summaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
authorTor Aamodt <[email protected]>2025-02-10 17:35:31 -0800
committerGitHub <[email protected]>2025-02-10 17:35:31 -0800
commit0e39753a623978eb37bf044b21fde1a5909bff03 (patch)
tree13416ab3a165dde580fe847b06bde7c966482088 /src/cuda-sim
parent6b244a5d3be7811f16c312905c1c7fee137ac7a4 (diff)
parent48af0c94ca6d7b05f800f535b3de4cefafcfa655 (diff)
Merge pull request #313 from accel-sim/dev
Purdue Updates Merging
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/CMakeLists.txt78
-rw-r--r--src/cuda-sim/Makefile12
-rw-r--r--src/cuda-sim/cuda-sim.cc309
-rw-r--r--src/cuda-sim/cuda_device_runtime.cc4
-rw-r--r--src/cuda-sim/instructions.cc61
-rw-r--r--src/cuda-sim/memory.cc8
-rw-r--r--src/cuda-sim/opcodes.def1
-rw-r--r--src/cuda-sim/ptx.l13
-rw-r--r--src/cuda-sim/ptx.y8
-rw-r--r--src/cuda-sim/ptx_ir.cc48
-rw-r--r--src/cuda-sim/ptx_ir.h7
-rw-r--r--src/cuda-sim/ptx_loader.cc6
-rw-r--r--src/cuda-sim/ptx_parser.cc6
-rw-r--r--src/cuda-sim/ptx_sim.cc3
-rw-r--r--src/cuda-sim/ptx_sim.h3
15 files changed, 391 insertions, 176 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)
diff --git a/src/cuda-sim/Makefile b/src/cuda-sim/Makefile
index 85d1c8c..541cf8f 100644
--- a/src/cuda-sim/Makefile
+++ b/src/cuda-sim/Makefile
@@ -91,16 +91,16 @@ $(OUTPUT_DIR)/lex.ptxinfo_.o: $(OUTPUT_DIR)/lex.ptxinfo_.c $(OUTPUT_DIR)/ptxinfo
$(CPP) -c $(CXX_OPT) $(OUTPUT_DIR)/lex.ptxinfo_.c -o $(OUTPUT_DIR)/lex.ptxinfo_.o
$(OUTPUT_DIR)/ptx.tab.c: ptx.y
- bison --name-prefix=ptx_ -v -d ptx.y --file-prefix=$(OUTPUT_DIR)/ptx
+ bison --name-prefix=ptx_ -v -d ptx.y --file-prefix=$(OUTPUT_DIR)/ptx 2> /dev/null
$(OUTPUT_DIR)/ptxinfo.tab.c: ptxinfo.y
- bison --name-prefix=ptxinfo_ -v -d ptxinfo.y --file-prefix=$(OUTPUT_DIR)/ptxinfo
+ bison --name-prefix=ptxinfo_ -v -d ptxinfo.y --file-prefix=$(OUTPUT_DIR)/ptxinfo 2> /dev/null
$(OUTPUT_DIR)/lex.ptx_.c: ptx.l
- flex --outfile=$(OUTPUT_DIR)/lex.ptx_.c ptx.l
+ flex --outfile=$(OUTPUT_DIR)/lex.ptx_.c ptx.l 2> /dev/null
$(OUTPUT_DIR)/lex.ptxinfo_.c: ptxinfo.l
- flex --outfile=$(OUTPUT_DIR)/lex.ptxinfo_.c ptxinfo.l
+ flex --outfile=$(OUTPUT_DIR)/lex.ptxinfo_.c ptxinfo.l 2> /dev/null
clean:
rm -f *~ *.o *.gcda *.gcno *.gcov libgpgpu_ptx_sim.a \
@@ -129,9 +129,9 @@ $(OUTPUT_DIR)/instructions.h: instructions.cc
$(OUTPUT_DIR)/ptx_parser_decode.def: $(OUTPUT_DIR)/ptx.tab.c
ifeq ($(shell uname),Linux)
- cat $(OUTPUT_DIR)/ptx.tab.h | grep "=" | sed 's/^[ ]\+//' | sed 's/[=,]//g' | sed 's/\([_A-Z1-9]\+\)[ ]\+\([0-9]\+\)/\1 \1/' | sed 's/^/DEF(/' | sed 's/ /,"/' | sed 's/$$/")/' > $(OUTPUT_DIR)/ptx_parser_decode.def
+ cat $(OUTPUT_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;'> $(OUTPUT_DIR)/ptx_parser_decode.def
else
- cat $(OUTPUT_DIR)/ptx.tab.h | grep "=" | sed -E 's/^ +//' | sed 's/[=,]//g' | sed -E 's/([_A-Z1-9]+).*/\1 \1/' | sed 's/^/DEF(/' | sed 's/ /,"/' | sed 's/$$/")/' > $(OUTPUT_DIR)/ptx_parser_decode.def
+ cat $(OUTPUT_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;' > $(OUTPUT_DIR)/ptx_parser_decode.def
endif
$(OUTPUT_DIR)/instructions.o: $(OUTPUT_DIR)/instructions.h $(OUTPUT_DIR)/ptx.tab.c
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index f9e5db3..2fd90c0 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -1,17 +1,19 @@
// Copyright (c) 2009-2021, Tor M. Aamodt, Ali Bakhoda, Wilson W.L. Fung,
-// George L. Yuan, Jimmy Kwa, Vijay Kandiah, Nikos Hardavellas
-// The University of British Columbia, Northwestern University
-// All rights reserved.
+// George L. Yuan, Jimmy Kwa, Vijay Kandiah, Nikos Hardavellas,
+// Mahmoud Khairy, Junrui Pan, Timothy G. Rogers
+// The University of British Columbia, Northwestern University, Purdue
+// University All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
-// 1. Redistributions of source code must retain the above copyright notice, this
+// 1. Redistributions of source code must retain the above copyright notice,
+// this
// list of conditions and the following disclaimer;
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution;
-// 3. Neither the names of The University of British Columbia, Northwestern
+// 3. Neither the names of The University of British Columbia, Northwestern
// University nor the names of their contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
@@ -544,7 +546,7 @@ void gpgpu_t::gpu_memset(size_t dst_start_addr, int c, size_t count) {
void cuda_sim::ptx_print_insn(address_type pc, FILE *fp) {
std::map<unsigned, function_info *>::iterator f = g_pc_to_finfo.find(pc);
if (f == g_pc_to_finfo.end()) {
- fprintf(fp, "<no instruction at address 0x%x>", pc);
+ fprintf(fp, "<no instruction at address 0x%llx>", pc);
return;
}
function_info *finfo = f->second;
@@ -558,7 +560,7 @@ std::string cuda_sim::ptx_get_insn_str(address_type pc) {
#define STR_SIZE 255
char buff[STR_SIZE];
buff[STR_SIZE - 1] = '\0';
- snprintf(buff, STR_SIZE, "<no instruction at address 0x%x>", pc);
+ snprintf(buff, STR_SIZE, "<no instruction at address 0x%llx>", pc);
return std::string(buff);
}
function_info *finfo = f->second;
@@ -590,118 +592,118 @@ void ptx_instruction::set_fp_or_int_archop() {
}
}
-void ptx_instruction::set_mul_div_or_other_archop(){
- sp_op=OTHER_OP;
- if((m_opcode != MEMBAR_OP) && (m_opcode != SSY_OP) && (m_opcode != BRA_OP) && (m_opcode != BAR_OP) && (m_opcode != EXIT_OP) && (m_opcode != NOP_OP) && (m_opcode != RETP_OP) && (m_opcode != RET_OP) && (m_opcode != CALLP_OP) && (m_opcode != CALL_OP)){
- if(get_type() == F64_TYPE || get_type() == FF64_TYPE){
- switch(get_opcode()){
- case MUL_OP:
- case MAD_OP:
- case FMA_OP:
- sp_op=DP_MUL_OP;
- break;
- case DIV_OP:
- case REM_OP:
- sp_op=DP_DIV_OP;
- break;
- case RCP_OP:
- sp_op=DP_DIV_OP;
- break;
- case LG2_OP:
- sp_op=FP_LG_OP;
- break;
- case RSQRT_OP:
- case SQRT_OP:
- sp_op=FP_SQRT_OP;
- break;
- case SIN_OP:
- case COS_OP:
- sp_op=FP_SIN_OP;
- break;
- case EX2_OP:
- sp_op=FP_EXP_OP;
- break;
- case MMA_OP:
- sp_op=TENSOR__OP;
- break;
- case TEX_OP:
- sp_op=TEX__OP;
- break;
- default:
- if((op==DP_OP) || (op==ALU_OP))
- sp_op=DP___OP;
- break;
- }
+void ptx_instruction::set_mul_div_or_other_archop() {
+ sp_op = OTHER_OP;
+ if ((m_opcode != MEMBAR_OP) && (m_opcode != SSY_OP) && (m_opcode != BRA_OP) &&
+ (m_opcode != BAR_OP) && (m_opcode != EXIT_OP) && (m_opcode != NOP_OP) &&
+ (m_opcode != RETP_OP) && (m_opcode != RET_OP) && (m_opcode != CALLP_OP) &&
+ (m_opcode != CALL_OP)) {
+ if (get_type() == F64_TYPE || get_type() == FF64_TYPE) {
+ switch (get_opcode()) {
+ case MUL_OP:
+ case MAD_OP:
+ case FMA_OP:
+ sp_op = DP_MUL_OP;
+ break;
+ case DIV_OP:
+ case REM_OP:
+ sp_op = DP_DIV_OP;
+ break;
+ case RCP_OP:
+ sp_op = DP_DIV_OP;
+ break;
+ case LG2_OP:
+ sp_op = FP_LG_OP;
+ break;
+ case RSQRT_OP:
+ case SQRT_OP:
+ sp_op = FP_SQRT_OP;
+ break;
+ case SIN_OP:
+ case COS_OP:
+ sp_op = FP_SIN_OP;
+ break;
+ case EX2_OP:
+ sp_op = FP_EXP_OP;
+ break;
+ case MMA_OP:
+ sp_op = TENSOR__OP;
+ break;
+ case TEX_OP:
+ sp_op = TEX__OP;
+ break;
+ default:
+ if ((op == DP_OP) || (op == ALU_OP)) sp_op = DP___OP;
+ break;
}
- else if(get_type()==F16_TYPE || get_type()==F32_TYPE){
- switch(get_opcode()){
- case MUL_OP:
- case MAD_OP:
- case FMA_OP:
- sp_op=FP_MUL_OP;
- break;
- case DIV_OP:
- case REM_OP:
- sp_op=FP_DIV_OP;
- break;
- case RCP_OP:
- sp_op=FP_DIV_OP;
- break;
- case LG2_OP:
- sp_op=FP_LG_OP;
- break;
- case RSQRT_OP:
- case SQRT_OP:
- sp_op=FP_SQRT_OP;
- break;
- case SIN_OP:
- case COS_OP:
- sp_op=FP_SIN_OP;
- break;
- case EX2_OP:
- sp_op=FP_EXP_OP;
- break;
- case MMA_OP:
- sp_op=TENSOR__OP;
- break;
- case TEX_OP:
- sp_op=TEX__OP;
- break;
- default:
- if((op==SP_OP) || (op==ALU_OP))
- sp_op=FP__OP;
- break;
- }
- }else {
- switch(get_opcode()){
- case MUL24_OP:
- case MAD24_OP:
- sp_op=INT_MUL24_OP;
- break;
- case MUL_OP:
- case MAD_OP:
- case FMA_OP:
- if(get_type()==U32_TYPE || get_type()==S32_TYPE || get_type()==B32_TYPE)
- sp_op=INT_MUL32_OP;
- else
- sp_op=INT_MUL_OP;
- break;
- case DIV_OP:
- case REM_OP:
- sp_op=INT_DIV_OP;
- break;
- case MMA_OP:
- sp_op=TENSOR__OP;
- break;
- case TEX_OP:
- sp_op=TEX__OP;
- break;
- default:
- if((op==INTP_OP) || (op==ALU_OP))
- sp_op=INT__OP;
- break;
- }
+ } else if (get_type() == F16_TYPE || get_type() == F32_TYPE) {
+ switch (get_opcode()) {
+ case MUL_OP:
+ case MAD_OP:
+ case FMA_OP:
+ sp_op = FP_MUL_OP;
+ break;
+ case DIV_OP:
+ case REM_OP:
+ sp_op = FP_DIV_OP;
+ break;
+ case RCP_OP:
+ sp_op = FP_DIV_OP;
+ break;
+ case LG2_OP:
+ sp_op = FP_LG_OP;
+ break;
+ case RSQRT_OP:
+ case SQRT_OP:
+ sp_op = FP_SQRT_OP;
+ break;
+ case SIN_OP:
+ case COS_OP:
+ sp_op = FP_SIN_OP;
+ break;
+ case EX2_OP:
+ sp_op = FP_EXP_OP;
+ break;
+ case MMA_OP:
+ sp_op = TENSOR__OP;
+ break;
+ case TEX_OP:
+ sp_op = TEX__OP;
+ break;
+ default:
+ if ((op == SP_OP) || (op == ALU_OP)) sp_op = FP__OP;
+ break;
+ }
+ } else {
+ switch (get_opcode()) {
+ case MUL24_OP:
+ case MAD24_OP:
+ sp_op = INT_MUL24_OP;
+ break;
+ case MUL_OP:
+ case MAD_OP:
+ case FMA_OP:
+ if (get_type() == U32_TYPE || get_type() == S32_TYPE ||
+ get_type() == B32_TYPE)
+ sp_op = INT_MUL32_OP;
+ else
+ sp_op = INT_MUL_OP;
+ break;
+ case DIV_OP:
+ case REM_OP:
+ sp_op = INT_DIV_OP;
+ break;
+ case MMA_OP:
+ sp_op = TENSOR__OP;
+ break;
+ case TEX_OP:
+ sp_op = TEX__OP;
+ break;
+ default:
+ if ((op == INTP_OP) || (op == ALU_OP)) sp_op = INT__OP;
+ break;
}
+ }
}
}
@@ -959,14 +961,16 @@ void ptx_instruction::set_opcode_and_latency() {
break;
}
break;
- case MUL24_OP: //MUL24 is performed on mul32 units (with additional instructions for bitmasking) on devices with compute capability >1.x
- latency = int_latency[2]+1;
- initiation_interval = int_init[2]+1;
+ case MUL24_OP: // MUL24 is performed on mul32 units (with additional
+ // instructions for bitmasking) on devices with compute
+ // capability >1.x
+ latency = int_latency[2] + 1;
+ initiation_interval = int_init[2] + 1;
op = INTP_OP;
break;
case MAD24_OP:
- latency = int_latency[3]+1;
- initiation_interval = int_init[3]+1;
+ latency = int_latency[3] + 1;
+ initiation_interval = int_init[3] + 1;
op = INTP_OP;
break;
case DIV_OP:
@@ -1301,7 +1305,12 @@ void function_info::add_param_name_type_size(unsigned index, std::string name,
void function_info::add_param_data(unsigned argn,
struct gpgpu_ptx_sim_arg *args) {
const void *data = args->m_start;
-
+ if (g_debug_execution >= 3) {
+ if (args->m_nbytes == 4)
+ printf("ADD_PARAM_DATA %d\n", *((uint32_t *)data));
+ else
+ printf("ADD_PARAM_DATA %p\n", *((void **)data));
+ }
bool scratchpad_memory_param =
false; // Is this parameter in CUDA shared memory or OpenCL local memory
@@ -1371,7 +1380,7 @@ void function_info::add_param_data(unsigned argn,
unsigned num_bits = 8 * args->m_nbytes;
printf(
"GPGPU-Sim PTX: deferred allocation of shared region for \"%s\" from "
- "0x%x to 0x%x (shared memory space)\n",
+ "0x%llx to 0x%llx (shared memory space)\n",
p->name().c_str(), m_symtab->get_shared_next(),
m_symtab->get_shared_next() + num_bits / 8);
fflush(stdout);
@@ -1502,7 +1511,7 @@ void function_info::list_param(FILE *fout) const {
std::string name = p.get_name();
symbol *param = m_symtab->lookup(name.c_str());
addr_t param_addr = param->get_address();
- fprintf(fout, "%s: %#08x\n", name.c_str(), param_addr);
+ fprintf(fout, "%s: %#08llx\n", name.c_str(), param_addr);
}
fflush(fout);
}
@@ -1530,9 +1539,13 @@ void function_info::ptx_jit_config(
std::string filename_c(filename + "_c");
snprintf(buff, 1024, "c++filt %s > %s", get_name().c_str(),
filename_c.c_str());
- assert(system(buff) != NULL);
+ assert(system(buff) != 0);
FILE *fp = fopen(filename_c.c_str(), "r");
- fgets(buff, 1024, fp);
+ char *ptr = fgets(buff, 1024, fp);
+ if (ptr == NULL) {
+ printf("can't read file %s \n", filename_c.c_str());
+ assert(0);
+ }
fclose(fp);
std::string fn(buff);
size_t pos1, pos2;
@@ -1738,6 +1751,17 @@ static unsigned get_tex_datasize(const ptx_instruction *pI,
ptx_thread_info *thread) {
const operand_info &src1 = pI->src1(); // the name of the texture
std::string texname = src1.name();
+ // If indirect access, use register's value as address
+ // to find the symbol
+ if (src1.is_reg()) {
+ const operand_info &dst = pI->dst();
+ ptx_reg_t src1_data =
+ thread->get_operand_value(src1, dst, pI->get_type(), thread, 1);
+ addr_t sym_addr = src1_data.u64;
+ symbol *texRef = thread->get_symbol_table()->lookup_by_addr(sym_addr);
+ assert(texRef != NULL);
+ texname = texRef->name();
+ }
/*
For programs with many streams, textures can be bound and unbound
@@ -1876,7 +1900,7 @@ void ptx_thread_info::ptx_exec_inst(warp_inst_t &inst, unsigned lane_id) {
dim3 tid = get_tid();
printf(
"%u [thd=%u][i=%u] : ctaid=(%u,%u,%u) tid=(%u,%u,%u) icount=%u "
- "[pc=%u] (%s:%u - %s) [0x%llx]\n",
+ "[pc=%llu] (%s:%u - %s) [0x%llx]\n",
m_gpu->gpgpu_ctx->func_sim->g_ptx_sim_num_insn, get_uid(), pI->uid(),
ctaid.x, ctaid.y, ctaid.z, tid.x, tid.y, tid.z, get_icount(), pc,
pI->source_file(), pI->source_line(), pI->get_source(),
@@ -2277,15 +2301,24 @@ void cuda_sim::gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src,
sym_name = g->second;
mem_region = global_space;
}
- if (g_globals.find(hostVar) != g_globals.end()) {
- found_sym = true;
- sym_name = hostVar;
- mem_region = global_space;
- }
- if (g_constants.find(hostVar) != g_constants.end()) {
- found_sym = true;
- sym_name = hostVar;
- mem_region = const_space;
+
+ // Weili: Only attempt to find symbol as it is a string
+ // if we could not find it in previously registered variable.
+ // This will avoid constructing std::string() from hostVar address
+ // where it is not a string as
+ // Use of a string naming a variable as the symbol parameter was deprecated in
+ // CUDA 4.1 and removed in CUDA 5.0.
+ if (!found_sym) {
+ if (g_globals.find(hostVar) != g_globals.end()) {
+ found_sym = true;
+ sym_name = hostVar;
+ mem_region = global_space;
+ }
+ if (g_constants.find(hostVar) != g_constants.end()) {
+ found_sym = true;
+ sym_name = hostVar;
+ mem_region = const_space;
+ }
}
if (!found_sym) {
@@ -2375,7 +2408,7 @@ void cuda_sim::read_sim_environment_variables() {
"%s\n",
dbg_pc);
fflush(stdout);
- sscanf(dbg_pc, "%d", &g_debug_pc);
+ sscanf(dbg_pc, "%llu", &g_debug_pc);
}
#if CUDART_VERSION > 1010
diff --git a/src/cuda-sim/cuda_device_runtime.cc b/src/cuda-sim/cuda_device_runtime.cc
index 4a99c1c..8ed90bc 100644
--- a/src/cuda-sim/cuda_device_runtime.cc
+++ b/src/cuda-sim/cuda_device_runtime.cc
@@ -36,7 +36,7 @@ void cuda_device_runtime::gpgpusim_cuda_getParameterBufferV2(
unsigned n_args = target_func->num_args();
assert(n_args == 4);
- function_info *child_kernel_entry;
+ function_info *child_kernel_entry = NULL;
struct dim3 grid_dim, block_dim;
unsigned int shared_mem;
@@ -258,7 +258,7 @@ void cuda_device_runtime::gpgpusim_cuda_streamCreateWithFlags(
assert(n_args == 2);
size_t generic_pStream_addr;
- addr_t pStream_addr;
+ addr_t pStream_addr = 0;
unsigned int flags;
for (unsigned arg = 0; arg < n_args; arg++) {
const operand_info &actual_param_op =
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index 44afbe5..843bf0b 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -1,17 +1,19 @@
// Copyright (c) 2009-2021, Tor M. Aamodt, Wilson W.L. Fung, Ali Bakhoda,
-// Jimmy Kwa, George L. Yuan, Vijay Kandiah, Nikos Hardavellas
-// The University of British Columbia, Northwestern University
-// All rights reserved.
+// Jimmy Kwa, George L. Yuan, Vijay Kandiah, Nikos Hardavellas,
+// Mahmoud Khairy, Junrui Pan, Timothy G. Rogers
+// The University of British Columbia, Northwestern University, Purdue
+// University All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
-// 1. Redistributions of source code must retain the above copyright notice, this
+// 1. Redistributions of source code must retain the above copyright notice,
+// this
// list of conditions and the following disclaimer;
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution;
-// 3. Neither the names of The University of British Columbia, Northwestern
+// 3. Neither the names of The University of British Columbia, Northwestern
// University nor the names of their contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
@@ -1947,7 +1949,7 @@ void mma_impl(const ptx_instruction *pI, core_t *core, warp_inst_t inst) {
hex_val = (v[k / 2].s64 & 0xffff);
else
hex_val = ((v[k / 2].s64 & 0xffff0000) >> 16);
- nw_v[k].f16 = *((half *)&hex_val);
+ nw_v[k].f16 = *(reinterpret_cast<half *>(hex_val));
}
}
if (!((operand_num == 3) && (type2 == F32_TYPE))) {
@@ -3979,7 +3981,7 @@ void mad_def(const ptx_instruction *pI, ptx_thread_info *thread,
fesetround(FE_TOWARDZERO);
break;
default:
- //assert(0);
+ // assert(0);
break;
}
d.f32 = a.f32 * b.f32 + c.f32;
@@ -4325,7 +4327,7 @@ void mul_impl(const ptx_instruction *pI, ptx_thread_info *thread) {
case S64_TYPE:
t.s64 = a.s64 * b.s64;
assert(!pI->is_wide());
- //assert(!pI->is_hi());
+ // assert(!pI->is_hi());
d.s64 = t.s64;
break;
case U16_TYPE:
@@ -5439,6 +5441,38 @@ void shfl_impl(const ptx_instruction *pI, core_t *core, warp_inst_t inst) {
}
}
+void shf_impl(const ptx_instruction *pI, ptx_thread_info *thread) {
+ ptx_reg_t a, b, c, d;
+ const operand_info &dst = pI->dst();
+ const operand_info &src1 = pI->src1();
+ const operand_info &src2 = pI->src2();
+ const operand_info &src3 = pI->src3();
+
+ // Only b32 is allowed
+ unsigned i_type = pI->get_type();
+ a = thread->get_operand_value(src1, dst, i_type, thread, 1);
+ b = thread->get_operand_value(src2, dst, i_type, thread, 1);
+ c = thread->get_operand_value(src3, dst, i_type, thread, 1);
+
+ if (i_type != B32_TYPE)
+ printf("Only the b32 data_type is allowed per the ISA\n");
+
+ unsigned clamp_mode = pI->clamp_mode();
+ unsigned n = c.u32 & 0x1f;
+ if (clamp_mode) {
+ if (c.u32 < 32)
+ n = c;
+ else
+ n = 32;
+ }
+ if (pI->left_mode())
+ d.u32 = (b.u32 << n) | (a.u32 >> (32 - n));
+ else
+ d.u32 = (b.u32 << (32 - n)) | (a.u32 >> n);
+
+ thread->set_operand_value(dst, d, i_type, thread, pI);
+}
+
void shl_impl(const ptx_instruction *pI, ptx_thread_info *thread) {
ptx_reg_t a, b, d;
const operand_info &dst = pI->dst();
@@ -6021,6 +6055,17 @@ void tex_impl(const ptx_instruction *pI, ptx_thread_info *thread) {
// to be fetched
std::string texname = src1.name();
+ // If indirect access, use register's value as address
+ // to find the symbol
+ if (src1.is_reg()) {
+ ptx_reg_t src1_data =
+ thread->get_operand_value(src1, dst, pI->get_type(), thread, 1);
+ addr_t sym_addr = src1_data.u64;
+ symbol *texRef = thread->get_symbol_table()->lookup_by_addr(sym_addr);
+ assert(texRef != NULL);
+ texname = texRef->name();
+ }
+
unsigned to_type = pI->get_type();
unsigned c_type = pI->get_type2();
fflush(stdout);
diff --git a/src/cuda-sim/memory.cc b/src/cuda-sim/memory.cc
index 1323837..036bada 100644
--- a/src/cuda-sim/memory.cc
+++ b/src/cuda-sim/memory.cc
@@ -109,11 +109,11 @@ void memory_space_impl<BSIZE>::read_single_block(mem_addr_t blk_idx,
if ((addr + length) > (blk_idx + 1) * BSIZE) {
printf(
"GPGPU-Sim PTX: ERROR * access to memory \'%s\' is unaligned : "
- "addr=0x%x, length=%zu\n",
+ "addr=0x%llx, length=%zu\n",
m_name.c_str(), addr, length);
printf(
- "GPGPU-Sim PTX: (addr+length)=0x%lx > 0x%x=(index+1)*BSIZE, "
- "index=0x%x, BSIZE=0x%x\n",
+ "GPGPU-Sim PTX: (addr+length)=0x%llx > 0x%llx=(index+1)*BSIZE, "
+ "index=0x%llx, BSIZE=0x%x\n",
(addr + length), (blk_idx + 1) * BSIZE, blk_idx, BSIZE);
throw 1;
}
@@ -169,7 +169,7 @@ void memory_space_impl<BSIZE>::print(const char *format, FILE *fout) const {
typename map_t::const_iterator i_page;
for (i_page = m_data.begin(); i_page != m_data.end(); ++i_page) {
- fprintf(fout, "%s %08x:", m_name.c_str(), i_page->first);
+ fprintf(fout, "%s %08llx:", m_name.c_str(), i_page->first);
i_page->second.print(format, fout);
}
}
diff --git a/src/cuda-sim/opcodes.def b/src/cuda-sim/opcodes.def
index f5bf156..83a23ea 100644
--- a/src/cuda-sim/opcodes.def
+++ b/src/cuda-sim/opcodes.def
@@ -103,6 +103,7 @@ OP_DEF(SELP_OP,selp_impl,"selp",1,1)
OP_DEF(SETP_OP,setp_impl,"setp",1,1)
OP_DEF(SET_OP,set_impl,"set",1,1)
OP_W_DEF(SHFL_OP,shfl_impl,"shfl",1,10)
+OP_DEF(SHF_OP,shf_impl,"shf",1,1)
OP_DEF(SHL_OP,shl_impl,"shl",1,1)
OP_DEF(SHR_OP,shr_impl,"shr",1,1)
OP_DEF(SIN_OP,sin_impl,"sin",1,4)
diff --git a/src/cuda-sim/ptx.l b/src/cuda-sim/ptx.l
index 7706f0b..0810ef6 100644
--- a/src/cuda-sim/ptx.l
+++ b/src/cuda-sim/ptx.l
@@ -1,6 +1,7 @@
/*
-Copyright (c) 2009-2021, Tor M. Aamodt, Vijay Kandiah, Nikos Hardavellas
-The University of British Columbia, Northwestern University
+Copyright (c) 2009-2021, Tor M. Aamodt, Vijay Kandiah, Nikos Hardavellas,
+Mahmoud Khairy, Junrui Pan, Timothy G. Rogers
+The University of British Columbia, Northwestern University, Purdue University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -133,6 +134,7 @@ selp TC; yylval->int_value = SELP_OP; return OPCODE;
setp TC; yylval->int_value = SETP_OP; return OPCODE;
set TC; yylval->int_value = SET_OP; return OPCODE;
shfl TC; yylval->int_value = SHFL_OP; return OPCODE;
+shf TC; yylval->int_value = SHF_OP; return OPCODE;
shl TC; yylval->int_value = SHL_OP; return OPCODE;
shr TC; yylval->int_value = SHR_OP; return OPCODE;
sin TC; yylval->int_value = SIN_OP; return OPCODE;
@@ -316,6 +318,9 @@ breakaddr TC; yylval->int_value = BREAKADDR_OP; return OPCODE;
\.sat TC; return SAT_OPTION;
+\.l TC; return LEFT_OPTION;
+\.r TC; return RIGHT_OPTION;
+
\.eq TC; return EQ_OPTION;
\.ne TC; return NE_OPTION;
\.lt TC; return LT_OPTION;
@@ -353,6 +358,8 @@ breakaddr TC; yylval->int_value = BREAKADDR_OP; return OPCODE;
\.arrive TC; return ARRIVE_OPTION;
\.red TC; return RED_OPTION;
+\.clamp TC; return CLAMP_OPTION;
+\.wrap TC; return WRAP_OPTION;
\.approx TC; return APPROX_OPTION;
\.full TC; return FULL_OPTION;
@@ -487,4 +494,4 @@ int ptx_error( yyscan_t yyscanner, ptx_recognizer* recognizer, const char *s )
fflush(stdout);
//exit(1);
return 0;
-} \ No newline at end of file
+}
diff --git a/src/cuda-sim/ptx.y b/src/cuda-sim/ptx.y
index b38f783..61183e8 100644
--- a/src/cuda-sim/ptx.y
+++ b/src/cuda-sim/ptx.y
@@ -220,6 +220,10 @@ class ptx_recognizer;
%token PRMT_RC16_MODE;
%token PRMT_ECL_MODE;
%token PRMT_ECR_MODE;
+%token WRAP_OPTION;
+%token CLAMP_OPTION;
+%token LEFT_OPTION;
+%token RIGHT_OPTION;
%type <int_value> function_decl_header
%type <ptr_value> function_decl
@@ -507,6 +511,10 @@ option: type_spec
| DOWN_OPTION { recognizer->add_option(DOWN_OPTION); }
| BFLY_OPTION { recognizer->add_option(BFLY_OPTION); }
| IDX_OPTION { recognizer->add_option(IDX_OPTION); }
+ | WRAP_OPTION { recognizer->add_option(WRAP_OPTION); }
+ | CLAMP_OPTION { recognizer->add_option(CLAMP_OPTION); }
+ | LEFT_OPTION { recognizer->add_option(LEFT_OPTION); }
+ | RIGHT_OPTION { recognizer->add_option(RIGHT_OPTION); }
;
atomic_operation_spec: ATOMIC_AND { recognizer->add_option(ATOMIC_AND); }
diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc
index 2edc1ed..4e500cc 100644
--- a/src/cuda-sim/ptx_ir.cc
+++ b/src/cuda-sim/ptx_ir.cc
@@ -1,17 +1,19 @@
// Copyright (c) 2009-2021, Tor M. Aamodt, Ali Bakhoda, Wilson W.L. Fung,
-// George L. Yuan, Vijay Kandiah, Nikos Hardavellas
-// The University of British Columbia, Northwestern University
-// All rights reserved.
+// George L. Yuan, Vijay Kandiah, Nikos Hardavellas,
+// Mahmoud Khairy, Junrui Pan, Timothy G. Rogers
+// The University of British Columbia, Northwestern University, Purdue
+// University All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
-// 1. Redistributions of source code must retain the above copyright notice, this
+// 1. Redistributions of source code must retain the above copyright notice,
+// this
// list of conditions and the following disclaimer;
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution;
-// 3. Neither the names of The University of British Columbia, Northwestern
+// 3. Neither the names of The University of British Columbia, Northwestern
// University nor the names of their contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
@@ -137,6 +139,22 @@ symbol *symbol_table::lookup(const char *identifier) {
return NULL;
}
+symbol *symbol_table::lookup_by_addr(addr_t addr) {
+ for (auto it = m_symbols.begin(); it != m_symbols.end(); ++it) {
+ symbol *sym = it->second;
+
+ // check if symbol has the addr to be found
+ if ((!sym->is_reg()) && (sym->has_valid_address()) &&
+ (sym->get_address() == addr)) {
+ return sym;
+ }
+ }
+ if (m_parent) {
+ return m_parent->lookup_by_addr(addr);
+ }
+ return NULL;
+}
+
symbol *symbol_table::add_variable(const char *identifier,
const type_info *type, unsigned size,
const char *filename, unsigned line) {
@@ -1225,6 +1243,8 @@ ptx_instruction::ptx_instruction(
m_rounding_mode = RN_OPTION;
m_compare_op = -1;
m_saturation_mode = 0;
+ m_clamp_mode = 0;
+ m_left_mode = 0;
m_geom_spec = 0;
m_vector_spec = 0;
m_atomic_spec = 0;
@@ -1291,6 +1311,18 @@ ptx_instruction::ptx_instruction(
case SAT_OPTION:
m_saturation_mode = 1;
break;
+ case WRAP_OPTION:
+ m_clamp_mode = 0;
+ break;
+ case CLAMP_OPTION:
+ m_clamp_mode = 1;
+ break;
+ case LEFT_OPTION:
+ m_left_mode = 1;
+ break;
+ case RIGHT_OPTION:
+ m_left_mode = 0;
+ break;
case RNI_OPTION:
case RZI_OPTION:
case RMI_OPTION:
@@ -1385,7 +1417,7 @@ ptx_instruction::ptx_instruction(
case CS_OPTION:
case LU_OPTION:
case CV_OPTION:
- case WB_OPTION:
+ case WB_OPTION:
case WT_OPTION:
m_cache_option = last_ptx_inst_option;
break;
@@ -1468,8 +1500,8 @@ std::string ptx_instruction::to_string() const {
char buf[STR_SIZE];
unsigned used_bytes = 0;
if (!is_label()) {
- used_bytes +=
- snprintf(buf + used_bytes, STR_SIZE - used_bytes, " PC=0x%03x ", m_PC);
+ used_bytes += snprintf(buf + used_bytes, STR_SIZE - used_bytes,
+ " PC=0x%03llx ", m_PC);
} else {
used_bytes +=
snprintf(buf + used_bytes, STR_SIZE - used_bytes, " ");
diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h
index 8251759..b08a692 100644
--- a/src/cuda-sim/ptx_ir.h
+++ b/src/cuda-sim/ptx_ir.h
@@ -205,6 +205,7 @@ class symbol {
const std::string &name() const { return m_name; }
const std::string &decl_location() const { return m_decl_location; }
const type_info *type() const { return m_type; }
+ bool has_valid_address() const { return m_address_valid; }
addr_t get_address() const {
assert(m_is_label ||
!m_type->get_key().is_reg()); // todo : other assertions
@@ -310,6 +311,7 @@ class symbol_table {
void set_ptx_version(float ver, unsigned ext);
void set_sm_target(const char *target, const char *ext, const char *ext2);
symbol *lookup(const char *identifier);
+ symbol *lookup_by_addr(addr_t addr);
std::string get_scope_name() const { return m_scope_name; }
symbol *add_variable(const char *identifier, const type_info *type,
unsigned size, const char *filename, unsigned line);
@@ -1085,6 +1087,8 @@ class ptx_instruction : public warp_inst_t {
unsigned cache_option() const { return m_cache_option; }
unsigned rounding_mode() const { return m_rounding_mode; }
unsigned saturation_mode() const { return m_saturation_mode; }
+ unsigned clamp_mode() const { return m_clamp_mode; }
+ unsigned left_mode() const { return m_left_mode; }
unsigned dimension() const { return m_geom_spec; }
unsigned barrier_op() const { return m_barrier_op; }
unsigned shfl_op() const { return m_shfl_op; }
@@ -1159,6 +1163,8 @@ class ptx_instruction : public warp_inst_t {
unsigned m_rounding_mode;
unsigned m_compare_op;
unsigned m_saturation_mode;
+ unsigned m_clamp_mode;
+ unsigned m_left_mode;
unsigned m_barrier_op;
unsigned m_shfl_op;
unsigned m_prmt_op;
@@ -1248,6 +1254,7 @@ class function_info {
const ptx_version &get_ptx_version() const {
return m_symtab->get_ptx_version();
}
+ virtual ~function_info() {}
unsigned get_sm_target() const { return m_symtab->get_sm_target(); }
bool is_extern() const { return m_extern; }
void set_name(const char *name) { m_name = name; }
diff --git a/src/cuda-sim/ptx_loader.cc b/src/cuda-sim/ptx_loader.cc
index 4e91763..df35498 100644
--- a/src/cuda-sim/ptx_loader.cc
+++ b/src/cuda-sim/ptx_loader.cc
@@ -95,7 +95,7 @@ void gpgpu_context::print_ptx_file(const char *p, unsigned source_num,
const ptx_instruction *pI = ptx_parser->ptx_instruction_lookup(filename, n);
char pc[64];
if (pI && pI->get_PC())
- snprintf(pc, 64, "%4u", pI->get_PC());
+ snprintf(pc, 64, "%4llu", pI->get_PC());
else
snprintf(pc, 64, " ");
printf(" _%u.ptx %4u (pc=%s): %s\n", source_num, n, pc, t);
@@ -240,7 +240,7 @@ void fix_duplicate_errors(char fname2[1024]) {
unsigned oldlinenum = 1;
unsigned linenum;
char *startptr = ptxdata;
- char *funcptr;
+ char *funcptr = NULL;
char *tempptr = ptxdata - 1;
char *lineptr = ptxdata - 1;
@@ -320,7 +320,7 @@ void fix_duplicate_errors(char fname2[1024]) {
// we need the application name here too.
char *get_app_binary_name() {
char exe_path[1025];
- char *self_exe_path;
+ char *self_exe_path = NULL;
#ifdef __APPLE__
// AMRUTH: get apple device and check the result.
printf("WARNING: not tested for Apple-mac devices \n");
diff --git a/src/cuda-sim/ptx_parser.cc b/src/cuda-sim/ptx_parser.cc
index 86a33c2..a80eeae 100644
--- a/src/cuda-sim/ptx_parser.cc
+++ b/src/cuda-sim/ptx_parser.cc
@@ -206,7 +206,7 @@ void ptx_recognizer::end_function() {
gpgpu_ptx_assemble(g_func_info->get_name(), g_func_info);
g_current_symbol_table = g_global_symbol_table;
- PTX_PARSE_DPRINTF("function %s, PC = %d\n", g_func_info->get_name().c_str(),
+ PTX_PARSE_DPRINTF("function %s, PC = %llu\n", g_func_info->get_name().c_str(),
g_func_info->get_start_PC());
}
@@ -486,7 +486,7 @@ void ptx_recognizer::add_identifier(const char *identifier, int array_dim,
case param_space_local:
printf(
"GPGPU-Sim PTX: allocating stack frame region for .param \"%s\" from "
- "0x%x to 0x%lx\n",
+ "0x%llx to 0x%llx\n",
identifier, g_current_symbol_table->get_local_next(),
g_current_symbol_table->get_local_next() + num_bits / 8);
fflush(stdout);
@@ -521,7 +521,7 @@ void ptx_recognizer::add_constptr(const char *identifier1,
unsigned addr = s2->get_address();
- printf("GPGPU-Sim PTX: moving \"%s\" from 0x%x to 0x%x (%s+%x)\n",
+ printf("GPGPU-Sim PTX: moving \"%s\" from 0x%llx to 0x%x (%s+%d)\n",
identifier1, s1->get_address(), addr + offset, identifier2, offset);
s1->set_address(addr + offset);
diff --git a/src/cuda-sim/ptx_sim.cc b/src/cuda-sim/ptx_sim.cc
index dc801f8..2a548ee 100644
--- a/src/cuda-sim/ptx_sim.cc
+++ b/src/cuda-sim/ptx_sim.cc
@@ -369,7 +369,8 @@ static void print_reg(FILE *fp, std::string name, ptx_reg_t value,
fprintf(fp, ".u64 %llu [0x%llx]\n", value.u64, value.u64);
break;
case F16_TYPE:
- fprintf(fp, ".f16 %f [0x%04x]\n", value.f16, (unsigned)value.u16);
+ fprintf(fp, ".f16 %f [0x%04x]\n", static_cast<float>(value.f16),
+ (unsigned)value.u16);
break;
case F32_TYPE:
fprintf(fp, ".f32 %.15lf [0x%08x]\n", value.f32, value.u32);
diff --git a/src/cuda-sim/ptx_sim.h b/src/cuda-sim/ptx_sim.h
index f0c26ef..8eec922 100644
--- a/src/cuda-sim/ptx_sim.h
+++ b/src/cuda-sim/ptx_sim.h
@@ -459,6 +459,9 @@ class ptx_thread_info {
// Jin: get corresponding kernel grid for CDP purpose
kernel_info_t &get_kernel() { return m_kernel; }
+ // Weili: access symbol_table
+ symbol_table *get_symbol_table() { return m_symbol_table; }
+
public:
addr_t m_last_effective_address;
bool m_branch_taken;