forked from GridTools/gtbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
67 lines (52 loc) · 2.16 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
cmake_minimum_required(VERSION 3.14.5)
project(GTBench LANGUAGES CXX)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
# User options
set(GTBENCH_BACKEND "mc" CACHE STRING "Benchmark backend")
set_property(CACHE GTBENCH_BACKEND PROPERTY STRINGS "x86" "mc" "cuda")
set(GTBENCH_FLOAT "float" CACHE STRING "Floating-point type")
set_property(CACHE GTBENCH_FLOAT PROPERTY STRINGS "float" "double")
set(GTBENCH_RUNTIME "single_node" CACHE STRING "Runtime")
set_property(CACHE GTBENCH_RUNTIME PROPERTY STRINGS "single_node" "simple_mpi" "gcl" "ghex_comm")
find_package(GridTools 1.1 REQUIRED)
if(GTBENCH_BACKEND STREQUAL "cuda" AND (NOT DEFINED GRIDTOOLS_CUDA_COMPILATION_TYPE
OR GRIDTOOLS_CUDA_COMPILATION_TYPE STREQUAL "NVCC-CUDA"))
enable_language(CUDA)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_EXTENSIONS OFF)
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
# Helper functions
function(compile_as_cuda)
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if("CUDA" IN_LIST languages)
set_source_files_properties(${ARGN} PROPERTIES LANGUAGE CUDA)
endif()
endfunction()
add_library(common INTERFACE)
target_compile_options(common INTERFACE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--default-stream per-thread>")
target_compile_definitions(common INTERFACE
GTBENCH_BACKEND=${GTBENCH_BACKEND}
GTBENCH_FLOAT=${GTBENCH_FLOAT}
)
target_link_libraries(common INTERFACE GridTools::gridtools)
add_library(common_runtime INTERFACE)
target_compile_definitions(common_runtime INTERFACE
GTBENCH_RUNTIME=${GTBENCH_RUNTIME}
)
target_link_libraries(common_runtime INTERFACE common)
# Subdirectories
add_subdirectory(common)
add_subdirectory(runtime)
add_subdirectory(numerics)
# Current directory
compile_as_cuda(convergence_tests.cpp benchmark.cpp)
add_executable(convergence_tests convergence_tests.cpp)
target_link_libraries(convergence_tests advection diffusion options runtime device)
add_executable(benchmark benchmark.cpp)
target_link_libraries(benchmark advection diffusion options runtime device)