diff options
| author | Ahmed El-Shafiey <[email protected]> | 2012-08-14 13:53:25 -0800 |
|---|---|---|
| committer | Andrew Boktor <[email protected]> | 2014-08-14 13:48:54 -0700 |
| commit | 0ce06988a6a13f9a8f48f2230b1b9727ee86081e (patch) | |
| tree | 08a4f172a71b3a9b0de5bea1b1c74f38d97036cb | |
| parent | 8f2b4a6f61ef30d86b9bae7c92ed62f223550a76 (diff) | |
Fixing bugs 169, 170, 171
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 13761]
| -rw-r--r-- | CHANGES | 5 | ||||
| -rw-r--r-- | cuobjdump_to_ptxplus/cuobjdumpInst.cc | 41 | ||||
| -rw-r--r-- | cuobjdump_to_ptxplus/cuobjdumpInstList.cc | 5 | ||||
| -rw-r--r-- | cuobjdump_to_ptxplus/ptx_parser.h | 1 | ||||
| -rw-r--r-- | src/cuda-sim/cuda-sim.cc | 3 | ||||
| -rw-r--r-- | src/cuda-sim/instructions.cc | 4 | ||||
| -rw-r--r-- | src/cuda-sim/ptx.y | 1 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_ir.h | 20 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_parser.cc | 17 | ||||
| -rw-r--r-- | src/cuda-sim/ptx_parser.h | 2 |
10 files changed, 76 insertions, 23 deletions
@@ -10,6 +10,11 @@ Version 3.1.1+edits (development branch) versus 3.1.1 - Adding support for atomic operations with generic memory space. Before this, atomic operations can only work on global memory space. (Bug #14 external) + - Fixed a bug in conversion to ptxplus that was causing local memory store + or load instruction to be ignored. + - Adding support for direct addressing using immediate values for the load + and store instructions. + - Fixed a bug that was causing inconsistency in local memory address calculations Version 3.1.1 versus 3.1.0 - Add checks to top level makefile to ensure setup_environment is run and checks to diff --git a/cuobjdump_to_ptxplus/cuobjdumpInst.cc b/cuobjdump_to_ptxplus/cuobjdumpInst.cc index dd9bb99..22dbdd3 100644 --- a/cuobjdump_to_ptxplus/cuobjdumpInst.cc +++ b/cuobjdump_to_ptxplus/cuobjdumpInst.cc @@ -539,7 +539,8 @@ void cuobjdumpInst::printCuobjdumpOperand(std::string currentPiece, std::string (m_base == "R2G") || (m_base == "GLD") || (m_base == "GST") || - (m_base == "LST") ))) { + (m_base == "LST") || + (m_base == "LLD")))) { std::string modsub = mod.substr(1); int regNumInt = atoi(modsub.c_str()); std::stringstream temp; @@ -576,8 +577,7 @@ void cuobjdumpInst::printCuobjdumpOperand(std::string currentPiece, std::string std::string modsub2; std::string modsub3; modsub = mod.c_str(); - int localFlag = 0; - + int const_sharedFlag =0; if(mod.find("global14") != std::string::npos) { //Those instructions don't need the dereferencing done by g [*] if( base == "GRED" || @@ -590,15 +590,23 @@ void cuobjdumpInst::printCuobjdumpOperand(std::string currentPiece, std::string } else if(mod[0]=='g') { //Shared memory output("s["); + const_sharedFlag=1; } else if(mod.find("local") != std::string::npos) { - modsub3 = modsub.substr(4, modsub.length()-10); - output(modsub3.c_str()); + if((base=="LST")|| + (base=="LLD")) output("["); - localFlag = 1; + else + output("l["); + //modsub3 = modsub.substr(4, modsub.length()-10); + //output(modsub3.c_str()); + //output("["); + //localFlag = 1; } else if(mod.substr(0,9) == "constant1") { output(modsub.substr(0, modsub.find_first_of("[]")+1).c_str()); + const_sharedFlag=1; } else if(mod.substr(0,9)=="constant0"){ output("constant0["); + const_sharedFlag=1; } else { printf("Unidentified modifier: %s\n", mod.c_str()); assert(0); @@ -636,14 +644,17 @@ void cuobjdumpInst::printCuobjdumpOperand(std::string currentPiece, std::string std::stringstream hexStringConvert; hexStringConvert << std::hex << modsub2; hexStringConvert >> addrValue; - unsigned chunksize = 4; - if ( this->m_typeModifiers->size()>0 && - ( m_typeModifiers->back() == ".S16" || - m_typeModifiers->back() == ".U16")) chunksize = 2; - if ( this->m_typeModifiers->size()>0 && - ( m_typeModifiers->back() == ".U8" || - m_typeModifiers->back() == ".S8")) chunksize = 1; - addrValue = addrValue*chunksize; + if(const_sharedFlag == 1) + { + unsigned chunksize = 4; + if ( this->m_typeModifiers->size()>0 && + ( m_typeModifiers->back() == ".S16" || + m_typeModifiers->back() == ".U16")) chunksize = 2; + if ( this->m_typeModifiers->size()>0 && + ( m_typeModifiers->back() == ".U8" || + m_typeModifiers->back() == ".S8")) chunksize = 1; + addrValue = addrValue*chunksize; + } char outputHex[10]; sprintf(outputHex, "%x", addrValue); std::stringstream outputhex; @@ -669,7 +680,7 @@ void cuobjdumpInst::printCuobjdumpOperand(std::string currentPiece, std::string hexStringConvert << std::hex << modsub; hexStringConvert >> addrValue; - if(localFlag == 0) + if(const_sharedFlag == 1) { unsigned chunksize = 4; if ( m_typeModifiers->size()>0 && diff --git a/cuobjdump_to_ptxplus/cuobjdumpInstList.cc b/cuobjdump_to_ptxplus/cuobjdumpInstList.cc index fabc396..d3ebd9a 100644 --- a/cuobjdump_to_ptxplus/cuobjdumpInstList.cc +++ b/cuobjdump_to_ptxplus/cuobjdumpInstList.cc @@ -350,7 +350,7 @@ void cuobjdumpInstList::addCuobjdumpRegister(std::string reg, bool lo) (typeModifiers->front() == ".S64") && ((baseInst == "G2R")||(baseInst == "R2G")|| (baseInst == "GLD")||(baseInst == "GST")|| - (baseInst == "LST")))) + (baseInst == "LST")|| (baseInst == "LLD")))) { vectorFlag = 64; } @@ -426,6 +426,7 @@ void cuobjdumpInstList::addCuobjdumpMemoryOperand(std::string mem, int memType) } // Local memory + /* if(memType == 3) { std::stringstream out; printf("Trying to find lmem for: %s\n", m_entryList.back().m_entryName.c_str()); @@ -434,7 +435,7 @@ void cuobjdumpInstList::addCuobjdumpMemoryOperand(std::string mem, int memType) out << "l" << kernellmemmap[m_entryList.back().m_entryName];// << mem; mem = out.str(); } - + */ // Add the memory operand to instruction operand list char* memName = new char [strlen(mem.c_str())+1]; strcpy(memName, mem.c_str()); diff --git a/cuobjdump_to_ptxplus/ptx_parser.h b/cuobjdump_to_ptxplus/ptx_parser.h index c6d7027..ce77c2f 100644 --- a/cuobjdump_to_ptxplus/ptx_parser.h +++ b/cuobjdump_to_ptxplus/ptx_parser.h @@ -90,6 +90,7 @@ void add_pred( const char *a, int b, int c ) {DPRINTF(" ");} void add_scalar_operand( const char *a ) {DPRINTF("%s", a);} void add_neg_pred_operand( const char *a ) {DPRINTF(" ");} void add_address_operand( const char *a, int b ) {DPRINTF("%s", a);} +void add_address_operand2( int b ) {DPRINTF(" ");} void change_operand_lohi( int a ) {DPRINTF(" ");} void change_double_operand_type( int a ) {DPRINTF(" ");} void change_operand_neg( ) {DPRINTF(" ");} diff --git a/src/cuda-sim/cuda-sim.cc b/src/cuda-sim/cuda-sim.cc index 4cad472..e6677fa 100644 --- a/src/cuda-sim/cuda-sim.cc +++ b/src/cuda-sim/cuda-sim.cc @@ -813,6 +813,9 @@ void ptx_instruction::pre_decode() // TODO: first address register in $r1+=$r2 should be an output register as well } } + else if(o.is_immediate_address()){ + + } // Regular PTX operand else if (o.get_symbol()->type()->get_key().is_reg()) { // Memory operand contains a register ar1 = o.reg_num(); diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc index a7685aa..237bfd5 100644 --- a/src/cuda-sim/instructions.cc +++ b/src/cuda-sim/instructions.cc @@ -106,7 +106,9 @@ ptx_reg_t ptx_thread_info::get_operand_value( const operand_info &op, operand_in result = get_reg( op.get_symbol() ); } else if ( op.is_builtin()) { result = get_builtin( op.get_int(), op.get_addr_offset() ); - } else if ( op.is_memory_operand() ) { + } else if(op.is_immediate_address()){ + result = op.get_addr_offset(); + } else if ( op.is_memory_operand() ) { // a few options here... const symbol *sym = op.get_symbol(); const type_info *type = sym->type(); diff --git a/src/cuda-sim/ptx.y b/src/cuda-sim/ptx.y index 8b65796..2c01a70 100644 --- a/src/cuda-sim/ptx.y +++ b/src/cuda-sim/ptx.y @@ -527,6 +527,7 @@ address_expression: IDENTIFIER { add_address_operand($1,0); } | IDENTIFIER LO_OPTION { add_address_operand($1,0); change_operand_lohi(1);} | IDENTIFIER HI_OPTION { add_address_operand($1,0); change_operand_lohi(2); } | IDENTIFIER PLUS INT_OPERAND { add_address_operand($1,$3); } + | INT_OPERAND { add_address_operand2($1); } ; %% diff --git a/src/cuda-sim/ptx_ir.h b/src/cuda-sim/ptx_ir.h index 15c6743..4078e6b 100644 --- a/src/cuda-sim/ptx_ir.h +++ b/src/cuda-sim/ptx_ir.h @@ -342,6 +342,7 @@ public: m_const_mem_offset = 0; m_uid = get_uid(); m_valid = false; + m_immediate_address=false; } operand_info( const symbol *addr ) { @@ -376,6 +377,7 @@ public: m_vector = false; m_neg_pred = false; m_is_return_var = false; + m_immediate_address=false; } operand_info( const symbol *addr1, const symbol *addr2 ) { @@ -396,6 +398,7 @@ public: m_vector = false; m_neg_pred = false; m_is_return_var = false; + m_immediate_address=false; } operand_info( int builtin_id, int dim_mod ) { @@ -412,6 +415,7 @@ public: m_addr_offset = dim_mod; m_neg_pred = false; m_is_return_var = false; + m_immediate_address=false; } operand_info( const symbol *addr, int offset ) { @@ -428,6 +432,7 @@ public: m_addr_offset = offset; m_neg_pred = false; m_is_return_var = false; + m_immediate_address=false; } operand_info( unsigned x ) { @@ -441,9 +446,10 @@ public: m_vector = false; m_type = unsigned_t; m_value.m_unsigned = x; - m_addr_offset = 0; + m_addr_offset = x; m_neg_pred = false; m_is_return_var = false; + m_immediate_address=true; } operand_info( int x ) { @@ -460,6 +466,7 @@ public: m_addr_offset = 0; m_neg_pred = false; m_is_return_var = false; + m_immediate_address=false; } operand_info( float x ) { @@ -476,6 +483,7 @@ public: m_addr_offset = 0; m_neg_pred = false; m_is_return_var = false; + m_immediate_address=false; } operand_info( double x ) { @@ -492,6 +500,7 @@ public: m_addr_offset = 0; m_neg_pred = false; m_is_return_var = false; + m_immediate_address=false; } operand_info( const symbol *s1, const symbol *s2, const symbol *s3, const symbol *s4 ) { @@ -512,11 +521,12 @@ public: m_addr_offset = 0; m_neg_pred = false; m_is_return_var = false; + m_immediate_address=false; } void make_memory_operand() { m_type = memory_t;} void set_return() { m_is_return_var = true; } - + void set_immediate_addr() {m_immediate_address=true;} const std::string &name() const { assert( m_type == symbolic_t || m_type == reg_t || m_type == address_t || m_type == memory_t || m_type == label_t); @@ -606,6 +616,10 @@ public: return (m_addr_space!=undefined_space); } + bool is_immediate_address() const { + return m_immediate_address; + } + bool is_literal() const { return m_type == int_t || m_type == float_op_t || m_type == double_op_t || @@ -678,7 +692,7 @@ private: bool m_valid; bool m_vector; enum operand_type m_type; - + bool m_immediate_address; enum _memory_space_t m_addr_space; int m_operand_lohi; int m_double_operand_type; diff --git a/src/cuda-sim/ptx_parser.cc b/src/cuda-sim/ptx_parser.cc index cc97b72..76d9a9c 100644 --- a/src/cuda-sim/ptx_parser.cc +++ b/src/cuda-sim/ptx_parser.cc @@ -689,8 +689,8 @@ void change_memory_addr_space(const char *identifier) if(!strcmp(l, "l")) { g_operands.back().set_addr_space(local_space); - parse_assert(g_current_symbol_table->lookup(identifier) != NULL, "Local memory segment was not defined."); - g_operands.back().set_const_mem_offset(g_current_symbol_table->lookup(identifier)->get_address()); + //parse_assert(g_current_symbol_table->lookup(identifier) != NULL, "Local memory segment was not defined."); + //g_operands.back().set_const_mem_offset(g_current_symbol_table->lookup(identifier)->get_address()); recognizedType = true; } @@ -711,6 +711,13 @@ void change_operand_lohi( int lohi ) } +void set_immediate_operand_type () +{ + DPRINTF("set_immediate_operand_type"); + assert( !g_operands.empty() ); + g_operands.back().set_immediate_addr(); +} + void change_double_operand_type( int operand_type ) { /* @@ -809,6 +816,12 @@ void add_address_operand( const char *identifier, int offset ) g_operands.push_back( operand_info(s,offset) ); } +void add_address_operand2( int offset ) +{ + DPRINTF("add_address_operand"); + g_operands.push_back( operand_info((unsigned)offset) ); +} + void add_array_initializer() { g_last_symbol->add_initializer(g_operands); diff --git a/src/cuda-sim/ptx_parser.h b/src/cuda-sim/ptx_parser.h index 561fd74..57d763e 100644 --- a/src/cuda-sim/ptx_parser.h +++ b/src/cuda-sim/ptx_parser.h @@ -64,6 +64,7 @@ void add_literal_int( int value ); void add_literal_float( float value ); void add_literal_double( double value ); void add_address_operand( const char *identifier, int offset ); +void add_address_operand2( int offset ); void add_label( const char *idenfiier ); void add_vector_spec(int spec ); void add_space_spec( enum _memory_space_t spec, int value ); @@ -89,6 +90,7 @@ void change_memory_addr_space( const char *identifier ); void change_operand_lohi( int lohi ); void change_double_operand_type( int addr_type ); void change_operand_neg( ); +void set_immediate_operand_type( ); void version_header(double a); #ifdef __cplusplus } |
