summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliamMTK <[email protected]>2024-04-04 18:13:54 -0400
committerGitHub <[email protected]>2024-04-04 18:13:54 -0400
commitbc8061fd1e3c26be37e2cbb83ff9ca26e6f4dead (patch)
tree8ed2e1e3b37a6add49dc18f73ce7ea17ff46ab06
parent63893019e953269d1b0fb38e1fa8754992dd8d80 (diff)
Migrate gpgpu-sim build system to cmake (#66)
* migrate_cmake: add package dependency checking * migrate_cmake: port setup_environment to CMake * migrate_cmake: break dependency checking and env export gen to different .cmake files * migrate_cmake: use CUDAToolkit_FOUND to test for CUDA compiler * migrate_cmake: use CUDAToolkit_FOUND to test for CUDA compiler * migrate_cmake: use CUDAToolkit_FOUND to test for CUDA compiler * migrate_cmake: properly parse for cuda version number * migrate_cmake: set highest CUDA supported to be 11.10.x * migrate_cmake: specify top level CMake file * migrate_cmake: add libcuda cmake file * migrate_cmake: use global compiler options and definitions * migrate_cmake: add cmake file to src * migrate_cmake: add cmake files for cuda-sim folder * migrate_cmake: add cmake files to gpgpu-sim folder * migrate_cmake: add cmake files for intersim * migrate_cmake: add short test using cmake * migrate_cmake: bump CXX standard requirement to 17 * Add cmake files for accelwattch * migrate_cmake: remove use of GLOB to grab source files * migrate_cmake: comment out the write protection on generated instructions.h * migrate_cmake: create sym folder and add newline to generated setup file * migrate_cmake: fix some path issues * migrate_cmake: let cmake thinks flex and bison generate CXX files * migrate_cmake: fix not linking pthread properly * migrate_cmake: remove debug message * migrate_cmake: add empty libopencl cmake file * migrate_cmake: install phase and runtime version detect * Added install phase to install the shared object and add symlinks * Changes with CUDA toolkit will be detected and triggered a rebuild * GPGPU-Sim detailed version string will be updated on each build * Typo fix and fix correct bin dir * Replace gcc -> g++ in intersim * ignore setup * check CMAKE_BUILD_TYPE * set DCMAKE_BUILD_TYPE --------- Co-authored-by: JRPAN <[email protected]>
-rw-r--r--.github/workflows/cmake.yml83
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt167
-rw-r--r--gpgpusim_check.cmake136
-rw-r--r--gpgpusim_gen_build_string.cmake27
-rw-r--r--gpgpusim_gen_setup_environment.cmake31
-rw-r--r--gpgpusim_install.cmake2
-rw-r--r--gpgpusim_unset_cuda.cmake60
-rw-r--r--libcuda/CMakeLists.txt26
-rw-r--r--libopencl/CMakeLists.txt0
-rwxr-xr-xshort-tests-cmake.sh27
-rw-r--r--src/CMakeLists.txt19
-rw-r--r--src/accelwattch/CMakeLists.txt46
-rw-r--r--src/cuda-sim/CMakeLists.txt78
-rw-r--r--src/gpgpu-sim/CMakeLists.txt36
-rw-r--r--src/intersim2/CMakeLists.txt106
-rw-r--r--src/intersim2/Makefile2
-rw-r--r--src/intersim2/config_utils.cpp10
-rw-r--r--src/intersim2/config_utils.hpp2
-rw-r--r--src/intersim2/interconnect_interface.cpp2
-rw-r--r--version.in1
21 files changed, 854 insertions, 8 deletions
diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml
new file mode 100644
index 0000000..ab9bfd0
--- /dev/null
+++ b/.github/workflows/cmake.yml
@@ -0,0 +1,83 @@
+# Workflow with cmake build system
+name: Short-Tests-CMake
+
+# Controls when the workflow will run
+on:
+ # Triggers the workflow on push or pull request events but only for the mydev branch
+ push:
+ pull_request:
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ build-TITANV:
+ runs-on: ubuntu-latest
+ container:
+ image: tgrogers/accel-sim_regress:Ubuntu-22.04-cuda-11.7
+ env:
+ CONFIG: TITANV
+
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - uses: actions/checkout@v4
+ - name: Run Simulation
+ run: /bin/bash $GITHUB_WORKSPACE/short-tests-cmake.sh
+
+ build-TITANV-LOCALXBAR:
+ runs-on: ubuntu-latest
+ container:
+ image: tgrogers/accel-sim_regress:Ubuntu-22.04-cuda-11.7
+ env:
+ CONFIG: TITANV-LOCALXBAR
+
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - uses: actions/checkout@v4
+ - name: Run Simulation
+ run: /bin/bash $GITHUB_WORKSPACE/short-tests-cmake.sh
+
+ build-QV100:
+ runs-on: ubuntu-latest
+ container:
+ image: tgrogers/accel-sim_regress:Ubuntu-22.04-cuda-11.7
+ env:
+ CONFIG: QV100
+
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - uses: actions/checkout@v4
+ - name: Run Simulation
+ run: /bin/bash $GITHUB_WORKSPACE/short-tests-cmake.sh
+
+ build-2060:
+ runs-on: ubuntu-latest
+ container:
+ image: tgrogers/accel-sim_regress:Ubuntu-22.04-cuda-11.7
+ env:
+ CONFIG: RTX2060
+
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - uses: actions/checkout@v4
+ - name: Run Simulation
+ run: /bin/bash $GITHUB_WORKSPACE/short-tests-cmake.sh
+
+ build-3070:
+ runs-on: ubuntu-latest
+ container:
+ image: tgrogers/accel-sim_regress:Ubuntu-22.04-cuda-11.7
+ env:
+ CONFIG: RTX3070
+
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - uses: actions/checkout@v4
+ - name: Run Simulation
+ run: /bin/bash $GITHUB_WORKSPACE/short-tests-cmake.sh
diff --git a/.gitignore b/.gitignore
index 4b343c5..340277a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,3 +61,4 @@ debug_tools/WatchYourStep/ptxjitplus/*.ptx
accel-sim-framework/
gpu-app-collection/
+setup
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..95ca8e0
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,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\)") \ No newline at end of file
diff --git a/gpgpusim_check.cmake b/gpgpusim_check.cmake
new file mode 100644
index 0000000..5da46c9
--- /dev/null
+++ b/gpgpusim_check.cmake
@@ -0,0 +1,136 @@
+# Dependency checking
+# Unset FindCUDA variables so that it
+# gets reconfigured
+include(gpgpusim_unset_cuda.cmake)
+
+find_package(Git REQUIRED)
+find_package(BISON REQUIRED)
+find_package(FLEX REQUIRED)
+find_package(ZLIB REQUIRED)
+find_package(CUDAToolkit REQUIRED)
+find_package(Doxygen)
+find_package(Python3)
+
+# GPGPU-Sim additional checking and info
+message(CHECK_START "Additional settings for ${CMAKE_PROJECT_NAME}")
+list(APPEND CMAKE_MESSAGE_INDENT " ")
+
+# Check for OS
+message(CHECK_START "Checking for OS")
+if((NOT APPLE) AND (NOT UNIX) AND (NOT LINUX))
+ message(FATAL_ERROR "${CMAKE_SYSTEM_NAME} not supported")
+else()
+ message(CHECK_PASS ${CMAKE_SYSTEM_NAME})
+endif()
+
+# Check for version
+message(CHECK_START "Checking GPGPU-Sim version")
+message(CHECK_PASS "${CMAKE_PROJECT_VERSION}")
+
+# Check for git commit hash
+message(CHECK_START "Checking git commit hash")
+# Get the latest abbreviated commit hash of the working branch
+execute_process(
+ COMMAND git log -1 --format=%H
+ WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+ OUTPUT_VARIABLE GPGPUSIM_CONFIG_GIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ RESULT_VARIABLE GPGPUSIM_CHECK_GIT_HASH
+)
+if(${GPGPUSIM_CHECK_GIT_HASH})
+ message(CHECK_FAIL "not a git repo")
+else()
+ message(CHECK_PASS "${GPGPUSIM_CONFIG_GIT_HASH}")
+endif()
+
+# Check for compiler and version
+message(CHECK_START "Checking CXX compiler")
+if(NOT (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU))
+ message(CHECK_FAIL "GPGPU-Sim only tested with GCC: ${CMAKE_CXX_COMPILER_ID}")
+else()
+ message(CHECK_PASS "${CMAKE_CXX_COMPILER}")
+endif()
+message(CHECK_START "Checking CXX compiler version")
+message(CHECK_PASS "${CMAKE_CXX_COMPILER_VERSION}")
+set(GPGPSIM_CC_VERSION )
+
+# Check for CUDA nvcc and version
+# Check already done with find_package, here just to display the path and version
+message(CHECK_START "Checking CUDA compiler")
+if(NOT CUDAToolkit_FOUND)
+ message(CHECK_FAIL "not found")
+else()
+ message(CHECK_PASS "${CUDAToolkit_NVCC_EXECUTABLE}")
+ message(CHECK_START "Checking CUDA compiler version")
+ message(CHECK_PASS "${CUDAToolkit_VERSION}")
+ if((CUDAToolkit_VERSION VERSION_LESS 2.0.3) OR (CUDAToolkit_VERSION VERSION_GREATER 11.10.0))
+ message(FATAL_ERROR "GPGPU-Sim ${CMAKE_PROJECT_VERSION} not tested with CUDA version ${CUDAToolkit_VERSION} (please see README)")
+ endif()
+endif()
+
+# Check for Power model
+# TODO How to configure the project to look for it?
+message(CHECK_START "Checking for GPGPU-Sim power model")
+if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/src/accelwattch)
+ if(NOT EXISTS ${PROJECT_SOURCE_DIR}/src/accelwattch/gpgpu_sim.verify)
+ message(FATAL_ERROR "gpgpu_sim.verify not found in ${PROJECT_SOURCE_DIR}/src/accelwattch/")
+ endif()
+ message(CHECK_PASS "${PROJECT_SOURCE_DIR}/src/accelwattch/")
+ set(GPGPUSIM_USE_POWER_MODEL True)
+ set(GPGPUSIM_POWER_MODEL ${PROJECT_SOURCE_DIR}/src/accelwattch)
+elseif(DEFINED ${GPGPUSIM_POWER_MODEL})
+ if(NOT EXISTS ${GPGPUSIM_POWER_MODEL}/gpgpu_sim.verify)
+ message(FATAL_ERROR "gpgpu_sim.verify not found in ${GPGPUSIM_POWER_MODEL} - Either incorrect directory or incorrect McPAT version")
+ endif()
+ message(CHECK_PASS "${GPGPUSIM_POWER_MODEL}")
+ set(GPGPUSIM_USE_POWER_MODEL True)
+else()
+ message(CHECK_PASS "configured without a power model")
+endif()
+
+# Set Build path
+# Get CUDA version
+set(CUDA_VERSION_STRING "${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR}")
+# execute_process(
+# COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} --version
+# COMMAND awk "/release/ {print $5;}"
+# COMMAND sed "s/,//"
+# WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+# OUTPUT_VARIABLE CUDA_VERSION_STRING
+# OUTPUT_STRIP_TRAILING_WHITESPACE
+# )
+
+# CMake cannot do formatted string output, so we just use the good old `awk`
+# math(EXPR CUDA_VERSION_NUMBER_MAJOR "${CUDAToolkit_VERSION_MAJOR} * 10")
+# math(EXPR CUDA_VERSION_NUMBER_MINOR "${CUDAToolkit_VERSION_MINOR} * 10")
+# set(CUDA_VERSION_NUMBER "${CUDA_VERSION_NUMBER_MAJOR}${CUDA_VERSION_NUMBER_MINOR}")
+execute_process(
+ COMMAND echo ${CUDA_VERSION_STRING}
+ COMMAND sed "s/\\./ /"
+ COMMAND awk "{printf(\"%02u%02u\", 10*int($1), 10*$2);}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+ OUTPUT_VARIABLE CUDA_VERSION_NUMBER
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+# Get debug or release
+# Set with -DCMAKE_BUILD_TYPE=Debug|Release to change build type
+message(CHECK_START "Checking for CMAKE_BUILD_TYPE")
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Release)
+ set(GPGPUSIM_BUILD_MODE "release" CACHE STRING "" FORCE)
+else()
+ string(TOLOWER "${CMAKE_BUILD_TYPE}" GPGPUSIM_BUILD_MODE)
+ set(CMAKE_BUILD_TYPE Debug)
+endif()
+message(CHECK_PASS "${CMAKE_BUILD_TYPE}")
+# TODO: Make this step an installation phase that handle copying so and creating symlinks
+message(STATUS "Setting binary directory to ${CMAKE_BINARY_DIR}")
+
+# TODO OpenCL check/support?
+
+list(POP_BACK CMAKE_MESSAGE_INDENT)
+message(CHECK_PASS "done")
+message(STATUS "Be sure to run 'source setup' "
+ "before you run CUDA program with GPGPU-Sim or building with external "
+ "simulator like SST") \ No newline at end of file
diff --git a/gpgpusim_gen_build_string.cmake b/gpgpusim_gen_build_string.cmake
new file mode 100644
index 0000000..4559570
--- /dev/null
+++ b/gpgpusim_gen_build_string.cmake
@@ -0,0 +1,27 @@
+# Get hash
+execute_process(
+ COMMAND git log -1 --format=%h
+ WORKING_DIRECTORY ${INPUT_DIR}
+ OUTPUT_VARIABLE GPGPUSIM_GIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+# Get diff
+execute_process(
+ COMMAND git diff --numstat
+ COMMAND wc
+ COMMAND sed -re "s/^\\s+([0-9]+).*/\\1./"
+ WORKING_DIRECTORY ${INPUT_DIR}
+ OUTPUT_VARIABLE GPGPUSIM_GIT_DIFF
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+execute_process(
+ COMMAND git diff --numstat --staged
+ COMMAND wc
+ COMMAND sed -re "s/^\\s+([0-9]+).*/\\1./"
+ WORKING_DIRECTORY ${INPUT_DIR}
+ OUTPUT_VARIABLE GPGPUSIM_GIT_DIFF_STAGED
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+set(GPGPUSIM_BUILD_STRING "gpgpu-sim_git-commit-${GPGPUSIM_GIT_HASH}_modified_${GPGPUSIM_GIT_DIFF}${GPGPUSIM_GIT_DIFF_STAGED}")
+configure_file(${INPUT_DIR}/version.in ${OUTPUT_DIR}/detailed_version)
diff --git a/gpgpusim_gen_setup_environment.cmake b/gpgpusim_gen_setup_environment.cmake
new file mode 100644
index 0000000..e74a7f5
--- /dev/null
+++ b/gpgpusim_gen_setup_environment.cmake
@@ -0,0 +1,31 @@
+# Need to create a setup script to set some variables for others to interact with
+set(SETUP_SCRIPT_FILENAME "setup")
+message(STATUS "Writing setup commands to '${SETUP_SCRIPT_FILENAME}'")
+file(WRITE ${SETUP_SCRIPT_FILENAME} "export GPGPUSIM_SETUP_ENVIRONMENT_WAS_RUN=1\n")
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export GPGPUSIM_ROOT=${PROJECT_SOURCE_DIR}\n")
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export GPGPUSIM_CONFIG=${GPGPUSIM_CONFIG}\n")
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export CUDA_INSTALL_PATH=${CUDAToolkit_TARGET_DIR}\n")
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export PATH=`echo $PATH | sed 's#$GPGPUSIM_ROOT/bin:$CUDA_INSTALL_PATH/bin:##'`\n")
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export PATH=$GPGPUSIM_ROOT/bin:$CUDA_INSTALL_PATH/bin:$PATH\n")
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export CUDA_VERSION_NUMBER=${CUDA_VERSION_NUMBER}\n")
+if(CUDA_VERSION_NUMBER GREATER_EQUAL 6000)
+ file(APPEND ${SETUP_SCRIPT_FILENAME} "export PTX_SIM_USE_PTX_FILE=1.ptx\n")
+ file(APPEND ${SETUP_SCRIPT_FILENAME} "export PTX_SIM_KERNELFILE=_1.ptx\n")
+ file(APPEND ${SETUP_SCRIPT_FILENAME} "export CUOBJDUMP_SIM_FILE=jj\n")
+endif()
+# TODO What about OpenCL support?
+
+# setting LD_LIBRARY_PATH as follows enables GPGPU-Sim to be invoked by
+# native CUDA and OpenCL applications. GPGPU-Sim is dynamically linked
+# against instead of the CUDA toolkit. This replaces this cumbersome
+# static link setup in prior GPGPU-Sim releases.
+# Create a softlink for backward support
+if(APPLE)
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export DYLD_LIBRARY_PATH=`echo $DYLD_LIBRARY_PATH | sed -Ee 's#'$GPGPUSIM_ROOT'\/lib\/[0-9]+\/(debug|release):##'`\n")
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export DYLD_LIBRARY_PATH=$GPGPUSIM_ROOT/lib/$GPGPUSIM_CONFIG:$DYLD_LIBRARY_PATH\n")
+else()
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | sed -re 's#'$GPGPUSIM_ROOT'\/lib\/[0-9]+\/(debug|release):##'`\n")
+file(APPEND ${SETUP_SCRIPT_FILENAME} "export LD_LIBRARY_PATH=$GPGPUSIM_ROOT/lib/$GPGPUSIM_CONFIG:$LD_LIBRARY_PATH\n")
+endif()
+
+# TODO ignore the OPENCL_REMOTE_GPU_HOST part? \ No newline at end of file
diff --git a/gpgpusim_install.cmake b/gpgpusim_install.cmake
new file mode 100644
index 0000000..1590bf3
--- /dev/null
+++ b/gpgpusim_install.cmake
@@ -0,0 +1,2 @@
+# TODO Create the build/gcc-X.X/cuda-XXXX/release folder and put so to it
+# TODO Also create symlinks to the libcudart.so \ No newline at end of file
diff --git a/gpgpusim_unset_cuda.cmake b/gpgpusim_unset_cuda.cmake
new file mode 100644
index 0000000..4eaef91
--- /dev/null
+++ b/gpgpusim_unset_cuda.cmake
@@ -0,0 +1,60 @@
+# Unset these variable to force a re-search on possible CUDA version changes
+unset(CUDAToolkit_BIN_DIR CACHE)
+unset(CUDAToolkit_CUPTI_INCLUDE_DIR CACHE)
+unset(CUDAToolkit_NVCC_EXECUTABLE CACHE)
+unset(CUDAToolkit_rt_LIBRARY CACHE)
+unset(CUDA_CUDART CACHE)
+unset(CUDA_OpenCL_LIBRARY CACHE)
+unset(CUDA_cublasLt_LIBRARY CACHE)
+unset(CUDA_cublasLt_static_LIBRARY CACHE)
+unset(CUDA_cublas_LIBRARY CACHE)
+unset(CUDA_cublas_static_LIBRARY CACHE)
+unset(CUDA_cuda_driver_LIBRARY CACHE)
+unset(CUDA_cudart_LIBRARY CACHE)
+unset(CUDA_cudart_static_LIBRARY CACHE)
+unset(CUDA_cufft_LIBRARY CACHE)
+unset(CUDA_cufft_static_LIBRARY CACHE)
+unset(CUDA_cufft_static_nocallback_LIBRARY CACHE)
+unset(CUDA_cufftw_LIBRARY CACHE)
+unset(CUDA_cufftw_static_LIBRARY CACHE)
+unset(CUDA_culibos_LIBRARY CACHE)
+unset(CUDA_cupti_LIBRARY CACHE)
+unset(CUDA_cupti_static_LIBRARY CACHE)
+unset(CUDA_curand_LIBRARY CACHE)
+unset(CUDA_curand_static_LIBRARY CACHE)
+unset(CUDA_cusolver_LIBRARY CACHE)
+unset(CUDA_cusolver_lapack_static_LIBRARY CACHE)
+unset(CUDA_cusolver_static_LIBRARY CACHE)
+unset(CUDA_cusparse_LIBRARY CACHE)
+unset(CUDA_cusparse_static_LIBRARY CACHE)
+unset(CUDA_nppc_LIBRARY CACHE)
+unset(CUDA_nppc_static_LIBRARY CACHE)
+unset(CUDA_nppial_LIBRARY CACHE)
+unset(CUDA_nppial_static_LIBRARY CACHE)
+unset(CUDA_nppicc_LIBRARY CACHE)
+unset(CUDA_nppicc_static_LIBRARY CACHE)
+unset(CUDA_nppicom_LIBRARY CACHE)
+unset(CUDA_nppicom_static_LIBRARY CACHE)
+unset(CUDA_nppidei_LIBRARY CACHE)
+unset(CUDA_nppidei_static_LIBRARY CACHE)
+unset(CUDA_nppif_LIBRARY CACHE)
+unset(CUDA_nppif_static_LIBRARY CACHE)
+unset(CUDA_nppig_LIBRARY CACHE)
+unset(CUDA_nppig_static_LIBRARY CACHE)
+unset(CUDA_nppim_LIBRARY CACHE)
+unset(CUDA_nppim_static_LIBRARY CACHE)
+unset(CUDA_nppist_LIBRARY CACHE)
+unset(CUDA_nppist_static_LIBRARY CACHE)
+unset(CUDA_nppisu_LIBRARY CACHE)
+unset(CUDA_nppisu_static_LIBRARY CACHE)
+unset(CUDA_nppitc_LIBRARY CACHE)
+unset(CUDA_nppitc_static_LIBRARY CACHE)
+unset(CUDA_npps_LIBRARY CACHE)
+unset(CUDA_npps_static_LIBRARY CACHE)
+unset(CUDA_nvToolsExt_LIBRARY CACHE)
+unset(CUDA_nvgraph_LIBRARY CACHE)
+unset(CUDA_nvgraph_static_LIBRARY CACHE)
+unset(CUDA_nvjpeg_LIBRARY CACHE)
+unset(CUDA_nvjpeg_static_LIBRARY CACHE)
+unset(CUDA_nvml_LIBRARY CACHE)
+unset(CUDA_nvrtc_LIBRARY CACHE) \ No newline at end of file
diff --git a/libcuda/CMakeLists.txt b/libcuda/CMakeLists.txt
new file mode 100644
index 0000000..c4ba4d1
--- /dev/null
+++ b/libcuda/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Specify Flex and Bison target
+BISON_TARGET(cuobjdump_parser cuobjdump.y ${CMAKE_CURRENT_BINARY_DIR}/cuobjdump_parser.c
+ COMPILE_FLAGS "-t -d -v --report=all -p cuobjdump_ --file-prefix=${CMAKE_CURRENT_BINARY_DIR}/cuobjdump")
+FLEX_TARGET(cuobjdump_lexer cuobjdump.l ${CMAKE_CURRENT_BINARY_DIR}/cuobjdump_lexer.c
+ COMPILE_FLAGS "-B -P cuobjdump_")
+ADD_FLEX_BISON_DEPENDENCY(cuobjdump_lexer cuobjdump_parser)
+
+# Set generated source files to CXX
+set_source_files_properties(${BISON_cuobjdump_parser_OUTPUT_SOURCE}
+ ${FLEX_cuobjdump_lexer_OUTPUTS}
+ PROPERTIES LANGUAGE CXX)
+
+# Create libcuda.a with all source files
+add_library(cuda STATIC
+ cuda_runtime_api.cc
+ ${BISON_cuobjdump_parser_OUTPUT_SOURCE} ${FLEX_cuobjdump_lexer_OUTPUTS})
+
+ # Add current dir to include path
+# Also add flex/bison generated header files
+target_include_directories(cuda PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+
+# Add cuda include path for own reference
+target_include_directories(cuda PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
+
+# Add project build dir to include path
+target_include_directories(cuda PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/libopencl/CMakeLists.txt b/libopencl/CMakeLists.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/libopencl/CMakeLists.txt
diff --git a/short-tests-cmake.sh b/short-tests-cmake.sh
new file mode 100755
index 0000000..e414441
--- /dev/null
+++ b/short-tests-cmake.sh
@@ -0,0 +1,27 @@
+if [ ! -n "$CUDA_INSTALL_PATH" ]; then
+ echo "ERROR ** Install CUDA Toolkit and set CUDA_INSTALL_PATH.";
+ exit;
+fi
+
+if [ ! -n "$CONFIG" ]; then
+ echo "ERROR ** set the CONFIG env variable to one of those found in ./accel-sim-framework/util/job_launching/configs/define-standard-cfgs.yml";
+ exit;
+fi
+
+if [ ! -n "$GPUAPPS_ROOT" ]; then
+ echo "ERROR ** GPUAPPS_ROOT to a location where the apps have been compiled";
+ exit;
+fi
+
+git config --system --add safe.directory '*'
+
+export PATH=$CUDA_INSTALL_PATH/bin:$PATH
+
+cmake -B build
+cmake --build build -j
+cmake --install build
+source setup
+
+git clone https://github.com/accel-sim/accel-sim-framework.git
+./accel-sim-framework/util/job_launching/run_simulations.py -C $CONFIG -B rodinia_2.0-ft -N regress -l local
+./accel-sim-framework/util/job_launching/monitor_func_test.py -v -N regress -j procman
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..5849629
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,19 @@
+# gpgpusim_entrypoint objects
+add_library(gpgpusim_entrypoint OBJECT
+ abstract_hardware_model.cc
+ debug.cc
+ gpgpusim_entrypoint.cc
+ option_parser.cc
+ statwrapper.cc
+ stream_manager.cc
+ trace.cc)
+
+# Add current folder and CUDA include to include path
+target_include_directories(gpgpusim_entrypoint PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(gpgpusim_entrypoint PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
+
+# Add subdir
+add_subdirectory(accelwattch)
+add_subdirectory(cuda-sim)
+add_subdirectory(gpgpu-sim)
+add_subdirectory(intersim2) \ No newline at end of file
diff --git a/src/accelwattch/CMakeLists.txt b/src/accelwattch/CMakeLists.txt
new file mode 100644
index 0000000..cb7dd71
--- /dev/null
+++ b/src/accelwattch/CMakeLists.txt
@@ -0,0 +1,46 @@
+set(GPGPUSIM_ACCELWATTCH_NTHREADS "4" CACHE STRING "Accelwattch MCPAT thread count")
+add_library(accelwattch STATIC
+ cacti/Ucache.cc
+ XML_Parse.cc
+ cacti/arbiter.cc
+ cacti/area.cc
+ array.cc
+ cacti/bank.cc
+ cacti/basic_circuit.cc
+ basic_components.cc
+ cacti/cacti_interface.cc
+ cacti/component.cc
+ core.cc
+ cacti/crossbar.cc
+ cacti/decoder.cc
+ cacti/htree2.cc
+ interconnect.cc
+ cacti/io.cc
+ iocontrollers.cc
+ logic.cc
+ main.cc
+ cacti/mat.cc
+ memoryctrl.cc
+ noc.cc
+ cacti/nuca.cc
+ cacti/parameter.cc
+ processor.cc
+ cacti/router.cc
+ sharedcache.cc
+ cacti/subarray.cc
+ cacti/technology.cc
+ cacti/uca.cc
+ cacti/wire.cc
+ xmlParser.cc
+ gpgpu_sim_wrapper.cc)
+target_include_directories(accelwattch PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(accelwattch PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cacti)
+# Compile options
+target_compile_options(accelwattch PRIVATE "-Wno-unknown-pragmas")
+if($<CONFIG:Debug>)
+ target_compile_definitions(NTHREADS=1)
+else()
+ target_compile_options(accelwattch PRIVATE "-msse2;-mfpmath=sse")
+ target_compile_definitions(accelwattch PRIVATE -DNTHREADS=${GPGPUSIM_ACCELWATTCH_NTHREADS})
+endif()
+target_link_options(accelwattch PRIVATE "-lm;-lpthread;-lz") \ No newline at end of file
diff --git a/src/cuda-sim/CMakeLists.txt b/src/cuda-sim/CMakeLists.txt
new file mode 100644
index 0000000..3378b77
--- /dev/null
+++ b/src/cuda-sim/CMakeLists.txt
@@ -0,0 +1,78 @@
+# Specify Flex and Bison target
+BISON_TARGET(ptx_parser ptx.y ${CMAKE_CURRENT_BINARY_DIR}/ptx.tab.c
+ COMPILE_FLAGS "--name-prefix=ptx_ -v -d --file-prefix=${CMAKE_CURRENT_BINARY_DIR}/ptx")
+BISON_TARGET(ptxinfo_parser ptxinfo.y ${CMAKE_CURRENT_BINARY_DIR}/ptxinfo.tab.c
+ COMPILE_FLAGS "--name-prefix=ptxinfo_ -v -d --file-prefix=${CMAKE_CURRENT_BINARY_DIR}/ptxinfo")
+FLEX_TARGET(ptx_lexer ptx.l ${CMAKE_CURRENT_BINARY_DIR}/lex.ptx_.c)
+FLEX_TARGET(ptxinfo_lexer ptxinfo.l ${CMAKE_CURRENT_BINARY_DIR}/lex.ptxinfo_.c)
+ADD_FLEX_BISON_DEPENDENCY(ptx_lexer ptx_parser)
+ADD_FLEX_BISON_DEPENDENCY(ptxinfo_lexer ptxinfo_parser)
+
+# The flex and bison are using CXX, need to set their generated files to CXX so that
+# they can be compiled and linked
+set_source_files_properties(${BISON_ptx_parser_OUTPUT_SOURCE}
+ ${FLEX_ptx_lexer_OUTPUTS}
+ ${BISON_ptxinfo_parser_OUTPUT_SOURCE}
+ ${FLEX_ptxinfo_lexer_OUTPUTS}
+ PROPERTIES LANGUAGE CXX)
+# Create libptxsim.a
+add_library(ptxsim STATIC
+ cuda_device_printf.cc
+ cuda_device_runtime.cc
+ cuda-sim.cc
+ instructions.cc
+ memory.cc
+ ptx_ir.cc
+ ptx_loader.cc
+ ptx_parser.cc
+ ptx_sim.cc
+ ptx-stats.cc
+ decuda_pred_table/decuda_pred_table.cc
+ ${BISON_ptx_parser_OUTPUT_SOURCE} ${FLEX_ptx_lexer_OUTPUTS}
+ ${BISON_ptxinfo_parser_OUTPUT_SOURCE} ${FLEX_ptxinfo_lexer_OUTPUTS})
+
+# Define this for all source files, though we just need it for parser
+target_compile_definitions(ptxsim PRIVATE YYDEBUG)
+target_include_directories(ptxsim PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/decuda_pred_table)
+target_include_directories(ptxsim PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
+target_include_directories(ptxsim PRIVATE ${CMAKE_BINARY_DIR})
+
+# ptxsim need buildstring
+add_dependencies(ptxsim gen_build_string)
+
+# Create instructions.h using custom command
+add_custom_target(gen_instructions_h DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/instructions.h)
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ COMMAND chmod +w ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ COMMAND echo "// DO NOT EDIT THIS FILE! IT IS AUTOMATICALLY GENERATED BY THE MAKEFILE (see target for instructions.h)" > ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ COMMAND echo "#include \"ptx_ir.h\"" >> ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ COMMAND echo "#ifndef instructions_h_included" >> ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ COMMAND echo "#define instructions_h_included" >> ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/instructions.cc | grep "_impl(" | sed "s/{.*//" | sed "s/$/;/" >> ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ COMMAND echo "#endif" >> ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ # COMMAND chmod -w ${CMAKE_CURRENT_BINARY_DIR}/instructions.h
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/instructions.cc
+ VERBATIM
+)
+add_dependencies(ptxsim gen_instructions_h)
+
+# Create ptx_parser_decode.def using custom command
+add_custom_target(gen_ptx_parser_decode DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ptx_parser_decode.def)
+if(UNIX)
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ptx_parser_decode.def
+ COMMAND cat ${CMAKE_CURRENT_BINARY_DIR}/ptx.tab.h | grep "=" | sed "s/^[ ]\\+//" | sed -E "s/\\s+\\/\\*.+\\*\\///" | sed "s/[=,]//g" | sed "s/\\([_A-Z1-9]\\+\\)[ ]\\+\\([0-9]\\+\\)/\\1 \\1/" | sed "s/^/DEF(/" | sed "s/ /,\"/" | sed "s/$/\")/" | sed "/YYerror/d;/YYEOF/d;/YYEMPTY/d;/YYUNDEF/d;" > ${CMAKE_CURRENT_BINARY_DIR}/ptx_parser_decode.def
+ DEPENDS ${BISON_ptx_parser_OUTPUTS}
+ VERBATIM
+ )
+else()
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ptx_parser_decode.def
+ COMMAND cat ${CMAKE_CURRENT_BINARY_DIR}/ptx.tab.h | grep "=" | sed -E "s/^ +//" | sed -E "s/\\s+\\/\\*.+\\*\\///" | sed "s/[=,]//g" | sed -E "s/([_A-Z1-9]+).*/\\1 \\1/" | sed "s/^/DEF(/" | sed "s/ /,\"/" | sed "s/$/\")/" | sed "/YYerror/d;/YYEOF/d;/YYEMPTY/d;/YYUNDEF/d;" > ${CMAKE_CURRENT_BINARY_DIR}/ptx_parser_decode.def
+ DEPENDS ${BISON_ptx_parser_OUTPUTS}
+ VERBATIM
+ )
+endif()
+add_dependencies(ptxsim gen_ptx_parser_decode)
diff --git a/src/gpgpu-sim/CMakeLists.txt b/src/gpgpu-sim/CMakeLists.txt
new file mode 100644
index 0000000..04f1973
--- /dev/null
+++ b/src/gpgpu-sim/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Exclude power_interface.cc if no power model
+list(APPEND gpgpusim_SRC addrdec.cc
+ dram.cc
+ dram_sched.cc
+ gpu-cache.cc
+ gpu-misc.cc
+ gpu-sim.cc
+ hashing.cc
+ histogram.cc
+ icnt_wrapper.cc
+ l2cache.cc
+ local_interconnect.cc
+ mem_fetch.cc
+ mem_latency_stat.cc
+ power_interface.cc
+ power_stat.cc
+ scoreboard.cc
+ shader.cc
+ stack.cc
+ stat-tool.cc
+ traffic_breakdown.cc
+ visualizer.cc)
+if(NOT GPGPUSIM_USE_POWER_MODEL)
+ list(REMOVE_ITEM ${gpgpusim_SRC} power_interface.cc)
+endif()
+
+# Create libgpgpusim.a
+add_library(gpgpusim STATIC ${gpgpusim_SRC})
+target_include_directories(gpgpusim PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(gpgpusim PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
+
+if(GPGPUSIM_USE_POWER_MODEL)
+target_compile_definitions(gpgpusim PRIVATE GPGPUSIM_POWER_MODEL)
+target_include_directories(gpgpusim PRIVATE ${GPGPUSIM_POWER_MODEL})
+endif()
+
diff --git a/src/intersim2/CMakeLists.txt b/src/intersim2/CMakeLists.txt
new file mode 100644
index 0000000..c3da1b1
--- /dev/null
+++ b/src/intersim2/CMakeLists.txt
@@ -0,0 +1,106 @@
+option(GPGPUSIM_INTERSIM_STANDALONE "Whether to also build intersim in standalone mode" OFF)
+
+# Specify Flex and Bison target
+BISON_TARGET(intersim_config_parser config.y ${CMAKE_CURRENT_BINARY_DIR}/y.tab.c
+ COMPILE_FLAGS "-y -d --file-prefix=${CMAKE_CURRENT_BINARY_DIR}/y")
+FLEX_TARGET(intersim_config_lexer config.l ${CMAKE_CURRENT_BINARY_DIR}/lex.yy.c)
+ADD_FLEX_BISON_DEPENDENCY(intersim_config_lexer intersim_config_parser)
+
+# Set generated source files to CXX
+set_source_files_properties(${BISON_intersim_config_parser_OUTPUT_SOURCE}
+ ${FLEX_intersim_config_lexer_OUTPUTS}
+ PROPERTIES LANGUAGE CXX)
+
+# Create booksim or libintersim.a
+# Shared include path
+list(APPEND intersim_INC ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/allocators
+ ${CMAKE_CURRENT_SOURCE_DIR}/arbiters
+ ${CMAKE_CURRENT_SOURCE_DIR}/networks
+ ${CMAKE_CURRENT_SOURCE_DIR}/power
+ ${CMAKE_CURRENT_SOURCE_DIR}/routers
+ ${PROJECT_SOURCE_DIR}/src)
+
+# Shared source files
+list(APPEND intersim_SRC
+ ${BISON_intersim_config_parser_OUTPUT_SOURCE}
+ ${FLEX_intersim_config_lexer_OUTPUTS}
+ allocators/allocator.cpp
+ allocators/islip.cpp
+ allocators/loa.cpp
+ allocators/maxsize.cpp
+ allocators/pim.cpp
+ allocators/selalloc.cpp
+ allocators/separable.cpp
+ allocators/separable_input_first.cpp
+ allocators/separable_output_first.cpp
+ allocators/wavefront.cpp
+ arbiters/arbiter.cpp
+ arbiters/matrix_arb.cpp
+ arbiters/prio_arb.cpp
+ arbiters/roundrobin_arb.cpp
+ arbiters/tree_arb.cpp
+ batchtrafficmanager.cpp
+ booksim_config.cpp
+ buffer.cpp
+ buffer_state.cpp
+ config_utils.cpp
+ credit.cpp
+ flitchannel.cpp
+ flit.cpp
+ gputrafficmanager.cpp
+ injection.cpp
+ interconnect_interface.cpp
+ intersim_config.cpp
+ main.cpp
+ misc_utils.cpp
+ module.cpp
+ networks/anynet.cpp
+ networks/cmesh.cpp
+ networks/dragonfly.cpp
+ networks/fattree.cpp
+ networks/flatfly_onchip.cpp
+ networks/fly.cpp
+ networks/kncube.cpp
+ networks/network.cpp
+ networks/qtree.cpp
+ networks/tree4.cpp
+ outputset.cpp
+ packet_reply_info.cpp
+ power/buffer_monitor.cpp
+ power/power_module.cpp
+ power/switch_monitor.cpp
+ rng_double_wrapper.cpp
+ rng_wrapper.cpp
+ routefunc.cpp
+ routers/chaos_router.cpp
+ routers/event_router.cpp
+ routers/iq_router.cpp
+ routers/router.cpp
+ stats.cpp
+ traffic.cpp
+ trafficmanager.cpp
+ vc.cpp)
+
+# If standalone, also build for it
+if(GPGPUSIM_INTERSIM_STANDALONE)
+ list(REMOVE_ITEM ${intersim_SRC} interconnect_interface.cpp)
+ add_executable(booksim ${intersim_SRC})
+ target_include_directories(booksim PUBLIC
+ ${intersim_INC})
+ target_include_directories(booksim PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+ target_include_directories(booksim PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
+ # Remove globally set TRACING_ON flag
+ target_compile_options(booksim PRIVATE -UTRACING_ON)
+endif()
+
+# Specify sources for libintersim.a
+add_library(intersim STATIC ${intersim_SRC})
+target_include_directories(intersim PUBLIC
+ ${intersim_INC}
+ ${PROJECT_SOURCE_DIR}/src/gpgpu-sim)
+target_include_directories(intersim PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
+target_include_directories(intersim PUBLIC ${CUDAToolkit_INCLUDE_DIRS})
+target_compile_definitions(intersim PRIVATE CREATE_LIBRARY)
+# Remove globally set TRACING_ON flag
+target_compile_options(intersim PRIVATE -UTRACING_ON)
diff --git a/src/intersim2/Makefile b/src/intersim2/Makefile
index dad436a..a7485e2 100644
--- a/src/intersim2/Makefile
+++ b/src/intersim2/Makefile
@@ -28,7 +28,7 @@
# Makefile
#
CXX = g++
-CC = gcc
+CC = g++
CREATE_LIBRARY ?= 0
INTERFACE = interconnect_interface.cpp
DEBUG ?= 0
diff --git a/src/intersim2/config_utils.cpp b/src/intersim2/config_utils.cpp
index fad5fce..a896a93 100644
--- a/src/intersim2/config_utils.cpp
+++ b/src/intersim2/config_utils.cpp
@@ -199,27 +199,27 @@ Configuration * Configuration::GetTheConfig()
//============================================================
-extern "C" void config_error( char const * msg, int lineno )
+void config_error( char * msg, int lineno )
{
Configuration::GetTheConfig( )->ParseError( msg, lineno );
}
-extern "C" void config_assign_string( char const * field, char const * value )
+ void config_assign_string( char const * field, char const * value )
{
Configuration::GetTheConfig()->Assign(field, value);
}
-extern "C" void config_assign_int( char const * field, int value )
+void config_assign_int( char const * field, int value )
{
Configuration::GetTheConfig()->Assign(field, value);
}
-extern "C" void config_assign_float( char const * field, double value )
+void config_assign_float( char const * field, double value )
{
Configuration::GetTheConfig()->Assign(field, value);
}
-extern "C" int config_input(char * line, int max_size)
+int config_input(char * line, int max_size)
{
return Configuration::GetTheConfig()->Input(line, max_size);
}
diff --git a/src/intersim2/config_utils.hpp b/src/intersim2/config_utils.hpp
index de3343b..1d960b6 100644
--- a/src/intersim2/config_utils.hpp
+++ b/src/intersim2/config_utils.hpp
@@ -35,7 +35,7 @@
#include<map>
#include<vector>
-extern "C" int yyparse();
+int yyparse();
class Configuration {
static Configuration * theConfig;
diff --git a/src/intersim2/interconnect_interface.cpp b/src/intersim2/interconnect_interface.cpp
index 1e1a2d7..438852e 100644
--- a/src/intersim2/interconnect_interface.cpp
+++ b/src/intersim2/interconnect_interface.cpp
@@ -200,7 +200,7 @@ void InterconnectInterface::Push(unsigned input_deviceID, unsigned output_device
void* InterconnectInterface::Pop(unsigned deviceID)
{
int icntID = _node_map[deviceID];
-#if DEBUG
+#if 0
cout<<"Call interconnect POP " << output<<endl;
#endif
diff --git a/version.in b/version.in
new file mode 100644
index 0000000..2935c6f
--- /dev/null
+++ b/version.in
@@ -0,0 +1 @@
+const char *g_gpgpusim_build_string="@GPGPUSIM_BUILD_STRING@"; \ No newline at end of file