summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cuda-sim/instructions.cc50
-rw-r--r--src/gpgpu-sim/shader.cc4
2 files changed, 40 insertions, 14 deletions
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index fe2d0ef..e7bb50a 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -899,18 +899,33 @@ void atom_callback( const inst_t* inst, ptx_thread_info* thread )
// Check state space
addr_t effective_address = src1_data.u64;
- memory_space_t space = pI->get_space();
+ memory_space_t space = pI->get_space();
if (space == undefined_space) {
- // generic space - determine space via address
- space = whichspace(effective_address);
- assert( space == global_space );
- effective_address = generic_to_global(effective_address);
+ // generic space - determine space via address
+ if( whichspace(effective_address) == global_space ) {
+ effective_address = generic_to_global(effective_address);
+ space = global_space;
+ } else if( whichspace(effective_address) == shared_space ) {
+ unsigned smid = thread->get_hw_sid();
+ effective_address = generic_to_shared(smid,effective_address);
+ space = shared_space;
+ } else {
+ abort();
+ }
}
- assert( space == global_space );
+ assert( space == global_space || space == shared_space );
+
+ memory_space *mem = NULL;
+ if(space == global_space)
+ mem = thread->get_global_memory();
+ else if(space == shared_space)
+ mem = thread->m_shared_mem;
+ else
+ abort();
// Copy value pointed to in operand 'a' into register 'd'
// (i.e. copy src1_data to dst)
- thread->get_global_memory()->read(effective_address,size/8,&data.s64);
+ mem->read(effective_address,size/8,&data.s64);
if (dst.get_symbol()->type()){
thread->set_operand_value(dst, data, to_type, thread, pI); // Write value into register 'd'
}
@@ -1151,9 +1166,9 @@ void atom_callback( const inst_t* inst, ptx_thread_info* thread )
}
}
- // Write operation result into global memory
+ // Write operation result into memory
// (i.e. copy src1_data to dst)
- thread->get_global_memory()->write(effective_address,size/8,&op_result.s64,thread,pI);
+ mem->write(effective_address,size/8,&op_result.s64,thread,pI);
}
// atom_impl will now result in a callback being called in mem_ctrl_pop (gpu-sim.c)
@@ -1177,16 +1192,23 @@ void atom_impl( const ptx_instruction *pI, ptx_thread_info *thread )
// handle generic memory space by converting it to global
if ( space == undefined_space ) {
- assert( whichspace(effective_address) == global_space );
- effective_address_final = generic_to_global(effective_address);
- space = global_space;
+ if( whichspace(effective_address) == global_space ) {
+ effective_address_final = generic_to_global(effective_address);
+ space = global_space;
+ } else if( whichspace(effective_address) == shared_space ) {
+ unsigned smid = thread->get_hw_sid();
+ effective_address_final = generic_to_shared(smid,effective_address);
+ space = shared_space;
+ } else {
+ abort();
+ }
} else {
- assert( space == global_space );
+ assert( space == global_space || space == shared_space );
effective_address_final = effective_address;
}
// Check state space
- assert( space == global_space );
+ assert( space == global_space || space == shared_space );
thread->m_last_effective_address = effective_address_final;
thread->m_last_memory_space = space;
diff --git a/src/gpgpu-sim/shader.cc b/src/gpgpu-sim/shader.cc
index 0dd8fd0..fb8165f 100644
--- a/src/gpgpu-sim/shader.cc
+++ b/src/gpgpu-sim/shader.cc
@@ -1169,6 +1169,10 @@ void ldst_unit::writeback()
case 0: // shared memory
if( !m_pipeline_reg[0]->empty() ) {
m_next_wb = *m_pipeline_reg[0];
+ if(m_next_wb.isatomic()) {
+ m_next_wb.do_atomic();
+ m_core->decrement_atomic_count(m_next_wb.warp_id(), m_next_wb.active_count());
+ }
m_core->dec_inst_in_pipeline(m_pipeline_reg[0]->warp_id());
m_pipeline_reg[0]->clear();
serviced_client = next_client;