summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew M. B. Boktor <[email protected]>2012-07-10 23:00:30 -0800
committerAndrew Boktor <[email protected]>2014-08-14 13:47:33 -0700
commitdc45f0ec4b16144c248fb86acc905fbb5b627300 (patch)
tree9a67669f23b30b79602c94c43190fdd7435aa74a
parent6f99ffb9b171495df7ef0725f8a8cbffb8d9591c (diff)
Fix for bug #154-internal and #8-external
Adding support for double destination to mad instruction Fixing broken madp instruction Adding a patch to cuobjdump_to_ptxplus to work around the C3 problem (Documented in bug #154 internal). [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 13349]
-rw-r--r--CHANGES1
-rw-r--r--cuobjdump_to_ptxplus/cuobjdumpInst.cc16
-rw-r--r--src/cuda-sim/instructions.cc10
-rw-r--r--src/cuda-sim/opcodes.def2
-rw-r--r--src/cuda-sim/ptx_parser.cc2
5 files changed, 25 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index e2e7f68..54b8380 100644
--- a/CHANGES
+++ b/CHANGES
@@ -38,6 +38,7 @@ Version 3.1.0+edits (development branch) versus 3.1.0
The same thing happened when using a prebuilt ptx file through
PTX_SIM_USE_PTX_FILE - It always wanted to
load the same ptx file even though there should have been more than one.
+ - Fixed bug that caused $p3 to be used before it was initialized.
Version 3.1.0 versus 3.0.2
- Support for CUDA 4.0 for both PTX and PTXPlus.
diff --git a/cuobjdump_to_ptxplus/cuobjdumpInst.cc b/cuobjdump_to_ptxplus/cuobjdumpInst.cc
index 2bdac6d..b276c04 100644
--- a/cuobjdump_to_ptxplus/cuobjdumpInst.cc
+++ b/cuobjdump_to_ptxplus/cuobjdumpInst.cc
@@ -1228,8 +1228,20 @@ void cuobjdumpInst::printCuobjdumpPtxPlus(std::list<std::string> labelList, std:
}
else if(m_base == "IMAD")
{
- printCuobjdumpPredicate();
- output("mad.wide");
+ //Patching the C3 problem
+ if(m_predicate->size() > 0 &&
+ m_predicate->front() == "C3" &&
+ m_operands->back()[0] == '-'){
+ m_predicate->clear();
+ std::string op = m_operands->back();
+ m_operands->pop_back();
+ m_operands->push_back(op.substr(1));
+ m_operands->push_back("C1");
+ output("madp.wide");
+ } else {
+ printCuobjdumpPredicate();
+ output("mad.wide");
+ }
printCuobjdumpBaseModifiers();
if(m_typeModifiers->size() == 0)
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index def0c55..37e5d00 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -2261,6 +2261,9 @@ void mad_def( const ptx_instruction *pI, ptx_thread_info *thread, bool use_carry
const operand_info &src3 = pI->src3();
ptx_reg_t d, t;
+ int carry=0;
+ int overflow=0;
+
unsigned i_type = pI->get_type();
ptx_reg_t a = thread->get_operand_value(src1, dst, i_type, thread, 1);
ptx_reg_t b = thread->get_operand_value(src2, dst, i_type, thread, 1);
@@ -2272,7 +2275,8 @@ void mad_def( const ptx_instruction *pI, ptx_thread_info *thread, bool use_carry
if (use_carry) {
const operand_info &carry = pI->operand_lookup(4);
carry_bit = thread->get_operand_value(carry, dst, PRED_TYPE, thread, 0);
- carry_bit.pred &= 0x4;
+ carry_bit.pred &= 0x4;
+ carry_bit.pred >>=2;
}
unsigned rounding_mode = pI->rounding_mode();
@@ -2284,6 +2288,7 @@ void mad_def( const ptx_instruction *pI, ptx_thread_info *thread, bool use_carry
else if ( pI->is_hi() ) d.s16 = (t.s32>>16) + c.s16 + carry_bit.pred;
else if ( pI->is_lo() ) d.s16 = t.s16 + c.s16 + carry_bit.pred;
else assert(0);
+ carry = ((long long int)(t.s32 + c.s32 + carry_bit.pred)&0x100000000)>>32;
break;
case S32_TYPE:
t.s64 = a.s32 * b.s32;
@@ -2306,6 +2311,7 @@ void mad_def( const ptx_instruction *pI, ptx_thread_info *thread, bool use_carry
else if ( pI->is_hi() ) d.u16 = (t.u32 + c.u16 + carry_bit.pred)>>16;
else if ( pI->is_lo() ) d.u16 = t.u16 + c.u16 + carry_bit.pred;
else assert(0);
+ carry = ((long long int)((long long int)t.u32 + c.u32 + carry_bit.pred)&0x100000000)>>32;
break;
case U32_TYPE:
t.u64 = a.u32 * b.u32;
@@ -2361,7 +2367,7 @@ void mad_def( const ptx_instruction *pI, ptx_thread_info *thread, bool use_carry
assert(0);
break;
}
- thread->set_operand_value(dst, d, i_type, thread, pI);
+ thread->set_operand_value(dst, d, i_type, thread, pI, overflow, carry);
}
bool isNaN(float x)
diff --git a/src/cuda-sim/opcodes.def b/src/cuda-sim/opcodes.def
index 46e6d94..0087d1e 100644
--- a/src/cuda-sim/opcodes.def
+++ b/src/cuda-sim/opcodes.def
@@ -68,7 +68,7 @@ OP_DEF(LDU_OP,ldu_impl,"ldu",1,5)
OP_DEF(LG2_OP,lg2_impl,"lg2",1,4)
OP_DEF(MAD24_OP,mad24_impl,"mad24",1,2)
OP_DEF(MAD_OP,mad_impl,"mad",1,2)
-OP_DEF(MADP_OP,mad_impl,"mad",1,2)
+OP_DEF(MADP_OP,madp_impl,"madp",1,2)
OP_DEF(MAX_OP,max_impl,"max",1,1)
OP_DEF(MEMBAR_OP,membar_impl,"membar",1,3)
OP_DEF(MIN_OP,min_impl,"min",1,1)
diff --git a/src/cuda-sim/ptx_parser.cc b/src/cuda-sim/ptx_parser.cc
index 308405a..257da1a 100644
--- a/src/cuda-sim/ptx_parser.cc
+++ b/src/cuda-sim/ptx_parser.cc
@@ -732,7 +732,7 @@ void change_double_operand_type( int operand_type )
else
g_operands.back().set_double_operand_type(-2);
} else if( operand_type == -3 ) {
- if(g_opcode == SET_OP)
+ if(g_opcode == SET_OP || g_opcode == MAD_OP)
g_operands.back().set_double_operand_type(operand_type);
else
parse_assert(0, "Error: Unsupported use of double destination operand.");