diff options
Diffstat (limited to 'src/cuda-sim')
| -rw-r--r-- | src/cuda-sim/cuda-sim.cc | 89 | ||||
| -rw-r--r-- | src/cuda-sim/instructions.cc | 60 | ||||
| -rw-r--r-- | src/cuda-sim/ptx.y | 18 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_ir.cc | 33 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_ir.h | 56 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_sim.cc | 2 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_sim.h | 6 |
7 files changed, 115 insertions, 149 deletions
diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc index f7b127c..700d985 100644 --- a/src/cuda-sim/cuda-sim.cc +++ b/src/cuda-sim/cuda-sim.cc @@ -274,7 +274,7 @@ ptx_instruction::ptx_instruction( int opcode, const operand_info &return_var, const std::list<int> &options, const std::list<int> &scalar_type, - int space_spec, + memory_space_t space_spec, const char *file, unsigned line, const char *source ) @@ -678,14 +678,14 @@ bool isspace_global( addr_t addr ) return (addr > GLOBAL_HEAP_START) || (addr < STATIC_ALLOC_LIMIT); } -unsigned whichspace( addr_t addr ) +memory_space_t whichspace( addr_t addr ) { if( (addr > GLOBAL_HEAP_START) || (addr < STATIC_ALLOC_LIMIT) ) { - return GLOBAL_DIRECTIVE; + return global_space; } else if( addr > SHARED_GENERIC_START ) { - return SHARED_DIRECTIVE; + return shared_space; } else { - return LOCAL_DIRECTIVE; + return local_space; } } @@ -971,29 +971,6 @@ void function_info::ptx_decode_inst( ptx_thread_info *thread, } } -unsigned function_info::ptx_get_inst_op( ptx_thread_info *thread ) -{ - addr_t pc = thread->get_pc(); - unsigned index = pc - m_start_PC; - assert( index < m_instr_mem_size ); - ptx_instruction *pI = m_instr_mem[index]; //get instruction from m_instr_mem[PC] - - int opcode = pI->get_opcode(); //determine the opcode - - if ( opcode == LD_OP ) { - if ( pI->get_space() != SHARED_DIRECTIVE ) //treat shared memory access as generic instruction (e.g. no bank conflicts) - return LOAD_OP; - } else if ( opcode == ST_OP ) { - if ( pI->get_space() != SHARED_DIRECTIVE ) - return STORE_OP; - } else if ( opcode == BRA_OP ) { - return BRANCH_OP; - } else if ( opcode == TEX_OP ) { - return LOAD_OP; - } - return ALU_OP; -} - void function_info::add_param_name_type_size( unsigned index, std::string name, int type, size_t size ) { unsigned parsed_index; @@ -1142,7 +1119,7 @@ unsigned g_warp_active_mask; void function_info::ptx_exec_inst( ptx_thread_info *thread, addr_t *addr, - unsigned *space, + memory_space_t *space, unsigned *data_size, dram_callback_t* callback, unsigned warp_active_mask ) @@ -1195,7 +1172,7 @@ void function_info::ptx_exec_inst( ptx_thread_info *thread, } addr_t insn_memaddr = 0xFEEBDAED; - unsigned insn_space = -1; + memory_space_t insn_space = undefined_space; unsigned insn_data_size = 0; if ( pI->get_opcode() == LD_OP || pI->get_opcode() == ST_OP || pI->get_opcode() == TEX_OP ) { insn_memaddr = thread->last_eaddr(); @@ -1231,21 +1208,24 @@ void function_info::ptx_exec_inst( ptx_thread_info *thread, g_ptx_sim_num_insn++; ptx_file_line_stats_add_exec_count(pI); if ( gpgpu_ptx_instruction_classification ) { - unsigned space = pI->get_space(); - switch ( space ) { - case GLOBAL_DIRECTIVE: space = 10; break; - case LOCAL_DIRECTIVE: space = 11; break; - case TEX_DIRECTIVE: space = 12; break; - case SURF_DIRECTIVE: space = 13; break; - case PARAM_DIRECTIVE: space = 14; break; - case SHARED_DIRECTIVE: space = 15; break; - case CONST_DIRECTIVE: space = 16; break; + unsigned space_type=0; + switch ( pI->get_space() ) { + case global_space: space_type = 10; break; + case local_space: space_type = 11; break; + case tex_space: space_type = 12; break; + case surf_space: space_type = 13; break; + case param_space_kernel: + case param_space_local_r: + case param_space_local_w: + space_type = 14; break; + case shared_space: space_type = 15; break; + case const_space: space_type = 16; break; default: - space = 0 ; + space_type = 0 ; break; } StatAddSample( g_inst_classification_stat[g_ptx_kernel_count], op_classification); - if (space) StatAddSample( g_inst_classification_stat[g_ptx_kernel_count], ( int )space); + if (space_type) StatAddSample( g_inst_classification_stat[g_ptx_kernel_count], ( int )space_type); StatAddSample( g_inst_op_classification_stat[g_ptx_kernel_count], (int) pI->get_opcode() ); } if ( (g_ptx_sim_num_insn % 100000) == 0 ) { @@ -1623,14 +1603,14 @@ void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t co { printf("GPGPU-Sim PTX: starting gpgpu_ptx_sim_memcpy_symbol with hostVar 0x%p\n", hostVar); bool found_sym = false; - int mem_region = 0; + memory_space_t mem_region = undefined_space; std::string sym_name; std::map<const void*,std::string>::iterator c=g_const_name_lookup.find(hostVar); if ( c!=g_const_name_lookup.end() ) { found_sym = true; sym_name = c->second; - mem_region = CONST_DIRECTIVE; + mem_region = const_space; } std::map<const void*,std::string>::iterator g=g_global_name_lookup.find(hostVar); if ( g!=g_global_name_lookup.end() ) { @@ -1641,17 +1621,17 @@ void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t co } found_sym = true; sym_name = g->second; - mem_region = GLOBAL_DIRECTIVE; + mem_region = global_space; } if( g_globals.find(hostVar) != g_globals.end() ) { found_sym = true; sym_name = hostVar; - mem_region = GLOBAL_DIRECTIVE; + mem_region = global_space; } if( g_constants.find(hostVar) != g_constants.end() ) { found_sym = true; sym_name = hostVar; - mem_region = CONST_DIRECTIVE; + mem_region = const_space; } if ( !found_sym ) { @@ -1670,11 +1650,11 @@ void gpgpu_ptx_sim_memcpy_symbol(const char *hostVar, const void *src, size_t co assert(sym); unsigned dst = sym->get_address() + offset; switch (mem_region) { - case CONST_DIRECTIVE: + case const_space: mem = g_global_mem; mem_name = "global"; break; - case GLOBAL_DIRECTIVE: + case global_space: mem = g_global_mem; mem_name = "global"; break; @@ -2117,7 +2097,7 @@ void gpgpu_ptx_sim_main_func( const char *kernel_key, dim3 gridDim, dim3 blockDi unsigned op_type; addr_t addr; - unsigned space; + memory_space_t space; int arch_reg[MAX_REG_OPERANDS] = { -1 }; unsigned data_size; dram_callback_t callback; @@ -2174,16 +2154,7 @@ void ptx_decode_inst( void *thd, unsigned *op, int *i1, int *i2, int *i3, int *i g_func_info->ptx_decode_inst(thread,op,i1,i2,i3,i4,o1,o2,o3,o4,vectorin,vectorout,arch_reg); } -unsigned ptx_get_inst_op( void *thd) -{ - if ( thd == NULL ) - return NO_OP; - - ptx_thread_info *thread = (ptx_thread_info *) thd; - return(thread->func_info())->ptx_get_inst_op(thread); -} - -void ptx_exec_inst( void *thd, address_type *addr, unsigned *space, unsigned *data_size, dram_callback_t* callback, unsigned warp_active_mask ) +void ptx_exec_inst( void *thd, address_type *addr, memory_space_t *space, unsigned *data_size, dram_callback_t* callback, unsigned warp_active_mask ) { if ( thd == NULL ) return; diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc index 4e82787..783f97c 100644 --- a/src/cuda-sim/instructions.cc +++ b/src/cuda-sim/instructions.cc @@ -380,7 +380,7 @@ void atom_callback( void* ptx_inst, void* thd ) ptx_instruction *pI = (ptx_instruction*)ptx_inst; // Check state space - assert( pI->get_space()==GLOBAL_DIRECTIVE ); + assert( pI->get_space()==global_space ); // "Decode" the output type unsigned to_type = pI->get_type(); @@ -640,13 +640,13 @@ void atom_impl( const ptx_instruction *pI, ptx_thread_info *thread ) // atom.space.operation.type d, a, b[, c]; (now read in callback) // Check state space - assert( pI->get_space()==GLOBAL_DIRECTIVE ); + assert( pI->get_space()== global_space ); // get the memory address const operand_info &src1 = pI->src1(); ptx_reg_t src1_data = thread->get_operand_value(src1); - unsigned space = pI->get_space(); + memory_space_t space = pI->get_space(); thread->m_last_effective_address = src1_data.u32; thread->m_last_memory_space = space; @@ -1323,7 +1323,7 @@ void cvta_impl( const ptx_instruction *pI, ptx_thread_info *thread ) const operand_info &dst = pI->dst(); const operand_info &src1 = pI->src1(); - unsigned space = pI->get_space(); + memory_space_t space = pI->get_space(); bool to_non_generic = pI->is_to(); ptx_reg_t from_addr = thread->get_operand_value(src1); @@ -1334,16 +1334,16 @@ void cvta_impl( const ptx_instruction *pI, ptx_thread_info *thread ) if( to_non_generic ) { switch( space ) { - case SHARED_DIRECTIVE: to_addr_hw = generic_to_shared( smid, from_addr_hw ); break; - case LOCAL_DIRECTIVE: to_addr_hw = generic_to_local( smid, hwtid, from_addr_hw ); break; - case GLOBAL_DIRECTIVE: to_addr_hw = generic_to_global(from_addr_hw ); break; + 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 ) { - case SHARED_DIRECTIVE: to_addr_hw = shared_to_generic( smid, from_addr_hw ); break; - case LOCAL_DIRECTIVE: to_addr_hw = local_to_generic( smid, hwtid, from_addr_hw ); break; - case GLOBAL_DIRECTIVE: to_addr_hw = global_to_generic( from_addr_hw ); break; + 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; default: abort(); } } @@ -1434,7 +1434,7 @@ void isspacep_impl( const ptx_instruction *pI, ptx_thread_info *thread ) const operand_info &dst = pI->dst(); const operand_info &src1 = pI->src1(); - unsigned space = pI->get_space(); + memory_space_t space = pI->get_space(); a = thread->get_operand_value(src1); addr_t addr = (addr_t)a.u64; @@ -1442,9 +1442,9 @@ void isspacep_impl( const ptx_instruction *pI, ptx_thread_info *thread ) unsigned hwtid = thread->get_hw_tid(); switch( space ) { - case SHARED_DIRECTIVE: t = isspace_shared( smid, addr ); - case LOCAL_DIRECTIVE: t = isspace_local( smid, hwtid, addr ); - case GLOBAL_DIRECTIVE: t = isspace_global( addr ); + case shared_space: t = isspace_shared( smid, addr ); + case local_space: t = isspace_local( smid, hwtid, addr ); + case global_space: t = isspace_global( addr ); default: abort(); } @@ -1454,26 +1454,30 @@ void isspacep_impl( const ptx_instruction *pI, ptx_thread_info *thread ) thread->set_operand_value(dst,p); } -void decode_space( unsigned &space, ptx_thread_info *thread, memory_space *&mem, addr_t &addr) +void decode_space( memory_space_t &space, ptx_thread_info *thread, memory_space *&mem, addr_t &addr) { unsigned smid = thread->get_hw_sid(); unsigned hwtid = thread->get_hw_tid(); switch ( space ) { - case GLOBAL_DIRECTIVE: mem = g_global_mem; break; - case LOCAL_DIRECTIVE: mem = thread->m_local_mem; break; - case TEX_DIRECTIVE: mem = g_tex_mem; break; - case SURF_DIRECTIVE: mem = g_surf_mem; break; - case PARAM_DIRECTIVE: mem = g_param_mem; break; - case SHARED_DIRECTIVE: mem = thread->m_shared_mem; break; - case CONST_DIRECTIVE: mem = g_global_mem; break; + case global_space: mem = g_global_mem; break; + case local_space: mem = thread->m_local_mem; break; + case tex_space: mem = g_tex_mem; break; + case surf_space: mem = g_surf_mem; break; + case param_space_local_r: + abort(); // finish this + case param_space_local_w: + 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; default: if( thread->get_ptx_version().ver() >= 2.0 ) { // convert generic address to memory space address space = whichspace(addr); switch ( space ) { - case GLOBAL_DIRECTIVE: mem = g_global_mem; addr = generic_to_global(addr); break; - case LOCAL_DIRECTIVE: mem = thread->m_local_mem; addr = generic_to_local(smid,hwtid,addr); break; - case SHARED_DIRECTIVE: mem = thread->m_shared_mem; addr = generic_to_shared(smid,addr); break; + 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; default: abort(); } } else { @@ -1489,7 +1493,7 @@ void ld_impl( const ptx_instruction *pI, ptx_thread_info *thread ) const operand_info &src1 = pI->src1(); ptx_reg_t src1_data = thread->get_operand_value(src1); ptx_reg_t data; - unsigned space = pI->get_space(); + memory_space_t space = pI->get_space(); unsigned vector_spec = pI->get_vector(); unsigned type = pI->get_type(); memory_space *mem = NULL; @@ -2626,7 +2630,7 @@ void st_impl( const ptx_instruction *pI, ptx_thread_info *thread ) const operand_info &src1 = pI->src1(); //may be scalar or vector of regs ptx_reg_t addr_reg = thread->get_operand_value(dst); ptx_reg_t data; - unsigned space = pI->get_space(); + memory_space_t space = pI->get_space(); unsigned vector_spec = pI->get_vector(); unsigned type = pI->get_type(); memory_space *mem = NULL; @@ -3007,7 +3011,7 @@ void tex_impl( const ptx_instruction *pI, ptx_thread_info *thread ) default: assert(0); } - thread->m_last_memory_space = TEX_DIRECTIVE; + thread->m_last_memory_space = tex_space; thread->set_vector_operand_values(dst,data1,data2,data3,data4,4); } diff --git a/src/cuda-sim/ptx.y b/src/cuda-sim/ptx.y index 5711b94..8a897ce 100644 --- a/src/cuda-sim/ptx.y +++ b/src/cuda-sim/ptx.y @@ -248,8 +248,8 @@ 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_DIRECTIVE); } variable_spec identifier_spec { add_function_arg(); } - | REG_DIRECTIVE { add_space_spec(REG_DIRECTIVE); } variable_spec identifier_spec { add_function_arg(); } +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(); } statement_list: directive_statement { add_directive(); } | instruction_statement { add_instruction(); } @@ -309,13 +309,13 @@ space_spec: REG_DIRECTIVE { add_space_spec(REG_DIRECTIVE); } | addressable_spec ; -addressable_spec: CONST_DIRECTIVE { add_space_spec(CONST_DIRECTIVE); } - | GLOBAL_DIRECTIVE { add_space_spec(GLOBAL_DIRECTIVE); } - | LOCAL_DIRECTIVE { add_space_spec(LOCAL_DIRECTIVE); } - | PARAM_DIRECTIVE { add_space_spec(PARAM_DIRECTIVE); } - | SHARED_DIRECTIVE { add_space_spec(SHARED_DIRECTIVE); } - | SURF_DIRECTIVE { add_space_spec(SURF_DIRECTIVE); } - | TEX_DIRECTIVE { add_space_spec(TEX_DIRECTIVE); } +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); } ; type_spec: scalar_type diff --git a/src/cuda-sim/ptx_ir.cc b/src/cuda-sim/ptx_ir.cc index 752dfc5..ac93aa3 100644 --- a/src/cuda-sim/ptx_ir.cc +++ b/src/cuda-sim/ptx_ir.cc @@ -90,7 +90,7 @@ std::map<std::string,symbol_table*> g_sym_name_to_symbol_table; int g_error_detected = 0; // type specifier stuff: -int g_space_spec = -1; +memory_space_t g_space_spec = undefined_space; int g_scalar_type_spec = -1; int g_vector_spec = -1; int g_alignment_spec = -1; @@ -144,7 +144,7 @@ void init_parser() void init_directive_state() { DPRINTF("init_directive_state"); - g_space_spec=-1; + g_space_spec=undefined_space; g_scalar_type_spec=-1; g_vector_spec=-1; g_opcode=-1; @@ -400,7 +400,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident } g_last_symbol = g_current_symbol_table->add_variable(identifier,type,g_filename,ptx_lineno); switch ( g_space_spec ) { - case REG_DIRECTIVE: { + case reg_space: { regnum = g_current_symbol_table->next_reg_num(); int arch_regnum = -1; for (int d = 0; d < strlen(identifier); d++) { @@ -414,7 +414,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident } g_last_symbol->set_regno(regnum, arch_regnum); } break; - case SHARED_DIRECTIVE: + case shared_space: printf("GPGPU-Sim PTX: allocating shared region for \"%s\" from 0x%x to 0x%lx (shared memory space)\n", identifier, g_current_symbol_table->get_shared_next(), @@ -426,7 +426,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident g_last_symbol->set_address( addr+addr_pad ); g_current_symbol_table->alloc_shared( num_bits/8 + addr_pad ); break; - case CONST_DIRECTIVE: + case const_space: if( array_ident == ARRAY_IDENTIFIER_NO_DIM ) { printf("GPGPU-Sim PTX: deferring allocation of constant region for \"%s\" (need size information)\n", identifier ); } else { @@ -448,7 +448,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident assert( g_current_symbol_table != NULL ); g_sym_name_to_symbol_table[ identifier ] = g_current_symbol_table; break; - case GLOBAL_DIRECTIVE: + case global_space: printf("GPGPU-Sim PTX: allocating global region for \"%s\" from 0x%x to 0x%lx (global memory space)\n", identifier, g_current_symbol_table->get_global_next(), @@ -463,7 +463,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident assert( g_current_symbol_table != NULL ); g_sym_name_to_symbol_table[ identifier ] = g_current_symbol_table; break; - case LOCAL_DIRECTIVE: + case local_space: printf("GPGPU-Sim PTX: allocating local region for \"%s\" from 0x%x to 0x%lx (local memory space)\n", identifier, g_current_symbol_table->get_local_next(), @@ -473,7 +473,7 @@ void add_identifier( const char *identifier, int array_dim, unsigned array_ident g_last_symbol->set_address( g_current_symbol_table->get_local_next() ); g_current_symbol_table->alloc_local( num_bits/8 ); break; - case TEX_DIRECTIVE: + case tex_space: printf("GPGPU-Sim PTX: encountered texture directive %s.\n", identifier); break; default: @@ -510,11 +510,20 @@ void add_alignment_spec( int spec ) g_alignment_spec = spec; } -void add_space_spec( int spec ) +void add_space_spec( memory_space_t spec ) { DPRINTF("add_space_spec \"%s\"", g_ptx_token_decode[spec].c_str() ); - parse_assert( g_space_spec == -1, "multiple space specifiers not allowed." ); - g_space_spec = spec; + parse_assert( g_space_spec == undefined_space, "multiple space specifiers not allowed." ); + if( g_space_spec == param_space_unclassified ) { + if( g_func_decl && !g_in_function_definition ) { + if( g_entry_point == 1) + g_space_spec = param_space_kernel; + else + g_space_spec = param_space_local_r; + } else + g_space_spec = param_space_local_w; + } else + g_space_spec = spec; } void add_vector_spec(int spec ) @@ -820,7 +829,7 @@ bool symbol_table::add_function_decl( const char *name, int entry_point, functio return prior_decl; } -type_info *symbol_table::add_type( int space_spec, int scalar_type_spec, int vector_spec, int alignment_spec, int extern_spec ) +type_info *symbol_table::add_type( memory_space_t space_spec, int scalar_type_spec, int vector_spec, int alignment_spec, int extern_spec ) { type_info_key t(space_spec,scalar_type_spec,vector_spec,alignment_spec,extern_spec,0); type_info *pt; diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h index 87a0b14..eaa3919 100644 --- a/src/cuda-sim/ptx_ir.h +++ b/src/cuda-sim/ptx_ir.h @@ -65,6 +65,8 @@ #ifndef ptx_ir_INCLUDED #define ptx_ir_INCLUDED +#include "../abstract_hardware_model.h" + #ifdef __cplusplus #include <cstdlib> @@ -78,35 +80,16 @@ #include "ptx.tab.h" #include "ptx_sim.h" #include "dram_callback.h" - #include "../abstract_hardware_model.h" #include "memory.h" -enum space_type { - undefined, inst_space -}; - - -class addr { /* need this because there are many distinct address spaces (global, local, param, tex, surf, shared) */ -public: - - addr() { m_space=undefined; m_addr = 0;} - void set_space( enum space_type space ); - operator unsigned() { return m_addr;} - -private: - enum space_type m_space; - unsigned m_addr; -}; - - class type_info_key { public: type_info_key() { m_init = false; } - type_info_key( int space_spec, int scalar_type_spec, int vector_spec, int alignment_spec, int extern_spec, int array_dim ) + type_info_key( memory_space_t space_spec, int scalar_type_spec, int vector_spec, int alignment_spec, int extern_spec, int array_dim ) { m_init = true; m_space_spec = space_spec; @@ -116,12 +99,12 @@ public: m_extern_spec = extern_spec; m_array_dim = array_dim; m_is_function = 0; - } + } void set_is_func() { assert(!m_init); m_init = true; - m_space_spec = 0; + m_space_spec = undefined_space; m_scalar_type_spec = 0; m_vector_spec = 0; m_alignment_spec = 0; @@ -135,18 +118,18 @@ public: m_array_dim = array_dim; } - bool is_reg() const { return m_space_spec == REG_DIRECTIVE;} - bool is_param() const { return m_space_spec == PARAM_DIRECTIVE;} - bool is_global() const { return m_space_spec == GLOBAL_DIRECTIVE;} - bool is_local() const { return m_space_spec == LOCAL_DIRECTIVE;} - bool is_shared() const { return m_space_spec == SHARED_DIRECTIVE;} - bool is_const() const { return m_space_spec == CONST_DIRECTIVE;} - bool is_tex() const { return m_space_spec == TEX_DIRECTIVE;} + bool is_reg() const { return m_space_spec == reg_space;} + bool is_param() const { abort(); /*this make sense?*/ return m_space_spec == param_space_kernel;} + 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_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;} private: bool m_init; - int m_space_spec; + memory_space_t m_space_spec; int m_scalar_type_spec; int m_vector_spec; int m_alignment_spec; @@ -325,7 +308,7 @@ public: symbol *add_variable( const char *identifier, const type_info *type, const char *filename, unsigned line ); void add_function( function_info *func ); bool add_function_decl( const char *name, int entry_point, function_info **func_info, symbol_table **symbol_table ); - type_info *add_type( int space_spec, int scalar_type_spec, int vector_spec, int alignment_spec, int extern_spec ); + type_info *add_type( memory_space_t space_spec, int scalar_type_spec, int vector_spec, int alignment_spec, int extern_spec ); type_info *add_type( function_info *func ); type_info *get_array_type( type_info *base_type, unsigned array_dim ); void set_label_address( const symbol *label, unsigned addr ); @@ -687,7 +670,7 @@ public: const operand_info &return_var, const std::list<int> &options, const std::list<int> &scalar_type, - int space_spec, + memory_space_t space_spec, const char *file, unsigned line, const char *source ); @@ -774,7 +757,7 @@ public: return m_return_var.is_valid(); } - unsigned get_space() const { return m_space_spec;} + memory_space_t get_space() const { return m_space_spec;} unsigned get_vector() const { return m_vector_spec;} unsigned get_atomic() const { return m_atomic_spec;} @@ -853,7 +836,7 @@ private: unsigned m_saturation_mode; std::list<int> m_scalar_type; - int m_space_spec; + memory_space_t m_space_spec; int m_geom_spec; int m_vector_spec; int m_atomic_spec; @@ -958,8 +941,7 @@ public: int *vectorin, int *vectorout, int *arch_reg ); - unsigned ptx_get_inst_op( ptx_thread_info *thread ); - void ptx_exec_inst( ptx_thread_info *thd, addr_t *addr, unsigned *space, unsigned *data_size, dram_callback_t* callback, unsigned warp_active_mask ); + void ptx_exec_inst( ptx_thread_info *thd, addr_t *addr, memory_space_t *space, unsigned *data_size, dram_callback_t* callback, unsigned warp_active_mask ); void add_param( const char *name, struct param_t value ) { m_params[ name ] = value; @@ -1157,7 +1139,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(int spec ); + void add_space_spec( memory_space_t spec ); void add_extern_spec(); void add_instruction(); void set_return(); diff --git a/src/cuda-sim/ptx_sim.cc b/src/cuda-sim/ptx_sim.cc index 8998466..269b858 100644 --- a/src/cuda-sim/ptx_sim.cc +++ b/src/cuda-sim/ptx_sim.cc @@ -223,7 +223,7 @@ ptx_thread_info::ptx_thread_info() m_PC=0; m_icount = 0; m_last_effective_address = 0; - m_last_memory_space = 0; + m_last_memory_space = undefined_space; m_branch_taken = 0; m_shared_mem = NULL; m_cta_info = NULL; diff --git a/src/cuda-sim/ptx_sim.h b/src/cuda-sim/ptx_sim.h index c07308e..8a74168 100644 --- a/src/cuda-sim/ptx_sim.h +++ b/src/cuda-sim/ptx_sim.h @@ -310,7 +310,7 @@ public: unsigned get_icount() const { return m_icount;} void set_valid() { m_valid = true;} addr_t last_eaddr() const { return m_last_effective_address;} - unsigned last_space() const { return m_last_memory_space;} + memory_space_t last_space() const { return m_last_memory_space;} dram_callback_t last_callback() const { return m_last_dram_callback;} void set_at_barrier( int barrier_num ) { @@ -427,7 +427,7 @@ public: public: addr_t m_last_effective_address; bool m_branch_taken; - unsigned m_last_memory_space; + memory_space_t m_last_memory_space; dram_callback_t m_last_dram_callback; memory_space *m_shared_mem; memory_space *m_local_mem; @@ -484,7 +484,7 @@ addr_t global_to_generic( addr_t addr ); bool isspace_local( unsigned smid, unsigned hwtid, addr_t addr ); bool isspace_shared( unsigned smid, addr_t addr ); bool isspace_global( addr_t addr ); -unsigned whichspace( addr_t addr ); +memory_space_t whichspace( addr_t addr ); #endif |
