Fix hipTestFMA to support older compiler
The older compiler does not promote integral
arguments to double, instead it uses float.
This patch tries to support the old compiler
headers, and also the newer one.
Change-Id: I01e0b96a82ecddc6230cb5baf2573a318b25445b
[ROCm/hip commit: 09a1c22208]
This commit is contained in:
committed by
Aaron En Ye Shi
parent
a2539f0342
commit
e2f8d46749
@@ -43,19 +43,38 @@ THE SOFTWARE.
|
||||
double doubleResult = fma(d, d, 3.0);
|
||||
Check(floatResult != doubleResult);
|
||||
|
||||
// To align with libcxx, if any argument has integral type,
|
||||
// it is cast to double.
|
||||
// Check type promotes to double.
|
||||
Check(fma(f, f, 3) == doubleResult);
|
||||
Check(fma(f, f, (char)3) == doubleResult);
|
||||
Check(fma(f, f, (unsigned char)3) == doubleResult);
|
||||
Check(fma(f, f, (short)3) == doubleResult);
|
||||
Check(fma(f, f, (unsigned short)3) == doubleResult);
|
||||
Check(fma(f, f, (int)3) == doubleResult);
|
||||
Check(fma(f, f, (unsigned int)3) == doubleResult);
|
||||
Check(fma(f, f, (long)3) == doubleResult);
|
||||
Check(fma(f, f, (unsigned long)3) == doubleResult);
|
||||
Check(fma(f, f, true) == fma((double)f, (double)f, 1.0));
|
||||
if(sizeof(decltype(fma(f, f, 3))) == 8) {
|
||||
// To align with libcxx, if any argument has integral type,
|
||||
// it is cast to double.
|
||||
// Check type promotes to double.
|
||||
Check(fma(f, f, 3) == doubleResult);
|
||||
Check(fma(f, f, (char)3) == doubleResult);
|
||||
Check(fma(f, f, (unsigned char)3) == doubleResult);
|
||||
Check(fma(f, f, (short)3) == doubleResult);
|
||||
Check(fma(f, f, (unsigned short)3) == doubleResult);
|
||||
Check(fma(f, f, (int)3) == doubleResult);
|
||||
Check(fma(f, f, (unsigned int)3) == doubleResult);
|
||||
Check(fma(f, f, (long)3) == doubleResult);
|
||||
Check(fma(f, f, (unsigned long)3) == doubleResult);
|
||||
Check(fma(f, f, true) == fma((double)f, (double)f, 1.0));
|
||||
} else if(sizeof(decltype(fma(f, f, 3))) == 4) {
|
||||
// Previous HIP headers returns float type.
|
||||
// Delete this to support backwards compatibility.
|
||||
// check promote to float.
|
||||
Check(fma(f, f, 3) == floatResult);
|
||||
Check(fma(f, f, (char)3) == floatResult);
|
||||
Check(fma(f, f, (unsigned char)3) == floatResult);
|
||||
Check(fma(f, f, (short)3) == floatResult);
|
||||
Check(fma(f, f, (unsigned short)3) == floatResult);
|
||||
Check(fma(f, f, (int)3) == floatResult);
|
||||
Check(fma(f, f, (unsigned int)3) == floatResult);
|
||||
Check(fma(f, f, (long)3) == floatResult);
|
||||
Check(fma(f, f, (unsigned long)3) == floatResult);
|
||||
Check(fma(f, f, true) == fma(f, f, 1.0f));
|
||||
} else {
|
||||
assert(0 && "Invalid fma return type.");
|
||||
}
|
||||
|
||||
Check(fma(d, (double)f, 3) == doubleResult);
|
||||
Check(fma(d, (double)f, (char)3) == doubleResult);
|
||||
Check(fma(d, (double)f, (unsigned char)3) == doubleResult);
|
||||
|
||||
Reference in New Issue
Block a user