Backport ThreadMPI.cmake version from master
authorRoland Schulz <roland@utk.edu>
Sun, 11 Nov 2012 00:49:40 +0000 (19:49 -0500)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 12 Nov 2012 18:39:17 +0000 (19:39 +0100)
Allows to compile small part of ThreadMPI (e.g. for set_affinity)

Change-Id: I4b483a06fccf801399544c753487402ca5eec3a0

CMakeLists.txt
cmake/ThreadMPI.cmake

index 874360b7efe4e4632d5ea5ce165122d200f4c76d..068ee23762df7bcb81f70dc22da04eede4c5c6ce 100644 (file)
@@ -520,12 +520,14 @@ if (GMX_X11)
        endif(X11_FOUND)
 endif(GMX_X11)
 
+include(ThreadMPI)
+set(THREAD_MPI_LIB thread_mpi)
 if(GMX_THREAD_MPI)
+    tmpi_get_source_list(THREAD_MPI_SRC)
     set(PKG_CFLAGS "${PKG_CFLAGS} -DGMX_THREAD_MPI")
-    include(ThreadMPI)
-    set(THREAD_MPI_LIB thread_mpi)
     set(GMX_MPI 1)
-    string(TOUPPER ${GMX_FFT_LIBRARY} ${GMX_FFT_LIBRARY})
+else(GMX_THREAD_MPI)
+    tmpi_get_source_list(THREAD_MPI_SRC NOMPI)
 endif(GMX_THREAD_MPI)
 
 if(GMX_OPENMM)
index b528af0c249849c39d6f794d6e8635cca5f8569b..6292a223e230afacf8c23a5271a4f7b7bd1287f2 100644 (file)
@@ -28,11 +28,46 @@ ENDMACRO(TEST_TMPI_ATOMICS VARIABLE)
 
 MACRO(TMPI_MAKE_CXX_LIB)
     set(TMPI_CXX_LIB 1)
-    # the C++ library
-    set(THREAD_MPI_CXX_SRC
-        thread_mpi/system_error.cpp )
 ENDMACRO(TMPI_MAKE_CXX_LIB)
 
+MACRO(TMPI_GET_SOURCE_LIST SRC_VARIABLE)
+    foreach (_option IN ITEMS ${ARGN})
+        if (_option STREQUAL "CXX")
+            set(TMPI_CXX_LIB 1)
+        elseif (_option STREQUAL "NOMPI")
+            set(TMPI_NO_MPI_LIB 1)
+        else ()
+            message(FATAL_ERROR "Unknown thread_mpi option '${_option}'")
+        endif ()
+    endforeach ()
+    set(${SRC_VARIABLE}
+        thread_mpi/errhandler.c
+        thread_mpi/tmpi_malloc.c)
+    if (THREAD_PTHREADS)
+        list(APPEND ${SRC_VARIABLE} thread_mpi/pthreads.c)
+    elseif (THREAD_WINDOWS)
+        list(APPEND ${SRC_VARIABLE} thread_mpi/winthreads.c)
+    endif (THREAD_PTHREADS)
+    if (TMPI_CXX_LIB)
+        list(APPEND ${SRC_VARIABLE} thread_mpi/system_error.cpp)
+    endif (TMPI_CXX_LIB)
+    if (NOT TMPI_NO_MPI_LIB)
+        list(APPEND ${SRC_VARIABLE}
+             thread_mpi/alltoall.c      thread_mpi/p2p_protocol.c
+             thread_mpi/barrier.c       thread_mpi/p2p_send_recv.c
+             thread_mpi/bcast.c         thread_mpi/p2p_wait.c
+             thread_mpi/collective.c    thread_mpi/profile.c
+             thread_mpi/comm.c          thread_mpi/reduce.c
+             thread_mpi/event.c         thread_mpi/reduce_fast.c
+             thread_mpi/gather.c        thread_mpi/scatter.c
+             thread_mpi/group.c         thread_mpi/tmpi_init.c
+             thread_mpi/topology.c      thread_mpi/list.c
+             thread_mpi/type.c          thread_mpi/lock.c
+             thread_mpi/numa_malloc.c   thread_mpi/once.c
+             thread_mpi/scan.c)
+    endif()
+ENDMACRO(TMPI_GET_SOURCE_LIST)
+
 test_tmpi_atomics(TMPI_ATOMICS)
 
 # do we want to only the atomics of tMPI (with GPU + MPI)
@@ -42,41 +77,12 @@ if (CMAKE_USE_PTHREADS_INIT)
     check_include_files(pthread.h    HAVE_PTHREAD_H)
     set(THREAD_PTHREADS 1)
     #add_definitions(-DTHREAD_PTHREADS)
-    set(THREAD_MPI_SRC 
-        thread_mpi/alltoall.c      thread_mpi/p2p_protocol.c
-        thread_mpi/barrier.c       thread_mpi/p2p_send_recv.c
-        thread_mpi/bcast.c         thread_mpi/p2p_wait.c
-        thread_mpi/collective.c    thread_mpi/profile.c
-        thread_mpi/comm.c          thread_mpi/pthreads.c
-        thread_mpi/errhandler.c    thread_mpi/reduce.c
-        thread_mpi/event.c         thread_mpi/reduce_fast.c
-        thread_mpi/gather.c        thread_mpi/scatter.c
-        thread_mpi/group.c         thread_mpi/tmpi_init.c
-        thread_mpi/topology.c      thread_mpi/list.c          
-        thread_mpi/type.c          thread_mpi/lock.c
-        thread_mpi/numa_malloc.c   thread_mpi/once.c 
-        thread_mpi/scan.c          thread_mpi/tmpi_malloc.c)
     set(THREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
 else (CMAKE_USE_PTHREADS_INIT)
     if (CMAKE_USE_WIN32_THREADS_INIT)
         set(THREAD_WINDOWS 1)
         #add_definitions(-DTHREAD_WINDOWS)
-        set(THREAD_MPI_SRC 
-            thread_mpi/alltoall.c      thread_mpi/p2p_protocol.c
-            thread_mpi/barrier.c       thread_mpi/p2p_send_recv.c
-            thread_mpi/bcast.c         thread_mpi/p2p_wait.c
-            thread_mpi/collective.c    thread_mpi/profile.c
-            thread_mpi/comm.c          
-            thread_mpi/errhandler.c    thread_mpi/reduce.c
-            thread_mpi/event.c         thread_mpi/reduce_fast.c
-            thread_mpi/gather.c        thread_mpi/scatter.c
-            thread_mpi/group.c         thread_mpi/tmpi_init.c
-            thread_mpi/topology.c      thread_mpi/list.c
-            thread_mpi/type.c          thread_mpi/lock.c
-            thread_mpi/winthreads.c    thread_mpi/once.c
-            thread_mpi/numa_malloc.c
-            thread_mpi/scan.c          thread_mpi/tmpi_malloc.c)
-        set(THREAD_LIBRARY )
+        set(THREAD_LIB)
     endif (CMAKE_USE_WIN32_THREADS_INIT)
 endif (CMAKE_USE_PTHREADS_INIT)