Skip to content

Commit

Permalink
No SSE2 - warning, not a error. DT **builds** on aarch64/ARM64
Browse files Browse the repository at this point in the history
I'm using  #pragma message  because #warning produces a warning,
and we are building with -Werror - so it is a #error.
  • Loading branch information
LebedevRI committed Feb 13, 2016
1 parent 9f0a5a4 commit ff72e9c
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 22 deletions.
32 changes: 26 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ project(darktable CXX C)
cmake_minimum_required(VERSION 2.6)
cmake_policy(VERSION 2.6)

include(CheckCCompilerFlag)

# Check if this is source package build
if(NOT IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
set(SOURCE_PACKAGE 1)
else()
set(SOURCE_PACKAGE 0)
endif()

option(USE_CAMERA_SUPPORT "Detect and use camera support if available." ON)
option(USE_NLS "Build Native Language Support (using gettext)" ON)
option(USE_COLORD "Enable colord support" ON)
Expand All @@ -26,6 +35,23 @@ option(USE_WEBP "Enable WebP export support" ON)
option(BUILD_CMSTEST "Build a test program to check your system's color management setup" ON)
option(USE_OPENEXR "Enable OpenEXR support" ON)
option(BUILD_PRINT "Build the print module" ON)

if(NOT SOURCE_PACKAGE)
OPTION(BUILD_SSE2_CODEPATHS "(EXPERIMENTAL OPTION, DO NOT DISABLE) Building SSE2-optimized codepaths" ON)

if(BUILD_SSE2_CODEPATHS)
CHECK_C_COMPILER_FLAG("-msse2" _MSSE2)
if(NOT _MSSE2)
MESSAGE(WARNING "Building of SSE2-optimized codepaths is enabled, but the compiler does not understand -msse2.")
set(BUILD_SSE2_CODEPATHS OFF)
endif()
endif()
else()
set(BUILD_SSE2_CODEPATHS ON)
endif()

MESSAGE(STATUS "Building SSE2-optimized codepaths: ${BUILD_SSE2_CODEPATHS}")

if(APPLE)
option(USE_MAC_INTEGRATION "Enable OS X integration" ON)
else(APPLE)
Expand Down Expand Up @@ -80,12 +106,6 @@ if(WIN32)
set(USE_CAMERA_SUPPORT OFF)
endif(WIN32)

# Check if this is source package build
if(NOT IS_DIRECTORY ${CMAKE_SOURCE_DIR}/.git)
set(SOURCE_PACKAGE 1)
else()
set(SOURCE_PACKAGE 0)
endif()

#
# Set package version
Expand Down
21 changes: 17 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ int main() {
if(HAVE_BUILTIN_CPU_SUPPORTS)
add_definitions("-DHAVE_BUILTIN_CPU_SUPPORTS")
endif(HAVE_BUILTIN_CPU_SUPPORTS)
MESSAGE(STATUS "Does the compiler support __builtin_cpu_supports(): ${HAVE_BUILTIN_CPU_SUPPORTS}")

#
# Set default compile flags for GCC
Expand Down Expand Up @@ -375,8 +376,10 @@ if(WIN32)
endif(WIN32)

if(NOT CUSTOM_CFLAGS)
#we MUST always specify our requred instruction set, native might not detect it
set(DT_REQ_INSTRUCTIONS "-msse3")
if(BUILD_SSE2_CODEPATHS)
#we MUST always specify our requred instruction set, native might not detect it
set(DT_REQ_INSTRUCTIONS "-msse2")
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
set(MARCH "-msse4.2")
Expand All @@ -398,14 +401,21 @@ if(NOT CUSTOM_CFLAGS)
set(MARCH "-mtune=generic")
endif()

#if(NOT BUILD_SSE2_CODEPATHS)
# set(MARCH "${MARCH} -mno-sse2 -D__DISABLE_SSE2__ -U__SSE2__ -D__DISABLE_SSE__ -U__SSE__")
#endif()

#-g MUST be set for ALL builds, or there will be no support for them when bugs happen
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MARCH} ${DT_REQ_INSTRUCTIONS} -g")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O2")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -ffast-math -fno-finite-math-only")
if(CMAKE_COMPILER_IS_GNUCC)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpmath=sse")
if(BUILD_SSE2_CODEPATHS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfpmath=sse")
endif()

set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3 -ggdb3")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fexpensive-optimizations")
else()
Expand All @@ -418,7 +428,10 @@ if(NOT CUSTOM_CFLAGS)
if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse")
if(BUILD_SSE2_CODEPATHS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpmath=sse")
endif()

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -ggdb3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fexpensive-optimizations")
else()
Expand Down
10 changes: 10 additions & 0 deletions src/common/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ dt_cpu_flags_t dt_detect_cpu_features()

#undef cpuid
}
#else
dt_cpu_flags_t dt_detect_cpu_features()
{
static dt_cpu_flags_t cpuflags = 0;

fprintf(stderr, "[dt_detect_cpu_features] Not implemented for this architecture.\n");
fprintf(stderr, "[dt_detect_cpu_features] Please contribute a patch.\n");

return cpuflags;
}
#endif /* __i386__ || __x86_64__ */

// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
Expand Down
35 changes: 23 additions & 12 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,19 @@ static void dt_codepaths_init()
// disabling all optimized codepaths enables it automatically.
if(dt_conf_get_bool("codepaths/openmp_simd") || darktable.codepath._no_intrinsics)
#endif
{
darktable.codepath.OPENMP_SIMD = 1;
fprintf(stderr, "[dt_codepaths_init] will be using HIGHLY EXPERIMENTAL plain OpenMP SIMD codepath.\n");
}

#if defined(__SSE__)
if(darktable.codepath._no_intrinsics)
#endif
{
fprintf(stderr, "[dt_codepaths_init] SSE2-optimized codepath is disabled or unavailable.\n");
fprintf(stderr,
"[dt_codepaths_init] expect a LOT of functionality to be broken. you have been warned.\n");
}
}

int dt_init(int argc, char *argv[], const int init_gui, lua_State *L)
Expand All @@ -437,26 +449,25 @@ int dt_init(int argc, char *argv[], const int init_gui, lua_State *L)
_dt_sigsegv_old_handler = signal(SIGSEGV, &_dt_sigsegv_handler);
#endif

#ifndef __SSE3__
#error "Unfortunately we depend on SSE3 instructions at this time."
#error "Please contribute a backport patch (or buy a newer processor)."
#else
int sse3_supported = 0;
#ifndef __SSE2__
#pragma message "Building without SSE2 is highly experimental."
#pragma message "Expect a LOT of functionality to be broken. You have been warned."
#endif

int sse2_supported = 0;

#ifdef HAVE_BUILTIN_CPU_SUPPORTS
// NOTE: _may_i_use_cpu_feature() looks better, but only avaliable in ICC
__builtin_cpu_init();
sse3_supported = __builtin_cpu_supports("sse3");
sse2_supported = __builtin_cpu_supports("sse2");
#else
sse3_supported = dt_detect_cpu_features() & CPU_FLAG_SSE3;
sse2_supported = dt_detect_cpu_features() & CPU_FLAG_SSE2;
#endif
if(!sse3_supported)
if(!sse2_supported)
{
fprintf(stderr, "[dt_init] unfortunately we depend on SSE3 instructions at this time.\n");
fprintf(stderr, "[dt_init] please contribute a backport patch (or buy a newer processor).\n");
return 1;
fprintf(stderr, "[dt_init] SSE2 instruction set is unavailable.\n");
fprintf(stderr, "[dt_init] expect a LOT of functionality to be broken. you have been warned.\n");
}
#endif

#ifdef M_MMAP_THRESHOLD
mallopt(M_MMAP_THRESHOLD, 128 * 1024); /* use mmap() for large allocations */
Expand Down

0 comments on commit ff72e9c

Please sign in to comment.