Commit dd08ffd1 authored by John Biddiscombe's avatar John Biddiscombe
Browse files

Add abstraction layer for threading library std::thread or hpx::thread

Add CMake user setting to enable DCA_WITH_HPX

Add new parallel_hpx library that can be used in place of
parallel_stdthread to send all work to hpx::async and thread queues

Replace all library references to parallel_stdthread with ${DCA_THREADING_LIBS}
and set the DCA_THREADING_LIBS variable to parallel_stdthread or parallel_hpx
according to CMake user setting

Remove all #include "dca/parallel/stdthread/stdthread.hpp" and replace with
a generated #include "dca/config/threading.hpp" that sets the correct
variables to switch between threading libraries

Replace all references to future/mutex/condition_variable/locks with
thread_traits:: types that are defined in the generated threading.hpp
file and use std:: or hpx:: variants accordingly

Remove all use of dca::parallel::stdthread and replace with Threading
type setup in threading.hpp

Modify dca_add_gtest macro to detect if hpx is being used and add
appropriate flags to ensure that the hpx runtime is started when
int main() is called

Consistently use target_link_libraries(... PUBLIC/PRIVATE/INTERFACE ...)
to ensure compatibility with other libraries such as HPX that use the
newer CMake conventions
parent 538d38fb
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -133,7 +133,6 @@ set(DCA_LIBS
  nfft
  tetrahedron_mesh
  ${DCA_RNG_LIBRARY}
  parallel_stdthread
  parallel_util
  dca_algorithms
  json
+1 −1
Original line number Diff line number Diff line
@@ -3,5 +3,5 @@
if (DCA_BUILD_ANALYSIS)
  add_executable(main_analysis main_analysis.cpp)
  target_include_directories(main_analysis PRIVATE ${DCA_INCLUDE_DIRS})
  target_link_libraries(main_analysis ${DCA_LIBS})
  target_link_libraries(main_analysis PRIVATE ${DCA_LIBS})
endif()
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
if (DCA_BUILD_CLUSTER_SOLVER_CHECK)
  add_executable(cluster_solver_check cluster_solver_check.cpp)
  target_include_directories(cluster_solver_check PRIVATE ${DCA_INCLUDE_DIRS})
  target_link_libraries(cluster_solver_check ${DCA_LIBS} statistical_testing)
  target_link_libraries(cluster_solver_check  PRIVATE ${DCA_LIBS} statistical_testing)

  if (DCA_WITH_CUDA)
    cuda_add_cublas_to_target(cluster_solver_check)
+2 −2
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
if (DCA_BUILD_DCA)
  add_executable(main_dca main_dca.cpp)
  target_include_directories(main_dca PRIVATE ${DCA_INCLUDE_DIRS})
  target_link_libraries(main_dca ${DCA_LIBS})
  target_link_libraries(main_dca  PRIVATE ${DCA_LIBS})

  if (DCA_WITH_CUDA)
    cuda_add_cublas_to_target(main_dca)
+21 −2
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@ endif()
configure_file("${PROJECT_SOURCE_DIR}/include/dca/config/concurrency.hpp.in"
  "${CMAKE_BINARY_DIR}/include/dca/config/concurrency.hpp" @ONLY)

configure_file("${PROJECT_SOURCE_DIR}/include/dca/config/threading.hpp.in"
  "${CMAKE_BINARY_DIR}/include/dca/config/threading.hpp" @ONLY)

################################################################################
# Enable CUDA.
option(DCA_WITH_CUDA "Enable GPU support." OFF)
@@ -212,7 +215,23 @@ endif()
################################################################################
# Threading options/settings
if (UNIX)
  set(DCA_THREADING_LIBS "pthread")
  set(DCA_THREADING_LIBS pthread)
endif()

if (DCA_WITH_THREADED_SOLVER)
  set(DCA_THREADING_LIBS ${DCA_THREADING_LIBS} parallel_stdthread)
endif()

################################################################################
# Enable HPX threading support if desired
option(DCA_WITH_HPX "Enable HPX for multi-threading" OFF)
if (DCA_WITH_HPX)
  # if HPX is not found then DCA_HAVE_HPX will not be set
  include(dca_hpx)
  if (NOT DCA_HAVE_HPX)
    message(FATAL_ERROR "HPX library not found but requested.")
  endif()
  set(DCA_THREADING_LIBS parallel_hpx)
endif()

################################################################################
Loading