-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
111 lines (81 loc) · 3.4 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
if(DEFINED PROJECT_NAME)
set(BigMPI_SUBPROJECT ON)
endif()
project(BigMPI)
cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
set(PACKAGE_NAME BigMPI)
# set macosx_rpath
set(CMAKE_MACOSX_RPATH 1)
# find and use detected mpi
find_package(MPI)
# generic function to add user-configurable options.
function(add_config_option name help_message default)
if(NOT DEFINED ${name})
set(${name} "${default}")
set(${name} "${default}" CACHE STRING "${help_message}" FORCE)
endif()
set(OPTIONS_LIST "${OPTIONS_LIST}\n\n * ${name}=\"${${name}}\",\n default=\"${default}\"\n ${help_message}" PARENT_SCOPE)
endfunction(add_config_option)
add_config_option(BIGMPI_MAX_INT "Determines which element count BigMPI will assume to be safe." 1000000)
add_config_option(BIGMPI_VCOLLS "Selects which flavor should be used for the implementation of vector collectives (valid options: RMA, P2P, NBHD_ALLTOALLW)" RMA)
add_config_option(LIB_LINKAGE_TYPE "Controls which type of library to build. Suggested: SHARED on Linux (creates a shared object \"bigmpi.so\"), STATIC should work for builds on Cray and Windows." "SHARED" false)
add_config_option(TEST_COVERAGE_VERBOSITY "Sets the verbosity of the test coverage reoprt (0 = off, 1 = summary, 2 = verbose listing)" 1)
message("-- The following options have been configured:")
message(${OPTIONS_LIST})
message("")
if (BIGMPI_MAX_INT)
add_definitions(-DBIGMPI_MAX_INT=${BIGMPI_MAX_INT})
endif()
add_definitions(-DBIGMPI_VCOLLS_${BIGMPI_VCOLLS})
set_property(GLOBAL PROPERTY C_STANDARD 99)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
include_directories(${MPI_INCLUDE_PATH})
string(APPEND CMAKE_C_COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
string(APPEND CMAKE_EXE_LINKER_FLAGS "${MPI_LINK_FLAGS}")
add_custom_target(bigmpi_test echo "Tests passed.")
add_subdirectory(src)
add_subdirectory(test)
# compute test coverage:
# will search all files matching WILDCARD for occurences of MPIX_Foo()
function(list_mpix_functions WILDCARD RESULT)
file(GLOB files "${WILDCARD}")
set(akku )
foreach(file ${files})
file(READ "${file}" file_content)
string(REPLACE ";" "" result1 "${file_content}")
string(REGEX MATCH "MPIX_[A-Za-z0-9_]+" matches "${result1}")
if(matches)
set(len_old "A")
set(len_new "B")
while(NOT (len_old EQUAL len_new))
string(REGEX REPLACE "(.*)(MPIX_[A-Za-z0-9_]+)(.+)" "\\2;\\1 " result2 "${result1}")
set(result1 "${result2}")
set(len_old "${len_new}")
string(LENGTH "${result1}" len_new )
endwhile()
list(APPEND akku "${result1}")
endif()
endforeach()
list(REMOVE_DUPLICATES akku)
list(SORT akku)
set("${RESULT}" "${akku}" PARENT_SCOPE)
endfunction()
list_mpix_functions("src/bigmpi.h" all_mpix_functions)
list_mpix_functions("test/*.c" tested_mpix_functions)
list(LENGTH all_mpix_functions num_all_mpix_functions)
list(LENGTH tested_mpix_functions num_tested_mpix_functions)
set(message_level STATUS)
if(num_all_mpix_functions GREATER num_tested_mpix_functions)
set(message_level WARNING)
endif()
if(TEST_COVERAGE_VERBOSITY GREATER 0)
message("${message_level}" "Test coverage: ${num_tested_mpix_functions}/${num_all_mpix_functions} functions.")
endif()
if(TEST_COVERAGE_VERBOSITY STREQUAL 2)
foreach(func ${all_mpix_functions})
list(FIND tested_mpix_functions "${func}" found)
if(found EQUAL -1)
message(STATUS "${func}() UNTESTED")
endif()
endforeach()
endif()