-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
73 lines (67 loc) · 3.06 KB
/
Copy pathCMakeLists.txt
File metadata and controls
73 lines (67 loc) · 3.06 KB
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
function(mdspan_add_benchmark EXENAME)
add_executable(${EXENAME} ${EXENAME}.cpp)
target_link_libraries(${EXENAME} mdspan benchmark::benchmark)
target_include_directories(${EXENAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/benchmarks>
)
endfunction()
find_package(benchmark REQUIRED)
function(mdspan_add_cuda_benchmark EXENAME)
add_executable(${EXENAME} ${EXENAME}.cu)
target_link_libraries(${EXENAME} PUBLIC mdspan)
target_include_directories(${EXENAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/benchmarks>
)
# This is gross, but it's the best I can do in this version of CMake
get_target_property(_benchmark_include benchmark::benchmark INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(_benchmark_libs_old benchmark::benchmark INTERFACE_LINK_LIBRARIES)
get_target_property(_benchmark_libs_imported benchmark::benchmark IMPORTED_LOCATION_RELEASE)
if(NOT _benchmark_libs_imported)
get_target_property(_benchmark_libs_imported benchmark::benchmark IMPORTED_LOCATION_DEBUG)
if(NOT _benchmark_libs_imported)
get_target_property(_benchmark_libs_imported benchmark::benchmark IMPORTED_LOCATION_RELWITHDEBINFO)
if(NOT _benchmark_libs_imported)
get_target_property(_benchmark_libs_imported benchmark::benchmark IMPORTED_LOCATION_MINSIZEREL)
if(NOT _benchmark_libs_imported)
message(FATAL_ERROR
"Could not figure out how to import google benchmark to hack around a cmake Cuda compatibility issue. Later versions of CMake will make this unnecessary"
)
else()
message(WARNING "Importing a Google Benchmark installation that was compiled in MinSizeRel mode. Times might not be reliable")
endif()
else()
message(WARNING "Importing a Google Benchmark installation that was compiled in RelWithDebInfo mode. Times might not be reliable")
endif()
else()
message(WARNING "Importing a Google Benchmark installation that was compiled in Debug mode. Times might not be reliable")
endif()
endif()
string(REPLACE "-pthread" "" _benchmark_libs "${_benchmark_libs_old}")
target_include_directories(${EXENAME} PUBLIC "${_benchmark_include}")
target_link_libraries(${EXENAME} PUBLIC "${_benchmark_libs};${_benchmark_libs_imported}")
if(_benchmark_libs_old MATCHES "-pthread")
target_compile_options(${EXENAME} PUBLIC "-Xcompiler=-pthread")
endif()
endfunction()
if(MDSPAN_ENABLE_OPENMP)
find_package(OpenMP)
endif()
function(mdspan_add_openmp_benchmark EXENAME)
if(MDSPAN_ENABLE_OPENMP)
if(OpenMP_CXX_FOUND)
add_executable(${EXENAME} ${EXENAME}.cpp)
target_link_libraries(${EXENAME} mdspan benchmark::benchmark OpenMP::OpenMP_CXX)
target_include_directories(${EXENAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/benchmarks>
)
else()
message(WARNING "Not adding target ${EXENAME} because OpenMP was not found")
endif()
endif()
endfunction()
add_subdirectory(extents)
add_subdirectory(sum)
add_subdirectory(matvec)
add_subdirectory(copy)
add_subdirectory(stencil)
add_subdirectory(tiny_matrix_add)