-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
133 lines (101 loc) · 4.78 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
cmake_minimum_required (VERSION 3.21)
project(SU3 LANGUAGES CXX)
set(CMAKE_CXX_EXTENSIONS OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(SOURCES su3_nn_bench.cpp)
add_executable(bench_f32 ${SOURCES})
add_executable(bench_f64 ${SOURCES})
target_compile_definitions(bench_f32 PUBLIC PRECISION=1)
if (${MODEL} STREQUAL "CUDA")
enable_language(CUDA)
set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE CUDA)
add_compile_definitions(USE_CUDA)
elseif (${MODEL} STREQUAL "HIP")
enable_language(HIP)
set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE HIP)
add_compile_definitions(USE_HIP)
elseif (${MODEL} STREQUAL "Kokkos")
set(CMAKE_CXX_STANDARD 17)
find_package(Kokkos REQUIRED)
add_compile_definitions(USE_KOKKOS)
target_link_libraries(bench_f32 Kokkos::kokkos)
target_link_libraries(bench_f64 Kokkos::kokkos)
if (${KOKKOS_BACK_END} STREQUAL "CUDA")
enable_language(CUDA)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -extended-lambda -Wext-lambda-captures-this -expt-relaxed-constexpr")
set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE CUDA)
elseif (${KOKKOS_BACK_END} STREQUAL "HIP")
enable_language(HIP)
set(CMAKE_HIP_STANDARD 17)
set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE HIP)
endif ()
elseif (${MODEL} STREQUAL "RAJA")
set(CMAKE_CXX_STANDARD 14)
find_package(RAJA REQUIRED)
find_package(Umpire REQUIRED)
add_compile_definitions(USE_RAJA)
target_link_libraries(bench_f32 RAJA umpire)
target_link_libraries(bench_f64 RAJA umpire)
if (${RAJA_BACK_END} STREQUAL "CUDA")
enable_language(CUDA)
set(CMAKE_CUDA_STANDARD 14)
set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE CUDA)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -extended-lambda --expt-relaxed-constexpr --restrict --keep")
set_target_properties(bench_f32 PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
set_target_properties(bench_f64 PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
elseif (${RAJA_BACK_END} STREQUAL "HIP")
enable_language(HIP)
find_package(hip REQUIRED)
set(CMAKE_HIP_STANDARD 14)
set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE HIP)
endif ()
elseif (${MODEL} STREQUAL "SYCL")
set(CMAKE_CXX_STANDARD 17)
add_compile_definitions(USE_SYCL MILC_COMPLEX)
find_package(AdaptiveCpp)
if (AdaptiveCpp_FOUND)
add_sycl_to_target(TARGET bench_f32 SOURCES ${SOURCES})
add_sycl_to_target(TARGET bench_f64 SOURCES ${SOURCES})
endif ()
separate_arguments(OFFLOAD_FLAGS)
target_compile_options(bench_f32 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_compile_options(bench_f64 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_link_options(bench_f32 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_link_options(bench_f64 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
elseif (${MODEL} STREQUAL "DPCPP")
set(CMAKE_CXX_STANDARD 17)
add_compile_definitions(USE_DPCPP MILC_COMPLEX)
find_package(AdaptiveCpp)
if (AdaptiveCpp_FOUND)
add_sycl_to_target(TARGET bench_f32 SOURCES ${SOURCES})
add_sycl_to_target(TARGET bench_f64 SOURCES ${SOURCES})
endif ()
separate_arguments(OFFLOAD_FLAGS)
target_compile_options(bench_f32 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_compile_options(bench_f64 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_link_options(bench_f32 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_link_options(bench_f64 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
elseif (${MODEL} STREQUAL "OpenACC")
add_compile_definitions(USE_OPENACC MILC_COMPLEX)
separate_arguments(OFFLOAD_FLAGS)
target_compile_options(bench_f32 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_compile_options(bench_f64 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_link_options(bench_f32 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_link_options(bench_f64 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
elseif (${MODEL} STREQUAL "OpenMP-Offload")
add_compile_definitions(USE_OPENMP MILC_COMPLEX)
separate_arguments(OFFLOAD_FLAGS)
target_compile_options(bench_f32 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_compile_options(bench_f64 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_link_options(bench_f32 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
target_link_options(bench_f64 PUBLIC "$<$<CONFIG:RELEASE>:${OFFLOAD_FLAGS}>")
else ()
message(FATAL_ERROR "Invalid Model")
endif ()
install(TARGETS bench_f32 bench_f64 DESTINATION bin)