From 960a55b075be901ca14d1878f886bbea73456663 Mon Sep 17 00:00:00 2001 From: Wilson Fung Date: Wed, 12 Sep 2012 20:15:37 -0800 Subject: Minor refactoring for the SIMT Stack implementation and fixing some indentation [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 14067] --- src/abstract_hardware_model.cc | 53 ++++++++++++++++++++++-------------------- src/abstract_hardware_model.h | 32 ++++++++++++------------- 2 files changed, 44 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/abstract_hardware_model.cc b/src/abstract_hardware_model.cc index 7a9fcf8..a2539af 100644 --- a/src/abstract_hardware_model.cc +++ b/src/abstract_hardware_model.cc @@ -716,16 +716,17 @@ void simt_stack::update( simt_mask_t &thread_done, addr_vector_t &next_pc, addre } } -void core_t::execute_warp_inst_t(warp_inst_t &inst, unsigned warpSize, unsigned warpId){ +void core_t::execute_warp_inst_t(warp_inst_t &inst, unsigned warpSize, unsigned warpId) +{ for ( unsigned t=0; t < warpSize; t++ ) { if( inst.active(t) ) { - if(warpId==(unsigned (-1))) - warpId = inst.warp_id(); - unsigned tid=warpSize*warpId+t; - m_thread[tid]->ptx_exec_inst(inst,t); - - //virtual function - checkExecutionStatusAndUpdate(inst,t,tid); + if(warpId==(unsigned (-1))) + warpId = inst.warp_id(); + unsigned tid=warpSize*warpId+t; + m_thread[tid]->ptx_exec_inst(inst,t); + + //virtual function + checkExecutionStatusAndUpdate(inst,t,tid); } } } @@ -735,25 +736,27 @@ bool core_t::ptx_thread_done( unsigned hw_thread_id ) const return ((m_thread[ hw_thread_id ]==NULL) || m_thread[ hw_thread_id ]->is_done()); } -void core_t::updateSIMTStack(unsigned warpId, unsigned warpSize, warp_inst_t * inst){ -simt_mask_t thread_done; -addr_vector_t next_pc; -unsigned wtid = warpId * warpSize; -for (unsigned i = 0; i < warpSize; i++) { - if( ptx_thread_done(wtid+i) ) { - thread_done.set(i); - next_pc.push_back( (address_type)-1 ); - } else { - if( inst->reconvergence_pc == RECONVERGE_RETURN_PC ) - inst->reconvergence_pc = get_return_pc(m_thread[wtid+i]); - next_pc.push_back( m_thread[wtid+i]->get_pc() ); - } -} -m_simt_stack[warpId]->update(thread_done,next_pc,inst->reconvergence_pc, inst->op); +void core_t::updateSIMTStack(unsigned warpId, unsigned warpSize, warp_inst_t * inst) +{ + simt_mask_t thread_done; + addr_vector_t next_pc; + unsigned wtid = warpId * warpSize; + for (unsigned i = 0; i < warpSize; i++) { + if( ptx_thread_done(wtid+i) ) { + thread_done.set(i); + next_pc.push_back( (address_type)-1 ); + } else { + if( inst->reconvergence_pc == RECONVERGE_RETURN_PC ) + inst->reconvergence_pc = get_return_pc(m_thread[wtid+i]); + next_pc.push_back( m_thread[wtid+i]->get_pc() ); + } + } + m_simt_stack[warpId]->update(thread_done,next_pc,inst->reconvergence_pc, inst->op); } //! Get the warp to be executed using the data taken form the SIMT stack -warp_inst_t core_t::getExecuteWarp(unsigned warpId){ +warp_inst_t core_t::getExecuteWarp(unsigned warpId) +{ unsigned pc,rpc; m_simt_stack[warpId]->get_pdom_stack_top_info(&pc,&rpc); warp_inst_t wi= *ptx_fetch_inst(pc); @@ -763,7 +766,7 @@ warp_inst_t core_t::getExecuteWarp(unsigned warpId){ void core_t::initilizeSIMTStack(unsigned warps, unsigned warpsSize) { -m_simt_stack = new simt_stack*[warps]; + m_simt_stack = new simt_stack*[warps]; for (unsigned i = 0; i < warps; ++i) m_simt_stack[i] = new simt_stack(i,warpsSize); } diff --git a/src/abstract_hardware_model.h b/src/abstract_hardware_model.h index 8a08501..3bde119 100644 --- a/src/abstract_hardware_model.h +++ b/src/abstract_hardware_model.h @@ -219,22 +219,6 @@ typedef std::bitset active_mask_t; typedef std::bitset simt_mask_t; typedef std::vector addr_vector_t; -enum stack_entry_type { - STACK_ENTRY_TYPE_NORMAL = 0, - STACK_ENTRY_TYPE_CALL -}; - -struct simt_stack_entry { - address_type m_pc; - unsigned int m_calldepth; - simt_mask_t m_active_mask; - address_type m_recvg_pc; - unsigned long long m_branch_div_cycle; - stack_entry_type m_type; - simt_stack_entry() : - m_pc(-1), m_calldepth(0), m_active_mask(), m_recvg_pc(-1), m_branch_div_cycle(0), m_type(STACK_ENTRY_TYPE_NORMAL) { }; -}; - class simt_stack { public: simt_stack( unsigned wid, unsigned warpSize); @@ -252,6 +236,22 @@ protected: unsigned m_warp_id; unsigned m_warp_size; + enum stack_entry_type { + STACK_ENTRY_TYPE_NORMAL = 0, + STACK_ENTRY_TYPE_CALL + }; + + struct simt_stack_entry { + address_type m_pc; + unsigned int m_calldepth; + simt_mask_t m_active_mask; + address_type m_recvg_pc; + unsigned long long m_branch_div_cycle; + stack_entry_type m_type; + simt_stack_entry() : + m_pc(-1), m_calldepth(0), m_active_mask(), m_recvg_pc(-1), m_branch_div_cycle(0), m_type(STACK_ENTRY_TYPE_NORMAL) { }; + }; + std::deque m_stack; }; -- cgit v1.3