Skip to content

Commit

Permalink
Adding back cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
JRPan committed Sep 3, 2024
1 parent 914ca23 commit 3c073e4
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
81 changes: 81 additions & 0 deletions gpu-simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
cmake_minimum_required(VERSION 3.17)

# Project name and version
project(Accel-Sim
VERSION 1.2.0
DESCRIPTION "Accel-Sim"
HOMEPAGE_URL https://github.com/accel-sim/accel-sim-framework
LANGUAGES CXX)

# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if($ENV{ACCELSIM_CONFIG} STREQUAL "debug")
set(CMAKE_BUILD_TYPE Debug)
else()
set(CMAKE_BUILD_TYPE Release)
endif()

# check envrionment variable string compare
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_compile_definitions(DEBUG=1)
add_compile_options(-Wall -O0 -g3 -fPIC)
else()
add_compile_definitions(DEBUG=0)
add_compile_options(-Wall -O3 -g3 -fPIC)
endif()

# run command
execute_process(
COMMAND git log --abbrev-commit -n 1
COMMAND head -1
COMMAND sed -re "s/commit (.*)/\\1/"
OUTPUT_VARIABLE GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git diff --numstat
COMMAND wc
COMMAND sed -re "s/^\\s+([0-9]+).*/\\1./"
OUTPUT_VARIABLE GIT_FILES_CHANGED_A
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git diff --numstat --cached
COMMAND wc
COMMAND sed -re "s/^\\s+([0-9]+).*/\\1/"
OUTPUT_VARIABLE GIT_FILES_CHANGED
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND date --iso-8601=minutes
OUTPUT_VARIABLE TIME
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(ACCELSIM_BUILD accelsim-commit-${GIT_COMMIT}_modified_${GIT_FILES_CHANGED_A}${GIT_FILES_CHANGED}_${TIME})

file(WRITE ${CMAKE_BINARY_DIR}/accelsim_version.h "const char *g_accelsim_version=\"${ACCELSIM_BUILD}\";")

add_subdirectory($ENV{GPGPUSIM_ROOT})
add_subdirectory(trace-driven)
add_subdirectory(trace-parser)


include_directories($ENV{CUDA_INSTALL_PATH}/include)
include_directories($ENV{GPGPUSIM_ROOT}/libcuda)
include_directories($ENV{GPGPUSIM_ROOT}/src)
include_directories(${CMAKE_BINARY_DIR})
include_directories(ISA_Def)
include_directories(trace-driven)
include_directories(trace-parser)


add_executable(accel-sim.out main.cc)
target_link_libraries(accel-sim.out PUBLIC cuda ptxsim gpgpusim intersim accelwattch entrypoint)
target_link_libraries(accel-sim.out PUBLIC -lm -lz -lGL -pthread)
target_link_libraries(accel-sim.out PUBLIC trace-driven trace-parser)


install(TARGETS accel-sim.out DESTINATION ${CMAKE_SOURCE_DIR}/bin/$ENV{ACCELSIM_CONFIG})
7 changes: 7 additions & 0 deletions gpu-simulator/trace-driven/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FILE(GLOB files *.cc)

include_directories($ENV{CUDA_INSTALL_PATH}/include)
include_directories($ENV{GPGPUSIM_ROOT}/libcuda)
include_directories($ENV{GPGPUSIM_ROOT}/src)

add_library(trace-driven STATIC ${files})
7 changes: 7 additions & 0 deletions gpu-simulator/trace-parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FILE(GLOB files *.cc)

include_directories($ENV{CUDA_INSTALL_PATH}/include)
include_directories($ENV{GPGPUSIM_ROOT}/libcuda)
include_directories($ENV{GPGPUSIM_ROOT}/src)

add_library(trace-parser STATIC ${files})

0 comments on commit 3c073e4

Please sign in to comment.