summaryrefslogtreecommitdiff
path: root/gpgpusim_check.cmake
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 /gpgpusim_check.cmake
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]>
Diffstat (limited to 'gpgpusim_check.cmake')
-rw-r--r--gpgpusim_check.cmake136
1 files changed, 136 insertions, 0 deletions
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