forked from NVIDIA/GPUStressTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
92 lines (72 loc) · 3.38 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
cmake_minimum_required(VERSION 3.8.0)
set(CUDA_HOME "/usr/local/cuda" CACHE STRING "" FORCE)
set(GPUStressTest_HOME "/home/dfisk/GPUStressTest" CACHE STRING "" FORCE)
set(LD_LIBRARY_PATH "${CUDA_HOME}/lib64;${LD_LIBRARY_PATH}")
set(CMAKE_VERBOSE_MAKEFILE "ON" CACHE STRING "" FORCE)
project(gst LANGUAGES CXX CUDA C)
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "" "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
#Config CUDA for this project:
set(FLAGS "")
set(CMAKE_CUDA_FLAGS "" CACHE STRING "" FORCE)
# Note that cmake will insert semicolons between these item automatically...
set(SM_LIST "70,75,80" CACHE STRING "Please input compute capability")
MARK_AS_ADVANCED(SM_LIST)
string(REPLACE "," " " DISPLAY_SMS_LIST ${SM_LIST})
string(REPLACE "," ";" SMS_LIST ${SM_LIST})
foreach(SM ${SMS_LIST})
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_${SM},code=sm_${SM}")
endforeach(SM)
message("-- GPU SM = " ${DISPLAY_SMS_LIST})
message("-- CMAKE_CUDA_FLAGS = " ${CMAKE_CUDA_FLAGS})
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
set(FLAGS ${FLAGS} "-G")
set(FLAGS ${FLAGS} -Xcompiler -g)
endif()
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -ccbin ${CMAKE_CXX_COMPILER}")
MARK_AS_ADVANCED(CLEAR CMAKE_CUDA_FLAGS)
# Global CXX/CUDA flags
set(CUDALIB_CUDA_CXX_FLAGS
"-Wall -Wextra -fno-strict-aliasing -Wno-unused-parameter -I${CUDA_HOME}/include -I${CUDA_HOME}/cublasLt -L${CUDA_HOME}/lib64"
# -fvisibility=hidde}
CACHE STRING "Common CXX/CUDA flags")
# Global CXX flags/options
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CUDALIB_CUDA_CXX_FLAGS}")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions("-DDEBUG=1")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--no-allow-shlib-undefined")
# Global CUDA CXX flags/options
set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_EXTENSIONS OFF)
if(CMAKE_CUDA_COMPILER_ID MATCHES CLANG)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${CUDALIB_CUDA_CXX_FLAGS} -fPIC")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" )
else() #NVCC
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -m64 -Xcompiler \"${CUDALIB_CUDA_CXX_FLAGS}\"")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xfatbin -compress-all")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcudafe --display_error_number") # Show error/warning numbers
endif()
get_filename_component(CUDA_COMPILER_DIR ${CMAKE_CUDA_COMPILER} DIRECTORY)
set(CUDA_TOOLKIT_ROOT_DIR ${CUDA_COMPILER_DIR}/..)
message(status " CUDA_TOOLKIT_ROOT_DIR: ${CUDA_TOOLKIT_ROOT_DIR}")
include_directories(${PROJECT_SOURCE_DIR}/util)
include_directories(${CUDA_TOOLKIT_ROOT_DIR}/include)
include_directories(${CUDA_HOME}/cublasLt)
LIST(APPEND SRC_FILES
${PROJECT_SOURCE_DIR}/util/test_args.cu
${PROJECT_SOURCE_DIR}/util/measure.cc
${PROJECT_SOURCE_DIR}/util/device_info.cu
)
add_executable(gst main.cu ${SRC_FILES})
target_link_libraries(gst cublas cublasLt)