1
1
cmake_minimum_required (VERSION 3.14.5)
2
- project (GTBench LANGUAGES CXX)
2
+
3
+ file (STRINGS "version.txt" _gtbench_version)
4
+ project (GTBench VERSION ${_gtbench_version} LANGUAGES CXX)
5
+ unset (_gtbench_version)
3
6
4
7
if (NOT CMAKE_BUILD_TYPE )
5
8
set (CMAKE_BUILD_TYPE "Release" CACHE STRING
@@ -22,6 +25,9 @@ set(GTBENCH_BPARAMS_VDIFF "" CACHE STRING "Parameters for GridTools backend for
22
25
set (GTBENCH_BPARAMS_HADV "" CACHE STRING "Parameters for GridTools backend for horizontal advection" )
23
26
set (GTBENCH_BPARAMS_VADV "" CACHE STRING "Parameters for GridTools backend for vertical advection" )
24
27
28
+ option (GTBENCH_PYTHON_BINDINGS "Build Python bindings" OFF )
29
+
30
+ set (_gtbench_cuda_enabled OFF )
25
31
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND GTBENCH_BACKEND STREQUAL "gpu" )
26
32
set (GT_CLANG_CUDA_MODE "Clang-CUDA" CACHE STRING "Clang-CUDA or NVCC-CUDA" )
27
33
set_property (CACHE GT_CLANG_CUDA_MODE PROPERTY STRINGS "Clang-CUDA" "NVCC-CUDA" )
32
38
enable_language (CUDA)
33
39
set (CMAKE_CUDA_STANDARD 14)
34
40
set (CMAKE_CUDA_EXTENSIONS OFF )
41
+ set (_gtbench_cuda_enabled ON )
35
42
endif ()
36
43
endif ()
37
44
@@ -40,65 +47,56 @@ if(NOT _gridtools_already_fetched)
40
47
find_package (GridTools "2" QUIET )
41
48
endif ()
42
49
if (NOT GridTools_FOUND)
43
- set (_gridtools_repository "https://github.com/GridTools/gridtools.git" )
44
- set (_gridtools_tag "release_v2.0" )
45
- if (NOT _gridtools_already_fetched)
46
- message (STATUS "Fetching GridTools ${_gridtools_tag} from ${_gridtools_repository} " )
47
- endif ()
48
- include (FetchContent)
49
- FetchContent_Declare(
50
- gridtools
51
- GIT_REPOSITORY ${_gridtools_repository}
52
- GIT_TAG ${_gridtools_tag}
53
- )
54
- FetchContent_MakeAvailable(gridtools)
55
- set (_gridtools_already_fetched ON CACHE INTERNAL "" )
50
+ set (_gridtools_repository "https://github.com/GridTools/gridtools.git" )
51
+ set (_gridtools_tag "release_v2.0" )
52
+ if (NOT _gridtools_already_fetched)
53
+ message (STATUS "Fetching GridTools ${_gridtools_tag} from ${_gridtools_repository} " )
54
+ endif ()
55
+ include (FetchContent)
56
+ FetchContent_Declare(
57
+ gridtools
58
+ GIT_REPOSITORY ${_gridtools_repository}
59
+ GIT_TAG ${_gridtools_tag}
60
+ )
61
+ FetchContent_MakeAvailable(gridtools)
62
+ set (_gridtools_already_fetched ON CACHE INTERNAL "" )
56
63
endif ()
57
64
58
- set (CMAKE_CXX_STANDARD 14)
59
- set (CMAKE_CXX_EXTENSIONS OFF )
60
-
61
65
# Helper functions
62
66
function (compile_as_cuda)
63
- get_property (languages GLOBAL PROPERTY ENABLED_LANGUAGES )
64
- if ("CUDA" IN_LIST languages)
67
+ if (_gtbench_cuda_enabled)
65
68
set_source_files_properties (${ARGN} PROPERTIES LANGUAGE CUDA)
66
69
endif ()
67
70
endfunction ()
68
71
69
- add_library (common INTERFACE )
70
- target_compile_options (common INTERFACE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--default-stream per-thread>" )
71
-
72
- target_compile_definitions (common INTERFACE
72
+ add_library (gtbench_common INTERFACE )
73
+ target_include_directories (gtbench_common INTERFACE
74
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR} /include />
75
+ $<INSTALL_INTERFACE:include >
76
+ )
77
+ target_compile_definitions (gtbench_common INTERFACE
73
78
GTBENCH_BACKEND=${GTBENCH_BACKEND}
74
79
GTBENCH_BACKEND_$<UPPER_CASE:${GTBENCH_BACKEND} >
75
80
GTBENCH_FLOAT=${GTBENCH_FLOAT}
76
81
)
77
- target_link_libraries (common INTERFACE
82
+ target_link_libraries (gtbench_common INTERFACE
78
83
GridTools::gridtools
79
84
GridTools::stencil_${GTBENCH_BACKEND}
80
85
GridTools::storage_${GTBENCH_BACKEND}
81
- )
86
+ )
87
+ set_target_properties (
88
+ gtbench_common
89
+ PROPERTIES
90
+ INTERFACE_POSITION_INDEPENDENT_CODE ON )
82
91
83
- add_library (common_runtime INTERFACE )
84
- target_compile_definitions (common_runtime INTERFACE
85
- GTBENCH_RUNTIME=${GTBENCH_RUNTIME}
86
- )
87
- target_link_libraries (common_runtime INTERFACE
88
- common
89
- )
92
+ add_library (gtbench)
93
+ add_library (GTBench::gtbench ALIAS gtbench)
94
+ target_link_libraries (gtbench PUBLIC gtbench_common)
90
95
91
- # Subdirectories
92
- add_subdirectory (common)
93
- add_subdirectory (io)
94
- add_subdirectory (runtime)
95
- add_subdirectory (numerics)
96
+ add_subdirectory (src)
96
97
97
- # Current directory
98
- compile_as_cuda(convergence_tests.cpp benchmark.cpp)
98
+ include (${CMAKE_CURRENT_LIST_DIR} /cmake/export.cmake)
99
99
100
- add_executable (convergence_tests convergence_tests.cpp)
101
- target_link_libraries (convergence_tests advection diffusion options runtime device io)
102
-
103
- add_executable (benchmark benchmark.cpp)
104
- target_link_libraries (benchmark advection diffusion options runtime device io)
100
+ if (GTBENCH_PYTHON_BINDINGS)
101
+ add_subdirectory (python)
102
+ endif ()
0 commit comments