diff options
| author | Tor Aamodt <[email protected]> | 2010-11-30 02:15:16 -0800 |
|---|---|---|
| committer | Tor Aamodt <[email protected]> | 2010-11-30 02:15:16 -0800 |
| commit | 52a638e84693fff528defbcbd24ecb58216baaba (patch) | |
| tree | 34449df36f63267119cd048508810a101618fd39 /src/cuda-sim | |
| parent | 7a47f9cd62902d960a989a920d882f3b77fe7b2a (diff) | |
integrate changes (makes code more modular, i would argue)
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 8179]
Diffstat (limited to 'src/cuda-sim')
| -rw-r--r-- | src/cuda-sim/cuda-sim.cc | 37 | ||||
| -rw-r--r-- | src/cuda-sim/cuda-sim.h | 5 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_ir.cc | 4 |
3 files changed, 34 insertions, 12 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc index 34bfe82..4326987 100644 --- a/src/cuda-sim/cuda-sim.cc +++ b/src/cuda-sim/cuda-sim.cc @@ -96,6 +96,8 @@ addr_t g_debug_pc = 0xBEEF1518; unsigned g_ptx_sim_num_insn = 0; unsigned gpgpu_param_num_shaders = 0; +static address_type get_converge_point(address_type pc); + void gpgpu_t::gpgpu_ptx_sim_bindNameToTexture(const char* name, const struct textureReference* texref) { std::string texname(name); @@ -242,13 +244,10 @@ void function_info::ptx_assemble() target.set_type(label_t); } } - for ( unsigned ii=0; ii < n; ii += m_instr_mem[ii]->inst_size() ) { // handle branch instructions - ptx_instruction *pI = m_instr_mem[ii]; - pI->pre_decode(); - } printf(" done.\n"); fflush(stdout); + printf("GPGPU-Sim PTX: finding reconvergence points for \'%s\'...\n", m_name.c_str() ); create_basic_blocks(); connect_basic_blocks(); @@ -274,6 +273,14 @@ void function_info::ptx_assemble() print_ipostdominators(); } + printf("GPGPU-Sim PTX: pre-decoding instructions for \'%s\'... ", m_name.c_str() ); + for ( unsigned ii=0; ii < n; ii += m_instr_mem[ii]->inst_size() ) { // handle branch instructions + ptx_instruction *pI = m_instr_mem[ii]; + pI->pre_decode(); + } + printf(" done.\n"); + fflush(stdout); + m_assembled = true; } @@ -659,6 +666,10 @@ void ptx_instruction::pre_decode() } } } + + // get reconvergence pc + reconvergence_pc = get_converge_point(pc); + m_decoded=true; } @@ -1609,7 +1620,15 @@ struct rec_pts find_reconvergence_points( function_info *finfo ) return tmp; } -unsigned int get_converge_point( unsigned int pc, void *thd ) +address_type get_return_pc( void *thd ) +{ + // function call return + ptx_thread_info *the_thread = (ptx_thread_info*)thd; + assert( the_thread != NULL ); + return the_thread->get_return_PC(); +} + +address_type get_converge_point( address_type pc ) { // the branch could encode the reconvergence point and/or a bit that indicates the // reconvergence point is the return PC on the call stack in the case the branch has @@ -1624,16 +1643,12 @@ unsigned int get_converge_point( unsigned int pc, void *thd ) for (; i < tmp.s_num_recon; ++i) { if (tmp.s_kernel_recon_points[i].source_pc == pc) { if( tmp.s_kernel_recon_points[i].target_pc == (unsigned) -2 ) { - // function call return - ptx_thread_info *the_thread = (ptx_thread_info*)thd; - assert( the_thread != NULL ); - return the_thread->get_return_PC(); + return RECONVERGE_RETURN_PC; } else { return tmp.s_kernel_recon_points[i].target_pc; } } } - assert(i < tmp.s_num_recon); - abort(); // returning garbage! + return NO_BRANCH_DIVERGENCE; } diff --git a/src/cuda-sim/cuda-sim.h b/src/cuda-sim/cuda-sim.h index 0e97b97..e7c1965 100644 --- a/src/cuda-sim/cuda-sim.h +++ b/src/cuda-sim/cuda-sim.h @@ -47,7 +47,10 @@ const warp_inst_t *ptx_fetch_inst( address_type pc ); const struct gpgpu_ptx_sim_kernel_info* ptx_sim_kernel_info(const class function_info *kernel); void ptx_print_insn( address_type pc, FILE *fp ); void set_param_gpgpu_num_shaders(int num_shaders); -unsigned int get_converge_point(unsigned int pc, void *thd); + +#define RECONVERGE_RETURN_PC ((address_type)-2) +#define NO_BRANCH_DIVERGENCE ((address_type)-1) +address_type get_return_pc( void *thd ); const char *get_ptxinfo_kname(); void print_ptxinfo(); void clear_ptxinfo(); diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc index b98e774..e52fccd 100644 --- a/src/cuda-sim/ptx_ir.cc +++ b/src/cuda-sim/ptx_ir.cc @@ -756,6 +756,8 @@ void function_info::print_idominators() unsigned function_info::get_num_reconvergence_pairs() { if (!num_reconvergence_pairs) { + if( m_basic_blocks.size() == 0 ) + return 0; for (unsigned i=0; i< (m_basic_blocks.size()-1); i++) { //last basic block containing exit obviously won't have a pair if (m_basic_blocks[i]->ptx_end->get_opcode() == BRA_OP) { num_reconvergence_pairs++; @@ -768,6 +770,8 @@ unsigned function_info::get_num_reconvergence_pairs() void function_info::get_reconvergence_pairs(gpgpu_recon_t* recon_points) { unsigned idx=0; //array index + if( m_basic_blocks.size() == 0 ) + return; for (unsigned i=0; i< (m_basic_blocks.size()-1); i++) { //last basic block containing exit obviously won't have a pair #ifdef DEBUG_GET_RECONVERG_PAIRS printf("i=%d\n", i); fflush(stdout); |
