-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
143 lines (129 loc) · 8.99 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(openfpm_devices LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CUDA_STANDARD 14)
if (ENABLE_GARBAGE_INJECTOR)
set(DEFINE_GARBAGE_INJECTOR "#define GARBAGE_INJECTOR")
endif()
if (OPENMP_FOUND)
set(DEFINE_HAVE_OPENMP "#define HAVE_OPENMP")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
if(CUDA_ON_CPU)
set(DEFINE_CUDA_GPU "#define CUDA_GPU")
endif()
if (CUDA_ON_BACKEND STREQUAL "HIP")
if(NOT HIP_FOUND)
message( FATAL_ERROR "HIP has not been found" )
else()
message("HIP has been found")
endif()
if (CUDA_ON_BACKEND="HIP")
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
set(DEFINE_CUDA_GPU "#define CUDA_GPU")
endif()
if(HIP_FOUND)
set(DEFINE_CUDA_GPU "#define CUDA_GPU")
set(DEFINE_CUDIFY_USE_HIP "#define CUDIFY_USE_HIP")
endif()
if (CUDA_ON_BACKEND STREQUAL "CUDA")
include(CheckLanguage)
if (CMAKE_CUDA_COMPILER)
set(CUDA_FOUND ON)
endif()
string(REPLACE "." ";" CUDA_VERSION_LIST ${CMAKE_CUDA_COMPILER_VERSION})
list(GET CUDA_VERSION_LIST 0 CUDA_VERSION_MAJOR)
list(GET CUDA_VERSION_LIST 1 CUDA_VERSION_MINOR)
list(GET CUDA_VERSION_LIST 2 CUDA_VERSION_PATCH)
if (CUDA_VERSION_MAJOR EQUAL 9 AND CUDA_VERSION_MINOR EQUAL 2)
message("CUDA is compatible 9.2")
set(WARNING_SUPPRESSION_AND_OPTION_NVCC -Xcudafe "--display_error_number --diag_suppress=611 --diag_suppress=2885 --diag_suppress=2886 --diag_suppress=2887 --diag_suppress=2888 --diag_suppress=186 --diag_suppress=111" --expt-extended-lambda)
set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT "-Xcudafe \"--display_error_number --diag_suppress=611 --diag_suppress=2885 --diag_suppress=2886 --diag_suppress=2887 --diag_suppress=2888 --diag_suppress=186 --diag_suppress=111\" --expt-extended-lambda ")
elseif ( CUDA_VERSION_MAJOR EQUAL 10 AND CUDA_VERSION_MINOR EQUAL 1 )
message("CUDA is compatible 10.1")
set(WARNING_SUPPRESSION_AND_OPTION_NVCC -Xcudafe "--display_error_number --diag_suppress=2931 --diag_suppress=2930 --diag_suppress=2929 --diag_suppress=2928 --diag_suppress=2915 --diag_suppress=2912 --diag_suppress=2913 --diag_suppress=111 --diag_suppress=186 --diag_suppress=611 --diag_suppress=128" --expt-extended-lambda)
set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT "-Xcudafe \"--display_error_number --display_error_number --diag_suppress=2931 --diag_suppress=2930 --diag_suppress=2929 --diag_suppress=2928 --diag_suppress=2915 --diag_suppress=2912 --diag_suppress=2913 --diag_suppress=111 --diag_suppress=186 --diag_suppress=611 --diag_suppress=128 \" --expt-extended-lambda")
elseif ( CUDA_VERSION_MAJOR EQUAL 10 AND CUDA_VERSION_MINOR EQUAL 2 )
message("CUDA is compatible 10.2")
set(WARNING_SUPPRESSION_AND_OPTION_NVCC -Xcudafe "--display_error_number --diag_suppress=2976 --diag_suppress=2977 --diag_suppress=2978 --diag_suppress=2979 --diag_suppress=1835 --diag_suppress=611 --diag_suppress=186 --diag_suppress=128" --expt-extended-lambda)
set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT "-Xcudafe \"--display_error_number --diag_suppress=2976 --diag_suppress=2977 --diag_suppress=2978 --diag_suppress=2979 --diag_suppress=1835 --diag_suppress=611 --diag_suppress=186 --diag_suppress=128\" --expt-extended-lambda")
elseif ( CUDA_VERSION_MAJOR EQUAL 11 AND CUDA_VERSION_MINOR EQUAL 0 )
message("CUDA is compatible 11.0")
set(WARNING_SUPPRESSION_AND_OPTION_NVCC -Xcudafe "--display_error_number --diag_suppress=3056 --diag_suppress=3057 --diag_suppress=3058 --diag_suppress=3059 --diag_suppress=611 --diag_suppress=186 --diag_suppress=128" --expt-extended-lambda)
set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT "-Xcudafe \"--display_error_number --diag_suppress=3056 --diag_suppress=3057 --diag_suppress=3058 --diag_suppress=3059 --diag_suppress=611 --diag_suppress=186 --diag_suppress=128\" --expt-extended-lambda")
elseif ( CUDA_VERSION_MAJOR EQUAL 11 AND CUDA_VERSION_MINOR EQUAL 1 )
message("CUDA is compatible 11.1")
set(WARNING_SUPPRESSION_AND_OPTION_NVCC -Xcudafe "--display_error_number --diag_suppress=3124 --diag_suppress=3126 --diag_suppress=3125 --diag_suppress=3123 --diag_suppress=611 --diag_suppress=186 --diag_suppress=128" --expt-extended-lambda)
set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT "-Xcudafe \"--display_error_number --diag_suppress=3124 --diag_suppress=3126 --diag_suppress=3125 --diag_suppress=3123 --diag_suppress=611 --diag_suppress=186 --diag_suppress=128\" --expt-extended-lambda")
elseif ( CUDA_VERSION_MAJOR EQUAL 11 AND (CUDA_VERSION_MINOR EQUAL 2 OR CUDA_VERSION_MINOR EQUAL 3 OR CUDA_VERSION_MINOR EQUAL 4 OR CUDA_VERSION_MINOR EQUAL 5 OR CUDA_VERSION_MINOR EQUAL 6 OR CUDA_VERSION_MINOR EQUAL 7 OR CUDA_VERSION_MINOR EQUAL 8))
message("CUDA is compatible 11.2/3/4/5")
set(WARNING_SUPPRESSION_AND_OPTION_NVCC -Xcudafe "--display_error_number --diag_suppress=20014 --diag_suppress=20013 --diag_suppress=20012 --diag_suppress=20011 --diag_suppress=611 --diag_suppress=550 --diag_suppress=186 --diag_suppress=128" --expt-extended-lambda)
set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT "-Xcudafe \"--display_error_number --diag_suppress=20014 --diag_suppress=20013 --diag_suppress=20012 --diag_suppress=20011 --diag_suppress=611 --diag_suppress=550 --diag_suppress=186 --diag_suppress=128\" --expt-extended-lambda")
elseif ( CUDA_VERSION_MAJOR EQUAL 12 AND (CUDA_VERSION_MINOR EQUAL 0 OR CUDA_VERSION_MINOR EQUAL 1 OR CUDA_VERSION_MINOR EQUAL 2 OR CUDA_VERSION_MINOR EQUAL 3 OR CUDA_VERSION_MINOR EQUAL 4 OR CUDA_VERSION_MINOR EQUAL 5))
message("CUDA is compatible 12")
set(WARNING_SUPPRESSION_AND_OPTION_NVCC -Xcudafe "--display_error_number --diag_suppress=20014 --diag_suppress=20013 --diag_suppress=20012 --diag_suppress=20011 --diag_suppress=611 --diag_suppress=550 --diag_suppress=186 --diag_suppress=128" --expt-extended-lambda)
set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT "-Xcudafe \"--display_error_number --diag_suppress=20014 --diag_suppress=20013 --diag_suppress=20012 --diag_suppress=20011 --diag_suppress=611 --diag_suppress=550 --diag_suppress=186 --diag_suppress=128\" --expt-extended-lambda")
else()
message(FATAL_ERROR "CUDA is incompatible, version 9.2 10.1 10.2 11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 12.0 12.1 12.2 12.3 12.4 12.5 is only supported")
endif()
set(DEFINE_CUDIFY_BACKEND "#define CUDIFY_USE_CUDA")
set(DEFINE_CUDA_GPU "#define CUDA_GPU")
elseif (CUDA_ON_BACKEND STREQUAL "OpenMP")
set(DEFINE_CUDIFY_BACKEND "#define CUDIFY_USE_OPENMP")
set(DEFINE_CUDA_GPU "#define CUDA_GPU")
elseif (CUDA_ON_BACKEND STREQUAL "SEQUENTIAL")
set(DEFINE_CUDIFY_BACKEND "#define CUDIFY_USE_SEQUENTIAL")
set(DEFINE_CUDA_GPU "#define CUDA_GPU")
endif()
if (ALPAKA_ROOT)
set(DEFINE_HAVE_ALPAKA "#define HAVE_ALPAKA")
endif()
if (CUDA_ON_BACKEND STREQUAL "SEQUENTIAL")
## We need BOOST_CONTEXT
if (NOT Boost_CONTEXT_FOUND)
message(FATAL_ERROR "Error to run CUDA on CPU (SEQUENTIAL backend) we need Boost::context installed, it seems is not available in your boost installation")
endif()
endif()
if (CUDA_ON_BACKEND STREQUAL "OpenMP")
## We need OpenMP
if (NOT OPENMP_FOUND OR NOT Boost_CONTEXT_FOUND)
message(FATAL_ERROR "Error to run CUDA on CPU (OpenMP backend) we need Boost::context and OpenMP installed, it seems is not available in your system")
endif()
endif()
if (CUDA_ON_BACKEND STREQUAL "HIP")
## We need HIP
if (NOT HIP_FOUND)
message(FATAL_ERROR "Error to run CUDA on HIP (HIP backend) RocM/HIP, it seems is not available in your system")
endif()
endif()
if (CUDA_ON_BACKEND STREQUAL "CUDA")
## We need CUDA
if (NOT CUDA_FOUND)
message(FATAL_ERROR "Error to run on CUDA you need a CUDA compatible compiler, it seems is not available in your system")
endif()
endif()
add_subdirectory (src)
get_directory_property(hasParent PARENT_DIRECTORY)
if(hasParent)
set(DEFINE_GARBAGE_INJECTOR ${DEFINE_GARBAGE_INJECTOR} CACHE INTERNAL "")
set(CMAKE_CXX_EXTENSIONS ${CMAKE_CXX_EXTENSIONS} CACHE INTERNAL "")
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} CACHE INTERNAL "")
set(WARNING_SUPPRESSION_AND_OPTION_NVCC ${WARNING_SUPPRESSION_AND_OPTION_NVCC} CACHE INTERNAL "")
set(WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT ${WARNING_SUPPRESSION_AND_OPTION_NVCC_TEXT} CACHE INTERNAL "")
set(DEFINE_CUDIFY_USE_HIP ${DEFINE_CUDIFY_USE_HIP} CACHE INTERNAL "")
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} CACHE INTERNAL "")
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} CACHE INTERNAL "")
set(DEFINE_HAVE_OPENMP ${DEFINE_HAVE_OPENMP} CACHE INTERNAL "")
set(DEFINE_CUDIFY_USE_HIP ${DEFINE_CUDIFY_USE_HIP} CACHE INTERNAL "")
set(DEFINE_CUDIFY_BACKEND ${DEFINE_CUDIFY_BACKEND} CACHE INTERNAL "")
set(DEFINE_CUDA_GPU ${DEFINE_CUDA_GPU} CACHE INTERNAL "")
set(DEFINE_HAVE_OPENMP ${DEFINE_HAVE_OPENMP} CACHE INTERNAL "")
set(DEFINE_HAVE_ALPAKA ${DEFINE_HAVE_ALPAKA} CACHE INTERNAL "")
set(CUDA_FOUND ${CUDA_FOUND} CACHE INTERNAL "")
set(CUDA_VERSION_MAJOR ${CUDA_VERSION_MAJOR} CACHE INTERNAL "")
set(CUDA_VERSION_MINOR ${CUDA_VERSION_MINOR} CACHE INTERNAL "")
set(CUDA_VERSION_PATCH ${CUDA_VERSION_PATCH} CACHE INTERNAL "")
endif()