-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
118 lines (106 loc) · 4.55 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
option(ENABLE_CUDNN "Enable CUDNN|Scope (github.com/c3sr/cudnn_scope)" OFF)
if(NOT ENABLE_CUDNN)
return()
endif()
option(ENABLE_CUDNN_DLPERF "Enable CUDNN|Scope Generated benchmarks" OFF)
option(ENABLE_CUDNN_CUPTI "Enable CUDNN|Scope with CUPTI support" OFF)
option(MOBILENETV2_ONLY "Enable only MobileNet-v2 model" OFF)
option(ADD_TENSOR_ONLY "Enable only ADD Tensor layers" OFF)
option(RESNET50_ONLY "Enable only ResNet50-v1 model" OFF)
option(LOW_PRECISION "Enable only low precision benchmarks" OFF)
option(LOW_PRECISION_NHWC_MODE "Use NHWC mode for low precision benchmarks" OFF)
option(ENABLE_PADDING "Use padded conv layer" OFF)
option(CUDNN_CUPTI_NUM_ITERS "Number of iterations to use for CUPTI evaluation"
4)
option(CUDNN_BATCH_SIZE "Batch size to use for generated DLPerf data" OFF)
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(cudnn|Scope LANGUAGES CXX VERSION 1.0.0)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
include(ScopeStatus)
hunter_add_package(spdlog)
if(ENABLE_CUDNN_CUPTI)
find_package(CUPTI REQUIRED)
endif(ENABLE_CUDNN_CUPTI)
find_package(CuDNN REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(CUDA REQUIRED)
# Look for sugar.cmake files in the plugin src directory
sugar_include("src")
# The plugin is a static library that Scope will be linked with
if(RESNET50_ONLY AND NOT ADD_TENSOR_ONLY)
list(APPEND cudnn_BENCHMARK_FWD_SOURCES ${cudnn_BENCHMARK_FWD_FUSED_SOURCES})
endif(RESNET50_ONLY AND NOT ADD_TENSOR_ONLY)
scope_add_library(cudnn_scope OBJECT ${cudnn_BENCHMARK_FWD_SOURCES})
target_include_scope_directories(cudnn_scope)
target_include_directories(cudnn_scope
PRIVATE ${SCOPE_SRC_DIR}
${SCOPE_SRC_DIR}/scope
${SCOPE_THIRDPARTY_DIR}
${CUDA_INCLUDE_DIRS}
${PROJECT_BINARY_DIR}/src
${PROJECT_SOURCE_DIR}/src
${CUDNN_INCLUDE_DIR}
${CUPTI_INCLUDE_DIR})
# Get the git version
git_get_head_revision(GIT_REFSPEC GIT_HASH)
git_local_changes(GIT_LOCAL_CHANGES)
scope_status(GIT_REFSPEC=${GIT_REFSPEC})
scope_status(GIT_HASH=${GIT_HASH})
scope_status(GIT_LOCAL_CHANGES=${GIT_LOCAL_CHANGES})
set_property(TARGET cudnn_scope PROPERTY CUDA_STANDARD 11)
target_compile_features(cudnn_scope PUBLIC cxx_std_17)
target_compile_options(cudnn_scope
PRIVATE -Wno-narrowing
-Wno-unused-variable
-Wno-unused-function
-Wno-vla)
if(ENABLE_CUDNN_CUPTI)
target_compile_options(
cudnn_scope
PRIVATE -DENABLE_CUDNN_CUPTI=1
-DCUDNN_CUPTI_NUM_ITERS=${CUDNN_CUPTI_NUM_ITERS})
endif(ENABLE_CUDNN_CUPTI)
if(ENABLE_CUDNN_DLPERF)
target_compile_options(cudnn_scope PRIVATE -DGENERATED_BENCHMARK_LAYER=1)
endif(ENABLE_CUDNN_DLPERF)
if(CUDNN_BATCH_SIZE)
target_compile_options(cudnn_scope
PRIVATE -DCUDNN_BATCH_SIZE=${CUDNN_BATCH_SIZE})
endif(CUDNN_BATCH_SIZE)
if(LOW_PRECISION)
target_compile_options(cudnn_scope PRIVATE -DLOW_PRECISION=${LOW_PRECISION})
endif(LOW_PRECISION)
if(RESNET50_ONLY)
target_compile_options(cudnn_scope PRIVATE -DRESNET50_ONLY=${RESNET50_ONLY})
endif(RESNET50_ONLY)
if(MOBILENETV2_ONLY)
target_compile_options(cudnn_scope
PRIVATE -DMOBILENETV2_ONLY=${MOBILENETV2_ONLY})
endif(MOBILENETV2_ONLY)
if(LOW_PRECISION_NHWC_MODE)
target_compile_options(
cudnn_scope
PRIVATE -DLOW_PRECISION_NHWC_MODE=${LOW_PRECISION_NHWC_MODE})
endif(LOW_PRECISION_NHWC_MODE)
if(ADD_TENSOR_ONLY)
target_compile_options(cudnn_scope
PRIVATE -DADD_TENSOR_ONLY=${ADD_TENSOR_ONLY})
endif(ADD_TENSOR_ONLY)
if(ENABLE_PADDING)
target_compile_options(cudnn_scope PRIVATE -DENABLE_PADDING=${ENABLE_PADDING})
endif(ENABLE_PADDING)
target_link_libraries(cudnn_scope PRIVATE benchmark::benchmark)
target_link_libraries(cudnn_scope
PUBLIC cuda
${CUDNN_LIBRARY}
${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
spdlog::spdlog)
if(ENABLE_CUDNN_CUPTI)
target_link_libraries(cudnn_scope PUBLIC ${CUPTI_LIBRARY})
endif(ENABLE_CUDNN_CUPTI)
scope_status(
"${PROJECT_SOURCE_DIR}/src/config.hpp.in -> ${PROJECT_BINARY_DIR}/src/config.hpp"
)
configure_file("${PROJECT_SOURCE_DIR}/src/config.hpp.in"
"${PROJECT_BINARY_DIR}/src/config.hpp")