summaryrefslogtreecommitdiff
path: root/src
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 /src
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 'src')
-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
9 files changed, 293 insertions, 8 deletions
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