diff options
| author | WilliamMTK <[email protected]> | 2024-04-04 18:13:54 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-04-04 18:13:54 -0400 |
| commit | bc8061fd1e3c26be37e2cbb83ff9ca26e6f4dead (patch) | |
| tree | 8ed2e1e3b37a6add49dc18f73ce7ea17ff46ab06 /src/cuda-sim | |
| parent | 63893019e953269d1b0fb38e1fa8754992dd8d80 (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 'src/cuda-sim')
| -rw-r--r-- | src/cuda-sim/CMakeLists.txt | 78 |
1 files changed, 78 insertions, 0 deletions
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) |
