2 include(CheckIncludeFiles)
3 include(CheckFunctionExists)
4 #include(CheckCSourceCompiles)
6 #option(THREAD_PTHREADS "Use posix threads" ON)
8 MACRO(TEST_TMPI_ATOMICS VARIABLE)
9 if (NOT DEFINED TMPI_ATOMICS)
10 try_compile(TEST_ATOMICS "${CMAKE_BINARY_DIR}"
11 "${CMAKE_SOURCE_DIR}/cmake/TestAtomics.c"
12 COMPILE_DEFINITIONS "-I${CMAKE_SOURCE_DIR}/include" )
15 message(STATUS "Atomics found")
16 set(${VARIABLE} CACHE INTERNAL 1)
18 message(WARNING "Atomics not found for this compiler+cpu combination. Thread support will be unbearably slow: disable threads.
19 Atomics should work on all but the most obscure CPU+compiler combinations; if your system is not obscure -- like, for example, x86 with gcc -- please contact the developers.
21 set(${VARIABLE} CACHE INTERNAL 0)
23 endif(NOT DEFINED TMPI_ATOMICS)
24 ENDMACRO(TEST_TMPI_ATOMICS VARIABLE)
28 if (CMAKE_USE_PTHREADS_INIT)
29 check_include_files(pthread.h HAVE_PTHREAD_H)
30 #set(THREAD_PTHREADS 1)
31 add_definitions(-DTHREAD_PTHREADS)
33 thread_mpi/profile.c thread_mpi/barrier.c
34 thread_mpi/collective.c thread_mpi/reduce_fast.c
35 thread_mpi/comm.c thread_mpi/errhandler.c
36 thread_mpi/p2p.c thread_mpi/event.c
37 thread_mpi/threads.c thread_mpi/tmpi_init.c
38 thread_mpi/group.c thread_mpi/list.c
39 thread_mpi/topology.c thread_mpi/type.c
40 thread_mpi/once.c thread_mpi/hwinfo.c)
41 set(THREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
42 else (CMAKE_USE_PTHREADS_INIT)
43 if (CMAKE_USE_WIN32_THREADS_INIT)
45 add_definitions(-DTHREAD_WINDOWS)
47 thread_mpi/profile.c thread_mpi/barrier.c
48 thread_mpi/collective.c thread_mpi/reduce_fast.c
49 thread_mpi/comm.c thread_mpi/errhandler.c
50 thread_mpi/p2p.c thread_mpi/event.c
51 thread_mpi/threads.c thread_mpi/tmpi_init.c
52 thread_mpi/group.c thread_mpi/list.c
53 thread_mpi/topology.c thread_mpi/type.c
54 thread_mpi/once.c thread_mpi/hwinfo.c)
56 endif (CMAKE_USE_WIN32_THREADS_INIT)
57 endif (CMAKE_USE_PTHREADS_INIT)
59 # the spin-waiting option
60 option(THREAD_MPI_WAIT_FOR_NO_ONE "Use busy waits without yielding to the OS scheduler. Turning this on might improve performance (very) slightly at the cost of very poor performance if the threads are competing for CPU time." OFF)
61 mark_as_advanced(THREAD_MPI_WAIT_FOR_NO_ONE)
62 if (THREAD_MPI_WAIT_FOR_NO_ONE)
63 add_definitions(-DTMPI_WAIT_FOR_NO_ONE)
64 else (THREAD_MPI_WAIT_FOR_NO_ONE)
66 endif (THREAD_MPI_WAIT_FOR_NO_ONE)
69 # the copy buffer option
70 option(THREAD_MPI_COPY_BUFFER "Use an intermediate copy buffer for small message sizes, to allow blocking sends to return quickly." ON)
71 mark_as_advanced(THREAD_MPI_COPY_BUFFER)
72 if (THREAD_MPI_COPY_BUFFER)
74 else (THREAD_MPI_COPY_BUFFER)
75 add_definitions(-DTMPI_NO_COPY_BUFFER)
76 endif (THREAD_MPI_COPY_BUFFER)
79 # the profiling option
80 option(THREAD_MPI_PROFILING "Turn on simple MPI profiling." OFF)
81 mark_as_advanced(THREAD_MPI_PROFILING)
82 if (THREAD_MPI_PROFILING)
83 add_definitions(-DTMPI_PROFILE)
84 else (THREAD_MPI_PROFILING)
86 endif (THREAD_MPI_PROFILING)
89 # this runs on POSIX systems
90 check_include_files(unistd.h HAVE_UNISTD_H)
91 check_include_files(sched.h HAVE_SCHED_H)
92 check_include_files(sys/time.h HAVE_SYS_TIME_H)
93 check_function_exists(sysconf HAVE_SYSCONF)
94 # this runs on windows
95 #check_include_files(windows.h HAVE_WINDOWS_H)
96 #check_function_exists(GetSystemInfo HAVE_SYSTEM_INFO)
98 test_tmpi_atomics(TMPI_ATOMICS)