summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cuda-sim/cuda-sim.cc12
-rw-r--r--src/cuda-sim/instructions.cc16
-rw-r--r--src/cuda-sim/ptx_ir.cc25
-rw-r--r--src/cuda-sim/ptx_ir.h14
-rw-r--r--src/cuda-sim/ptx_sim.cc11
-rw-r--r--src/cuda-sim/ptx_sim.h6
6 files changed, 63 insertions, 21 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index 41acd62..2f66d51 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -459,6 +459,7 @@ function_info::function_info(int entry_point )
m_kernel_info.lmem = 0;
m_kernel_info.regs = 0;
m_kernel_info.smem = 0;
+ m_local_mem_framesize = (unsigned)-1;
}
void function_info::print_insn( unsigned pc, FILE * fp ) const
@@ -986,11 +987,6 @@ void function_info::add_param_name_type_size( unsigned index, std::string name,
}
}
-void function_info::add_local_param_name_type_size( std::string name, int type, size_t size )
-{
- m_ptx_local_params[name] = param_info(name, type, size);
-}
-
void function_info::add_param_data( unsigned argn, struct gpgpu_ptx_sim_arg *args )
{
const void *data = args->m_start;
@@ -1345,11 +1341,9 @@ unsigned ptx_sim_init_thread( ptx_thread_info** thread_info,int sid,unsigned tid
unsigned max_cta_per_sm = num_threads/cta_size; // e.g., 256 / 48 = 5
assert( max_cta_per_sm > 0 );
- //following sm_idx calculation assumes shaders being filled up depth-first?
- unsigned sm_idx = sid*max_cta_per_sm + sm_offset; /* Is this assuming non-even block distribution? */
+ unsigned sm_idx = sid*max_cta_per_sm + sm_offset;
sm_idx = max_cta_per_sm*sid + tid/cta_size;
-
if (!gpgpu_option_spread_blocks_across_cores) {
// update offset...
if ( (sm_offset + 1) >= max_cta_per_sm ) {
@@ -1905,7 +1899,7 @@ void gpgpu_ptx_assemble( std::string kname, void *kinfo )
{
function_info *func_info = (function_info *)kinfo;
if( func_info->is_extern() ) {
- printf("GPGPU-Sim: skipping assembly for extern declared function \'%s\'", func_info->get_name().c_str() );
+ printf("GPGPU-Sim PTX: skipping assembly for extern declared function \'%s\'\n", func_info->get_name().c_str() );
return;
}
g_func_info = func_info;
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index 2b4b410..7606686 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -141,6 +141,8 @@ ptx_reg_t ptx_thread_info::get_operand_value( const operand_info &op )
result.u64 = baseaddr.u64 + op.get_addr_offset();
} else if ( info.is_param_kernel() ) {
result = sym->get_address() + op.get_addr_offset();
+ } else if ( info.is_param_local() ) {
+ result = sym->get_address() + op.get_addr_offset();
} else if ( info.is_global() ) {
assert( op.get_addr_offset() == 0 );
result = sym->get_address();
@@ -151,7 +153,9 @@ ptx_reg_t ptx_thread_info::get_operand_value( const operand_info &op )
} else if ( op.is_shared() ) {
result = op.get_symbol()->get_address() + op.get_addr_offset();
} else {
- assert(0);
+ name = op.name().c_str();
+ printf("GPGPU-Sim PTX: ERROR ** get_operand_value : unknown memory operand type for %s\n", name );
+ abort();
}
} else if ( op.is_literal() ) {
@@ -168,7 +172,7 @@ ptx_reg_t ptx_thread_info::get_operand_value( const operand_info &op )
result = op.get_symbol()->get_address();
} else {
name = op.name().c_str();
- printf("ERROR! %s is neither local, global, const, shared, label, literal, memory operand, builtin, or register!\n",name);
+ printf("GPGPU-Sim PTX: ERROR ** get_operand_value : unknown operand type for %s\n", name );
assert(0);
}
@@ -1460,11 +1464,13 @@ void decode_space( memory_space_t &space, ptx_thread_info *thread, memory_space
unsigned hwtid = thread->get_hw_tid();
switch ( space ) {
case global_space: mem = g_global_mem; break;
- case local_space: mem = thread->m_local_mem; break;
+ case param_space_local:
+ case local_space:
+ mem = thread->m_local_mem;
+ addr += thread->get_local_mem_stack_pointer();
+ break;
case tex_space: mem = g_tex_mem; break;
case surf_space: mem = g_surf_mem; break;
- case param_space_local:
- abort(); // finish this
case param_space_kernel: mem = g_param_mem; break;
case shared_space: mem = thread->m_shared_mem; break;
case const_space: mem = g_global_mem; break;
diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc
index da1c49b..2597ac5 100644
--- a/src/cuda-sim/ptx_ir.cc
+++ b/src/cuda-sim/ptx_ir.cc
@@ -455,7 +455,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident
g_sym_name_to_symbol_table[ identifier ] = g_current_symbol_table;
break;
case local_space:
- printf("GPGPU-Sim PTX: allocating local region for \"%s\" from 0x%x to 0x%lx (local memory space)\n",
+ printf("GPGPU-Sim PTX: allocating stack frame region for .local \"%s\" from 0x%x to 0x%lx\n",
identifier,
g_current_symbol_table->get_local_next(),
g_current_symbol_table->get_local_next() + num_bits/8 );
@@ -468,6 +468,15 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident
printf("GPGPU-Sim PTX: encountered texture directive %s.\n", identifier);
break;
case param_space_local:
+ printf("GPGPU-Sim PTX: allocating stack frame region for .param \"%s\" from 0x%x to 0x%lx\n",
+ identifier,
+ g_current_symbol_table->get_local_next(),
+ g_current_symbol_table->get_local_next() + num_bits/8 );
+ fflush(stdout);
+ assert( (num_bits%8) == 0 );
+ g_last_symbol->set_address( g_current_symbol_table->get_local_next() );
+ g_current_symbol_table->alloc_local( num_bits/8 );
+ break;
case param_space_kernel:
break;
default:
@@ -475,12 +484,20 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident
break;
}
-
+ assert( !ti.is_param_unclassified() );
if ( ti.is_param_kernel() ) {
g_func_info->add_param_name_type_size(g_entry_func_param_index,identifier, ti.scalar_type(), num_bits );
g_entry_func_param_index++;
- } else if ( ti.is_param_local() || ti.is_param_unclassified() ) {
- g_func_info->add_local_param_name_type_size( identifier, ti.scalar_type(), num_bits );
+ } else if ( ti.is_param_local() ) {
+ printf("GPGPU-Sim PTX: allocating stack frame region for input/output .param \"%s\" from 0x%x to 0x%lx\n",
+ identifier,
+ g_current_symbol_table->get_local_next(),
+ g_current_symbol_table->get_local_next() + num_bits/8 );
+ fflush(stdout);
+ assert( (num_bits%8) == 0 );
+ addr_t addr = g_current_symbol_table->get_local_next();
+ g_last_symbol->set_address( addr );
+ g_current_symbol_table->alloc_local( num_bits/8 );
}
}
diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h
index b143697..8f3d48e 100644
--- a/src/cuda-sim/ptx_ir.h
+++ b/src/cuda-sim/ptx_ir.h
@@ -196,6 +196,7 @@ public:
m_is_const = false;
m_is_global = false;
m_is_local = false;
+ m_is_param_local = false;
m_is_tex = false;
m_is_func_addr = false;
m_reg_num_valid = false;
@@ -204,6 +205,7 @@ public:
if ( type ) m_is_const = type->get_key().is_const();
if ( type ) m_is_global = type->get_key().is_global();
if ( type ) m_is_local = type->get_key().is_local();
+ if ( type ) m_is_param_local = type->get_key().is_param_local();
if ( type ) m_is_tex = type->get_key().is_tex();
if ( type ) m_is_func_addr = type->get_key().is_func_addr();
}
@@ -249,6 +251,7 @@ public:
bool is_const() const { return m_is_const;}
bool is_global() const { return m_is_global;}
bool is_local() const { return m_is_local;}
+ bool is_param_local() const { return m_is_param_local; }
bool is_tex() const { return m_is_tex;}
bool is_func_addr() const { return m_is_func_addr; }
@@ -289,6 +292,7 @@ private:
bool m_is_const;
bool m_is_global;
bool m_is_local;
+ bool m_is_param_local;
bool m_is_tex;
bool m_is_func_addr;
unsigned m_reg_num;
@@ -374,6 +378,8 @@ public:
m_type = symbolic_t;
} else if ( addr->is_local() ) {
m_type = symbolic_t;
+ } else if ( addr->is_param_local() ) {
+ m_type = symbolic_t;
} else if ( addr->is_tex() ) {
m_type = symbolic_t;
} else if ( addr->is_func_addr() ) {
@@ -944,7 +950,6 @@ public:
m_kernel_params[ name ] = value;
}
void add_param_name_type_size( unsigned index, std::string name, int type, size_t size );
- void add_local_param_name_type_size( std::string name, int type, size_t size );
void add_param_data( unsigned argn, struct gpgpu_ptx_sim_arg *args );
void add_return_var( const symbol *rv )
{
@@ -1009,9 +1014,15 @@ public:
assert(pc <= s_g_pc_to_insn.size());
return s_g_pc_to_insn[pc - 1];
}
+ unsigned local_mem_framesize() const
+ {
+ assert( m_local_mem_framesize != (unsigned) -1 );
+ return m_local_mem_framesize;
+ }
private:
unsigned m_uid;
+ unsigned m_local_mem_framesize;
bool m_entry_point;
bool m_extern;
bool m_assembled;
@@ -1021,7 +1032,6 @@ private:
unsigned m_instr_mem_size;
std::map<std::string,param_t> m_kernel_params;
std::map<unsigned,param_info> m_ptx_kernel_param_info;
- std::map<std::string,param_info> m_ptx_local_params;
const symbol *m_return_var_sym;
std::vector<const symbol*> m_args;
std::list<ptx_instruction*> m_instructions;
diff --git a/src/cuda-sim/ptx_sim.cc b/src/cuda-sim/ptx_sim.cc
index 269b858..85e6185 100644
--- a/src/cuda-sim/ptx_sim.cc
+++ b/src/cuda-sim/ptx_sim.cc
@@ -241,6 +241,7 @@ ptx_thread_info::ptx_thread_info()
m_RPC_updated = false;
m_last_was_call = false;
m_enable_debug_trace = false;
+ m_local_mem_stack_pointer = 0;
}
const ptx_version &ptx_thread_info::get_ptx_version() const
@@ -447,6 +448,16 @@ void ptx_thread_info::dump_modifiedregs()
}
}
+void ptx_thread_info::push_local_mem_stack()
+{
+ m_local_mem_stack_pointer += m_func_info->local_mem_framesize();
+}
+
+void ptx_thread_info::pop_local_mem_stack()
+{
+ m_local_mem_stack_pointer -= m_func_info->local_mem_framesize();
+}
+
void ptx_thread_info::set_npc( const function_info *f )
{
m_NPC = f->get_start_PC();
diff --git a/src/cuda-sim/ptx_sim.h b/src/cuda-sim/ptx_sim.h
index 8a74168..d4bdf48 100644
--- a/src/cuda-sim/ptx_sim.h
+++ b/src/cuda-sim/ptx_sim.h
@@ -424,6 +424,10 @@ public:
void enable_debug_trace() { m_enable_debug_trace = true; }
+ unsigned get_local_mem_stack_pointer() const { return m_local_mem_stack_pointer; }
+ void push_local_mem_stack();
+ void pop_local_mem_stack();
+
public:
addr_t m_last_effective_address;
bool m_branch_taken;
@@ -464,8 +468,8 @@ private:
function_info *m_func_info;
std::list<stack_entry> m_callstack;
+ unsigned m_local_mem_stack_pointer;
- // typedef std::unordered_map<std::string,ptx_reg_t> reg_map_t;
typedef std::unordered_map<const symbol*,ptx_reg_t> reg_map_t;
std::list<reg_map_t> m_regs;