summaryrefslogtreecommitdiff
path: root/src/cuda-sim/cuda-sim.cc
diff options
context:
space:
mode:
authorMengchi Zhang <[email protected]>2019-07-16 10:36:42 -0400
committerGitHub <[email protected]>2019-07-16 10:36:42 -0400
commitbf198b13541a427cba9bef22799955aa08ab050a (patch)
tree4af15f4e22cb0c55450e26cb97110534148c8c60 /src/cuda-sim/cuda-sim.cc
parent89e913f7b28e342b9023a01105cb441cfafbee8b (diff)
parente1fa1a3cc7c509417064a8e4cdab71e3f7feb881 (diff)
Merge pull request #25 from echoedit/dev
Dev
Diffstat (limited to 'src/cuda-sim/cuda-sim.cc')
-rw-r--r--src/cuda-sim/cuda-sim.cc27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index 7ff869c..b9e6552 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -54,7 +54,6 @@ typedef void * yyscan_t;
#include "../../libcuda/gpgpu_context.h"
int g_debug_execution = 0;
-addr_t g_debug_pc = 0xBEEF1518;
// Output debug information to file options
@@ -216,8 +215,6 @@ void gpgpu_t::gpgpu_ptx_sim_unbindTexture(const struct textureReference* texref)
m_NameToTextureInfo.erase(texname);
}
-std::vector<ptx_instruction*> function_info::s_g_pc_to_insn;
-
#define MAX_INST_SIZE 8 /*bytes*/
void function_info::ptx_assemble()
@@ -238,14 +235,14 @@ void function_info::ptx_assemble()
addr_t PC = gpgpu_ctx->func_sim->g_assemble_code_next_pc; // globally unique address (across functions)
// start function on an aligned address
for( unsigned i=0; i < (PC%MAX_INST_SIZE); i++ )
- s_g_pc_to_insn.push_back((ptx_instruction*)NULL);
+ gpgpu_ctx->s_g_pc_to_insn.push_back((ptx_instruction*)NULL);
PC += PC%MAX_INST_SIZE;
m_start_PC = PC;
addr_t n=0; // offset in m_instr_mem
//Why s_g_pc_to_insn.size() is needed to reserve additional memory for insts? reserve is cumulative.
//s_g_pc_to_insn.reserve(s_g_pc_to_insn.size() + MAX_INST_SIZE*m_instructions.size());
- s_g_pc_to_insn.reserve(MAX_INST_SIZE*m_instructions.size());
+ gpgpu_ctx->s_g_pc_to_insn.reserve(MAX_INST_SIZE*m_instructions.size());
for ( i=m_instructions.begin(); i != m_instructions.end(); i++ ) {
ptx_instruction *pI = *i;
if ( pI->is_label() ) {
@@ -254,13 +251,13 @@ void function_info::ptx_assemble()
} else {
gpgpu_ctx->func_sim->g_pc_to_finfo[PC] = this;
m_instr_mem[n] = pI;
- s_g_pc_to_insn.push_back(pI);
- assert(pI == s_g_pc_to_insn[PC]);
+ gpgpu_ctx->s_g_pc_to_insn.push_back(pI);
+ assert(pI == gpgpu_ctx->s_g_pc_to_insn[PC]);
pI->set_m_instr_mem_index(n);
pI->set_PC(PC);
assert( pI->inst_size() <= MAX_INST_SIZE );
for( unsigned i=1; i < pI->inst_size(); i++ ) {
- s_g_pc_to_insn.push_back((ptx_instruction*)NULL);
+ gpgpu_ctx->s_g_pc_to_insn.push_back((ptx_instruction*)NULL);
m_instr_mem[n+i]=NULL;
}
n += pI->inst_size();
@@ -1739,9 +1736,9 @@ const struct gpgpu_ptx_sim_info* ptx_sim_kernel_info(const function_info *kernel
return kernel->get_kernel_info();
}
-const warp_inst_t *ptx_fetch_inst( address_type pc )
+const warp_inst_t *gpgpu_context::ptx_fetch_inst( address_type pc )
{
- return function_info::pc_to_instruction(pc);
+ return pc_to_instruction(pc);
}
unsigned ptx_sim_init_thread( kernel_info_t &kernel,
@@ -1825,7 +1822,7 @@ unsigned ptx_sim_init_thread( kernel_info_t &kernel,
snprintf(buf,512,"sstarr_%u", sid);
sstarr_mem = new memory_space_impl<16*1024>(buf,4);
sstarr_memory_lookup[sm_idx] = sstarr_mem;
- cta_info = new ptx_cta_info(sm_idx);
+ cta_info = new ptx_cta_info(sm_idx, gpu->gpgpu_ctx);
ptx_cta_lookup[sm_idx] = cta_info;
} else {
if ( g_debug_execution >= 1 ) {
@@ -1995,8 +1992,8 @@ void cuda_sim::gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src,
const char *mem_name = NULL;
memory_space *mem = NULL;
- std::map<std::string,symbol_table*>::iterator st = g_sym_name_to_symbol_table.find(sym_name.c_str());
- assert( st != g_sym_name_to_symbol_table.end() );
+ std::map<std::string,symbol_table*>::iterator st = gpgpu_ctx->ptx_parser->g_sym_name_to_symbol_table.find(sym_name.c_str());
+ assert( st != gpgpu_ctx->ptx_parser->g_sym_name_to_symbol_table.end() );
symbol_table *symtab = st->second;
symbol *sym = symtab->lookup(sym_name.c_str());
@@ -2367,11 +2364,11 @@ void functionalCoreSim::executeWarp(unsigned i, bool &allAtBarrier, bool & someO
if(!m_warpAtBarrier[i]&& m_liveThreadCount[i]>0) allAtBarrier = false;
}
-unsigned translate_pc_to_ptxlineno(unsigned pc)
+unsigned gpgpu_context::translate_pc_to_ptxlineno(unsigned pc)
{
// this function assumes that the kernel fits inside a single PTX file
// function_info *pFunc = g_func_info; // assume that the current kernel is the one in query
- const ptx_instruction *pInsn = function_info::pc_to_instruction(pc);
+ const ptx_instruction *pInsn = pc_to_instruction(pc);
unsigned ptx_line_number = pInsn->source_line();
return ptx_line_number;