summaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
authorTor Aamodt <[email protected]>2010-07-19 23:29:18 -0800
committerTor Aamodt <[email protected]>2010-07-19 23:29:18 -0800
commit55106068e9087f253bbeb587a763055620e59441 (patch)
treeb82de10a84fa023fa694af4cee0229bbbf98a927 /src/cuda-sim
parent7f931254bd1468c2db4fc7a954550e89c3d742f4 (diff)
OpenCL running on simulator w/ CUDA 3.1 and nvidia driver 256.35
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 6907]
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/cuda-sim.cc16
-rw-r--r--src/cuda-sim/instructions.cc12
-rw-r--r--src/cuda-sim/ptx.l4
-rw-r--r--src/cuda-sim/ptx.y34
-rw-r--r--src/cuda-sim/ptx_ir.cc23
-rw-r--r--src/cuda-sim/ptx_ir.h12
6 files changed, 59 insertions, 42 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc
index 1326ccd..8703922 100644
--- a/src/cuda-sim/cuda-sim.cc
+++ b/src/cuda-sim/cuda-sim.cc
@@ -1045,8 +1045,12 @@ void function_info::finalize( memory_space *param_mem, symbol_table *symtab )
assert(xtype==(unsigned)type);
size_t size;
size = param_value.size; // size of param in bytes
- assert(param_value.offset == param_address);
- assert(size == p.get_size() / 8);
+ //assert(param_value.offset == param_address);
+ if( size != p.get_size() / 8) {
+ printf("GPGPU-Sim PTX: WARNING actual kernel paramter size = %zu bytes vs. formal size = %zu (using smaller of two)\n",
+ size, p.get_size()/8);
+ size = (size<(p.get_size()/8))?size:(p.get_size()/8);
+ }
// copy the parameter over word-by-word so that parameter that crosses a memory page can be copied over
const size_t word_size = 4;
for (size_t idx = 0; idx < size; idx += word_size) {
@@ -1214,7 +1218,7 @@ void function_info::ptx_exec_inst( ptx_thread_info *thread,
ptx_file_line_stats_add_exec_count(pI);
if ( gpgpu_ptx_instruction_classification ) {
unsigned space_type=0;
- switch ( pI->get_space() ) {
+ switch ( pI->get_space().get_type() ) {
case global_space: space_type = 10; break;
case local_space: space_type = 11; break;
case tex_space: space_type = 12; break;
@@ -1651,7 +1655,7 @@ void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t co
symbol *sym = g_current_symbol_table->lookup(sym_name.c_str());
assert(sym);
unsigned dst = sym->get_address() + offset;
- switch (mem_region) {
+ switch (mem_region.get_type()) {
case const_space:
mem = g_global_mem;
mem_name = "global";
@@ -2271,9 +2275,9 @@ struct rec_pts find_reconvergence_points( function_info *finfo )
gpgpu_recon_t *kernel_recon_points = (struct gpgpu_recon_t*) calloc(num_recon, sizeof(struct gpgpu_recon_t));
finfo->get_reconvergence_pairs(kernel_recon_points);
- printf("Reconvergence Pairs for %s\n", finfo->get_name().c_str() );
+ printf("GPGPU-Sim PTX: Reconvergence Pairs for %s\n", finfo->get_name().c_str() );
for (int i=0;i<num_recon;i++)
- printf("%d\t%d\n", kernel_recon_points[i].source_pc, kernel_recon_points[i].target_pc);
+ printf("GPGPU-Sim PTX: branch pc = %d\ttarget pc = %d\n", kernel_recon_points[i].source_pc, kernel_recon_points[i].target_pc);
tmp.s_kernel_recon_points = kernel_recon_points;
tmp.s_num_recon = num_recon;
g_rpts[finfo] = tmp;
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index fe3e1a1..a19f1a8 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -1301,14 +1301,14 @@ void cvta_impl( const ptx_instruction *pI, ptx_thread_info *thread )
unsigned hwtid = thread->get_hw_tid();
if( to_non_generic ) {
- switch( space ) {
+ switch( space.get_type() ) {
case shared_space: to_addr_hw = generic_to_shared( smid, from_addr_hw ); break;
case local_space: to_addr_hw = generic_to_local( smid, hwtid, from_addr_hw ); break;
case global_space: to_addr_hw = generic_to_global(from_addr_hw ); break;
default: abort();
}
} else {
- switch( space ) {
+ switch( space.get_type() ) {
case shared_space: to_addr_hw = shared_to_generic( smid, from_addr_hw ); break;
case local_space: to_addr_hw = local_to_generic( smid, hwtid, from_addr_hw ); break;
case global_space: to_addr_hw = global_to_generic( from_addr_hw ); break;
@@ -1409,7 +1409,7 @@ void isspacep_impl( const ptx_instruction *pI, ptx_thread_info *thread )
unsigned smid = thread->get_hw_sid();
unsigned hwtid = thread->get_hw_tid();
- switch( space ) {
+ switch( space.get_type() ) {
case shared_space: t = isspace_shared( smid, addr );
case local_space: t = isspace_local( smid, hwtid, addr );
case global_space: t = isspace_global( addr );
@@ -1441,7 +1441,7 @@ void decode_space( memory_space_t &space, const ptx_thread_info *thread, const o
abort();
}
}
- switch ( space ) {
+ switch ( space.get_type() ) {
case global_space: mem = g_global_mem; break;
case param_space_local:
case local_space:
@@ -1452,12 +1452,12 @@ void decode_space( memory_space_t &space, const ptx_thread_info *thread, const o
case surf_space: mem = g_surf_mem; break;
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;
+ case const_space: assert(space.get_bank()==0); mem = g_global_mem; break;
case generic_space:
if( thread->get_ptx_version().ver() >= 2.0 ) {
// convert generic address to memory space address
space = whichspace(addr);
- switch ( space ) {
+ switch ( space.get_type() ) {
case global_space: mem = g_global_mem; addr = generic_to_global(addr); break;
case local_space: mem = thread->m_local_mem; addr = generic_to_local(smid,hwtid,addr); break;
case shared_space: mem = thread->m_shared_mem; addr = generic_to_shared(smid,addr); break;
diff --git a/src/cuda-sim/ptx.l b/src/cuda-sim/ptx.l
index 21f8b08..3e98a75 100644
--- a/src/cuda-sim/ptx.l
+++ b/src/cuda-sim/ptx.l
@@ -170,8 +170,8 @@ xor TC; ptx_lval.int_value = XOR_OP; return OPCODE;
\.byte TC; return BYTE_DIRECTIVE; /* not in PTX 2.1 */
\.callprototype TC; return CALLPROTOTYPE_DIRECTIVE;
\.calltargets TC; return CALLTARGETS_DIRECTIVE;
-\.const\[[0-9]+\] TC; /*fixme: should use const offset value*/ abort(); return CONST_DIRECTIVE;
-\.const TC; return CONST_DIRECTIVE;
+\.const\[[0-9]+\] TC; ptx_lval.int_value = atoi(yytext+7); return CONST_DIRECTIVE;
+\.const TC; ptx_lval.int_value = 0; return CONST_DIRECTIVE;
\.entry TC; return ENTRY_DIRECTIVE;
\.extern TC; return EXTERN_DIRECTIVE;
\.file TC; BEGIN(INITIAL); return FILE_DIRECTIVE;
diff --git a/src/cuda-sim/ptx.y b/src/cuda-sim/ptx.y
index 36c71d8..f788e01 100644
--- a/src/cuda-sim/ptx.y
+++ b/src/cuda-sim/ptx.y
@@ -76,7 +76,7 @@
%token BYTE_DIRECTIVE
%token CALLPROTOTYPE_DIRECTIVE
%token CALLTARGETS_DIRECTIVE
-%token CONST_DIRECTIVE
+%token <int_value> CONST_DIRECTIVE
%token ENTRY_DIRECTIVE
%token EXTERN_DIRECTIVE
%token FILE_DIRECTIVE
@@ -224,8 +224,8 @@ input: /* empty */
| input function_decl
;
-function_defn: function_decl { set_symtab($1); } LEFT_BRACE statement_list RIGHT_BRACE { end_function(); }
- | function_decl { set_symtab($1); } block_spec LEFT_BRACE statement_list RIGHT_BRACE { end_function(); }
+function_defn: function_decl { set_symtab($1); } statement_block { end_function(); }
+ | function_decl { set_symtab($1); } block_spec statement_block { end_function(); }
;
block_spec: MAXNTID_DIRECTIVE INT_OPERAND COMMA INT_OPERAND COMMA INT_OPERAND
@@ -249,13 +249,17 @@ function_decl_header: ENTRY_DIRECTIVE { $$ = 1; g_func_decl=1; }
param_list: param_entry { add_directive(); }
| param_list COMMA param_entry { add_directive(); }
-param_entry: PARAM_DIRECTIVE { add_space_spec(param_space_unclassified); } variable_spec identifier_spec { add_function_arg(); }
- | REG_DIRECTIVE { add_space_spec(reg_space); } variable_spec identifier_spec { add_function_arg(); }
+param_entry: PARAM_DIRECTIVE { add_space_spec(param_space_unclassified,0); } variable_spec identifier_spec { add_function_arg(); }
+ | REG_DIRECTIVE { add_space_spec(reg_space,0); } variable_spec identifier_spec { add_function_arg(); }
+
+statement_block: LEFT_BRACE statement_list RIGHT_BRACE
statement_list: directive_statement { add_directive(); }
| instruction_statement { add_instruction(); }
| statement_list directive_statement { add_directive(); }
- | statement_list instruction_statement { add_instruction(); }
+ | statement_list instruction_statement { add_instruction(); }
+ | statement_list statement_block
+ | statement_block
;
directive_statement: variable_declaration SEMI_COLON
@@ -305,18 +309,18 @@ var_spec: space_spec
align_spec: ALIGN_DIRECTIVE INT_OPERAND { add_alignment_spec($2); }
-space_spec: REG_DIRECTIVE { add_space_spec(reg_space); }
- | SREG_DIRECTIVE { add_space_spec(reg_space); }
+space_spec: REG_DIRECTIVE { add_space_spec(reg_space,0); }
+ | SREG_DIRECTIVE { add_space_spec(reg_space,0); }
| addressable_spec
;
-addressable_spec: CONST_DIRECTIVE { add_space_spec(const_space); }
- | GLOBAL_DIRECTIVE { add_space_spec(global_space); }
- | LOCAL_DIRECTIVE { add_space_spec(local_space); }
- | PARAM_DIRECTIVE { add_space_spec(param_space_unclassified); }
- | SHARED_DIRECTIVE { add_space_spec(shared_space); }
- | SURF_DIRECTIVE { add_space_spec(surf_space); }
- | TEX_DIRECTIVE { add_space_spec(tex_space); }
+addressable_spec: CONST_DIRECTIVE { add_space_spec(const_space,$1); }
+ | GLOBAL_DIRECTIVE { add_space_spec(global_space,0); }
+ | LOCAL_DIRECTIVE { add_space_spec(local_space,0); }
+ | PARAM_DIRECTIVE { add_space_spec(param_space_unclassified,0); }
+ | SHARED_DIRECTIVE { add_space_spec(shared_space,0); }
+ | SURF_DIRECTIVE { add_space_spec(surf_space,0); }
+ | TEX_DIRECTIVE { add_space_spec(tex_space,0); }
;
type_spec: scalar_type
diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc
index f51b022..fa87ad9 100644
--- a/src/cuda-sim/ptx_ir.cc
+++ b/src/cuda-sim/ptx_ir.cc
@@ -322,7 +322,7 @@ void add_variables()
void set_variable_type()
{
DPRINTF("set_variable_type space_spec=%s scalar_type_spec=%s",
- g_ptx_token_decode[g_space_spec].c_str(),
+ g_ptx_token_decode[g_space_spec.get_type()].c_str(),
g_ptx_token_decode[g_scalar_type_spec].c_str() );
parse_assert( g_space_spec != undefined_space, "variable has no space specification" );
parse_assert( g_scalar_type_spec != -1, "variable has no type information" ); // need to extend for structs?
@@ -372,8 +372,9 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident
g_last_symbol = s;
if( g_func_decl )
return;
- std::string msg = std::string(identifier) + " was delcared previous at " + s->decl_location();
- parse_error(msg.c_str());
+ std::string msg = std::string(identifier) + " was delcared previous at " + s->decl_location() + " skipping new declaration";
+ printf("GPGPU-Sim PTX: Warning %s\n", msg.c_str());
+ return;
}
assert( g_var_type != NULL );
@@ -390,7 +391,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident
break;
}
g_last_symbol = g_current_symbol_table->add_variable(identifier,type,num_bits/8,g_filename,ptx_lineno);
- switch ( ti.get_memory_space() ) {
+ switch ( ti.get_memory_space().get_type() ) {
case reg_space: {
regnum = g_current_symbol_table->next_reg_num();
int arch_regnum = -1;
@@ -418,6 +419,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident
g_current_symbol_table->alloc_shared( num_bits/8 + addr_pad );
break;
case const_space:
+ assert(ti.get_memory_space().get_bank()==0);
if( array_ident == ARRAY_IDENTIFIER_NO_DIM ) {
printf("GPGPU-Sim PTX: deferring allocation of constant region for \"%s\" (need size information)\n", identifier );
} else {
@@ -455,6 +457,10 @@ 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:
+ if( g_func_info == NULL ) {
+ printf("GPGPU-Sim PTX: not allocating .local \"%s\" declared at global scope\n", identifier);
+ break;
+ }
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(),
@@ -514,7 +520,7 @@ void add_alignment_spec( int spec )
g_alignment_spec = spec;
}
-void add_space_spec( memory_space_t spec )
+void add_space_spec( enum _memory_space_t spec, int value )
{
DPRINTF("add_space_spec \"%s\"", g_ptx_token_decode[spec].c_str() );
parse_assert( g_space_spec == undefined_space, "multiple space specifiers not allowed." );
@@ -526,8 +532,11 @@ void add_space_spec( memory_space_t spec )
g_space_spec = param_space_local;
} else
g_space_spec = param_space_unclassified;
- } else
+ } else {
g_space_spec = spec;
+ if( g_space_spec == const_space )
+ g_space_spec.set_bank((unsigned)value);
+ }
}
void add_vector_spec(int spec )
@@ -1312,7 +1321,7 @@ extern "C" void set_symtab(void*symtab)
extern "C" void add_pragma( const char *str )
{
- printf("GPGPU-Sim: Warning -- ignoring pragma '%s'\n", str );
+ printf("GPGPU-Sim PTX: Warning -- ignoring pragma '%s'\n", str );
}
unsigned ptx_kernel_shmem_size( void *kernel_impl )
diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h
index 0c63e41..1daf9f1 100644
--- a/src/cuda-sim/ptx_ir.h
+++ b/src/cuda-sim/ptx_ir.h
@@ -123,7 +123,7 @@ public:
bool is_global() const { return m_space_spec == global_space;}
bool is_local() const { return m_space_spec == local_space;}
bool is_shared() const { return m_space_spec == shared_space;}
- bool is_const() const { return m_space_spec == const_space;}
+ bool is_const() const { return m_space_spec.get_type() == const_space;}
bool is_tex() const { return m_space_spec == tex_space;}
bool is_func_addr() const { return m_is_function?true:false; }
int scalar_type() const { return m_scalar_type_spec;}
@@ -869,7 +869,7 @@ private:
class param_info {
public:
- param_info() { m_valid = false; m_value_set=false;}
+ param_info() { m_valid = false; m_value_set=false; m_size = 0; }
param_info( std::string name, int type, size_t size )
{
m_valid = true;
@@ -882,10 +882,10 @@ public:
m_value_set = true;
m_value = v;
}
- std::string get_name() const { return m_name; }
- int get_type() const { return m_type; }
+ std::string get_name() const { assert(m_valid); return m_name; }
+ int get_type() const { assert(m_valid); return m_type; }
param_t get_value() const { assert(m_value_set); return m_value; }
- size_t get_size() const { return m_size; }
+ size_t get_size() const { assert(m_valid); return m_size; }
private:
bool m_valid;
std::string m_name;
@@ -1294,7 +1294,7 @@ extern "C" {
void add_address_operand( const char *identifier, int offset );
void add_label( const char *idenfiier );
void add_vector_spec(int spec );
- void add_space_spec( memory_space_t spec );
+ void add_space_spec( enum _memory_space_t spec, int value );
void add_extern_spec();
void add_instruction();
void set_return();