From 69809ecf14e68c0386086c22b57c4e18974a0705 Mon Sep 17 00:00:00 2001 From: maier Date: Wed, 13 Mar 2013 23:47:22 +0000 Subject: [PATCH] Porting to Windows: Enable thread support for native Windows targets (mingw so far) git-svn-id: https://svn.dealii.org/trunk@28893 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/bundled/CMakeLists.txt | 13 ++++----- .../libs/thread/src/CMakeLists.txt | 24 ++++++---------- .../bundled/tbb30_104oss/src/CMakeLists.txt | 28 ++++++------------- .../checks/check_01_system_features.cmake | 1 - .../cmake/configure/configure_1_threads.cmake | 17 +++++++++-- .../deal.II/base/std_cxx1x/shared_ptr.h | 1 + 6 files changed, 38 insertions(+), 46 deletions(-) diff --git a/deal.II/bundled/CMakeLists.txt b/deal.II/bundled/CMakeLists.txt index 97fb672f78..2035f528bb 100644 --- a/deal.II/bundled/CMakeLists.txt +++ b/deal.II/bundled/CMakeLists.txt @@ -66,14 +66,11 @@ ENDIF() # # Threading Building Blocks library # -IF(NOT CMAKE_SYSTEM_NAME MATCHES "CYGWIN" AND - NOT CMAKE_SYSTEM_NAME MATCHES "Windows") - SET(FEATURE_THREADS_HAVE_BUNDLED TRUE) - SET(TBB_FOLDER "${CMAKE_SOURCE_DIR}/bundled/tbb30_104oss") - OPTION(DEAL_II_FORCE_BUNDLED_THREADS - "Always use the bundled tbb library instead of an external one." - OFF) -ENDIF() +SET(FEATURE_THREADS_HAVE_BUNDLED TRUE) +OPTION(DEAL_II_FORCE_BUNDLED_THREADS + "Always use the bundled tbb library instead of an external one." + OFF) +SET(TBB_FOLDER "${CMAKE_SOURCE_DIR}/bundled/tbb30_104oss") IF(FEATURE_THREADS_BUNDLED_CONFIGURED) INSTALL(DIRECTORY ${TBB_FOLDER}/include/tbb diff --git a/deal.II/bundled/boost-1.49.0/libs/thread/src/CMakeLists.txt b/deal.II/bundled/boost-1.49.0/libs/thread/src/CMakeLists.txt index 5813b06168..7a87dfb931 100644 --- a/deal.II/bundled/boost-1.49.0/libs/thread/src/CMakeLists.txt +++ b/deal.II/bundled/boost-1.49.0/libs/thread/src/CMakeLists.txt @@ -19,28 +19,20 @@ IF(DEAL_II_USE_MT_POSIX) ) ELSE() SET(src_boost_thread - win32/once.cpp win32/thread.cpp + win32/tss_dll.cpp + win32/tss_pe.cpp ) ENDIF() DEAL_II_ADD_LIBRARY(obj_boost_thread OBJECT ${src_boost_thread}) +DEAL_II_ADD_DEFINITIONS(obj_boost_thread + "BOOST_THREAD_BUILD_LIB" "BOOST_ALL_NO_LIB" + ) -IF(DEAL_II_USE_MT_POSIX) - - # TODO: Necessary? - # include - - # ifndef UINTMAX_C - # define UINTMAX_C(x) x ## ULL - # endif - - DEAL_II_ADD_DEFINITIONS(obj_boost_thread - "BOOST_THREAD_BUILD_LIB" "BOOST_ALL_NO_LIB" - ) +IF(CMAKE_SYSTEM_NAME MATCHES "Windows") + DEAL_II_ADD_DEFINITIONS(obj_boost_thread "BOOST_HAS_WINTHREADS") ELSE() - DEAL_II_ADD_DEFINITIONS(obj_boost_thread - "BOOST_THREAD_BUILD_LIB" "BOOST_ALL_NO_LIB" "BOOST_THREAD_POSIX" - ) + DEAL_II_ADD_DEFINITIONS(obj_boost_thread "BOOST_THREAD_POSIX") ENDIF() diff --git a/deal.II/bundled/tbb30_104oss/src/CMakeLists.txt b/deal.II/bundled/tbb30_104oss/src/CMakeLists.txt index 5ecc1ee4e0..73bf87e16e 100644 --- a/deal.II/bundled/tbb30_104oss/src/CMakeLists.txt +++ b/deal.II/bundled/tbb30_104oss/src/CMakeLists.txt @@ -57,31 +57,21 @@ SET(src_tbb tbb/tbb_statistics.cpp tbb/tbb_thread.cpp ) +DEAL_II_ADD_LIBRARY(obj_tbb OBJECT ${src_tbb}) # # Add necessary definitions: # -SET(obj_tbb_DEFINITIONS) -IF(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") - LIST(APPEND obj_tbb_DEFINITIONS "DO_ITT_NOTIFY") -ENDIF() -IF(DEAL_II_USE_MT_POSIX) - LIST(APPEND obj_tbb_DEFINITIONS "USE_PTHREAD") -ENDIF() +IF(CMAKE_SYSTEM_NAME MATCHES "Windows") + DEAL_II_ADD_DEFINITIONS(obj_tbb "USE_WINTHREAD") -IF(CMAKE_SYSTEM_NAME MATCHES "CYGWIN") - MESSAGE(FATAL_ERROR "No support for internal tbb and CYGWIN atm.") - #LIST(APPEND obj_tbb_DEFINITIONS - # "USE_WINTHREAD" - # "_WIN32" - # "__MSVCRT_VERSION__=0x0700" - # ) - #ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-msse") - #ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-mthreads") -ENDIF() +ELSE() -DEAL_II_ADD_LIBRARY(obj_tbb OBJECT ${src_tbb}) + DEAL_II_ADD_DEFINITIONS(obj_tbb "USE_PTHREAD") -DEAL_II_ADD_DEFINITIONS(obj_tbb ${obj_tbb_DEFINITIONS}) + IF(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin") + DEAL_II_ADD_DEFINITIONS(obj_tbb "DO_ITT_NOTIFY") + ENDIF() +ENDIF() diff --git a/deal.II/cmake/checks/check_01_system_features.cmake b/deal.II/cmake/checks/check_01_system_features.cmake index fbf0412387..a942bf4820 100644 --- a/deal.II/cmake/checks/check_01_system_features.cmake +++ b/deal.II/cmake/checks/check_01_system_features.cmake @@ -81,7 +81,6 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Windows") # SET(DEAL_II_MSVC TRUE) - # # Disable shared libraries on native Windows targets for the moment. # diff --git a/deal.II/cmake/configure/configure_1_threads.cmake b/deal.II/cmake/configure/configure_1_threads.cmake index cee03a7dee..b1f5decacd 100644 --- a/deal.II/cmake/configure/configure_1_threads.cmake +++ b/deal.II/cmake/configure/configure_1_threads.cmake @@ -55,7 +55,14 @@ MACRO(SETUP_THREADING) # # Set up some posix thread specific configuration toggles: # - IF(CMAKE_USE_PTHREADS_INIT) + IF(NOT CMAKE_SYSTEM_NAME MATCHES "Windows") + + IF(NOT CMAKE_USE_PTHREADS_INIT) + MESSAGE(FATAL_ERROR + "\nInternal configuration error: Not on Windows but posix thread support unavailable\n\n" + ) + ENDIF() + SET(DEAL_II_USE_MT_POSIX TRUE) # @@ -76,11 +83,17 @@ MACRO(SETUP_THREADING) " DEAL_II_HAVE_MT_POSIX_BARRIERS) STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}") - IF(NOT DEAL_II_HAVE_MT_POSIX_BARRIERS) SET(DEAL_II_USE_MT_POSIX_NO_BARRIERS TRUE) ENDIF() + ELSE() + + # + # Poor Windows: + # + SET(DEAL_II_USE_MT_POSIX FALSE) + SET(DEAL_II_USE_MT_POSIX_NO_BARRIERS TRUE) ENDIF() ENDMACRO() diff --git a/deal.II/include/deal.II/base/std_cxx1x/shared_ptr.h b/deal.II/include/deal.II/base/std_cxx1x/shared_ptr.h index 9babfec48e..d51ccb5a2b 100644 --- a/deal.II/include/deal.II/base/std_cxx1x/shared_ptr.h +++ b/deal.II/include/deal.II/base/std_cxx1x/shared_ptr.h @@ -30,6 +30,7 @@ DEAL_II_NAMESPACE_CLOSE #else #include +#include DEAL_II_NAMESPACE_OPEN namespace std_cxx1x { -- 2.39.5