forked from accel-sim/gpgpu-sim_distribution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
167 lines (149 loc) · 6.98 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
cmake_minimum_required(VERSION 3.17)
# Project name and version
project(GPGPU-Sim
VERSION 4.2.0
DESCRIPTION "cycle-level simulator modeling contemporary graphics processing units (GPUs)"
HOMEPAGE_URL https://github.com/accel-sim/gpgpu-sim_distribution
LANGUAGES CXX)
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# GPGPU-Sim build option
option(GPGPUSIM_ENABLE_TRACE "Whether to enable GPGPU-Sim debug tracing" ON)
# GPGPU-Sim conditional build variable
set(GPGPUSIM_USE_POWER_MODEL OFF)
set(GPGPUSIM_USE_OPENCL OFF)
# Check for dependencies
include(gpgpusim_check.cmake)
# Create version file
add_custom_target(gen_build_string ALL
COMMAND ${CMAKE_COMMAND} -D INPUT_DIR=${CMAKE_CURRENT_SOURCE_DIR} -D OUTPUT_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/gpgpusim_gen_build_string.cmake
COMMENT "Generating build string file to ${CMAKE_CURRENT_BINARY_DIR}")
# CMake target
# GPGPU-Sim CUDA Runtime lib
# Use the entrypoint object files sources else CMake will complain
add_library(cudart SHARED $<TARGET_OBJECTS:gpgpusim_entrypoint>)
add_library(entrypoint STATIC $<TARGET_OBJECTS:gpgpusim_entrypoint>)
# Add global C/CXX compilation flags and definitions
# TODO Specify more build modes like gem5 with fast opt?
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_compile_definitions(DEBUG=1)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wall;-Wno-unused-function;-Wno-sign-compare;-g;-fPIC>")
add_compile_options("$<$<COMPILE_LANGUAGE:C>:-Wall;-Wno-unused-function;-Wno-sign-compare;-ggdb;-fPIC>")
else()
add_compile_definitions(DEBUG=0)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-O3;-g;-Wall;-Wno-unused-function;-Wno-sign-compare;-fPIC>")
add_compile_options("$<$<COMPILE_LANGUAGE:C>:-Wall;-Wno-unused-function;-Wno-sign-compare;-fPIC>")
endif()
# Add CUDA version
add_compile_definitions(CUDART_VERSION=${CUDA_VERSION_NUMBER})
# OpenCL support
if(GPGPUSIM_USE_OPENCL)
add_compile_definitions(OPENGL_SUPPORT)
endif()
# Tracing support
if(GPGPUSIM_ENABLE_TRACE)
add_compile_definitions(TRACING_ON=1)
endif()
# Add subdirectory
add_subdirectory(src)
add_subdirectory(libcuda)
add_subdirectory(libopencl)
# Set linker option for libcudart.so
if(APPLE)
target_link_options(cudart PUBLIC "-Wl,-headerpad_max_install_names,-undefined,dynamic_lookup,-compatibility_version,1.1,-current_version,1.1;-lm;-lz;-pthread")
else()
target_link_options(cudart PUBLIC
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/linux-so-version.txt;-lm;-lz;-lGL;-pthread")
target_link_options(entrypoint PUBLIC
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/linux-so-version.txt;-lm;-lz;-lGL;-pthread")
endif()
# cuda: CUDA API lib
# ptxsim: cuda-sim, functional simulator
# gpgpusim: gpu simulator (gpgpu-sim)
# intersim: interconnect simulator
# accelwattch: power simulator
# Rest of source files in src/ will be created with gpgpusim_entrypoint target
target_link_libraries(cudart PUBLIC cuda ptxsim gpgpusim intersim)
target_link_libraries(entrypoint PUBLIC cuda ptxsim gpgpusim intersim)
if(GPGPUSIM_USE_POWER_MODEL)
target_link_libraries(cudart PUBLIC cuda ptxsim gpgpusim intersim accelwattch)
target_link_libraries(entrypoint PUBLIC cuda ptxsim gpgpusim intersim accelwattch)
endif()
# TODO Conditionally build for Opencl?
# if(GPGPUSIM_USE_OPENCL)
# add_library(OpenCL)
# endif()
# Install and post-install
# Get configure
set(GPGPUSIM_CONFIG "gcc-${CMAKE_CXX_COMPILER_VERSION}/cuda-${CUDA_VERSION_NUMBER}/${GPGPUSIM_BUILD_MODE}")
# Env var setup script
include(gpgpusim_gen_setup_environment.cmake)
# Installation
set(GPGPUSIM_INSTALL_PATH ${PROJECT_SOURCE_DIR}/lib/${GPGPUSIM_CONFIG})
install(TARGETS cudart DESTINATION ${GPGPUSIM_INSTALL_PATH})
# Installing symlinks
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.2\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.3\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.4\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.5.0\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.5.5\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.6.0\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.6.5\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.7.0\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.7.5\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.8.0\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.9.0\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.9.1\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.9.2\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.10.0\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.10.1\)")
install(CODE "execute_process\(\
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart> \
${GPGPUSIM_INSTALL_PATH}/$<TARGET_FILE_NAME:cudart>.11.0\)")