Skip to content

Commit 8000ef8

Browse files
committed
math_brute_force: stop relying on volatile for IsTininessDetectedBeforeRounding
This makes it literally impossible for drivers to constant fold the IsTininessDetectedBeforeRounding kernel. Sure, drivers might have should respect volatile here, but I'm not convinced this is actually required by the spec in a very strict sense, because here there are no side-effects possible in the first place. And as far as I know, constant folding is allowed to give different results than an actual GPU calculation would. In any case, passing the constants via kernel arguments makes this detection more reliable and one doesn't have to wonder why the fma test is failing.
1 parent a406b34 commit 8000ef8

File tree

1 file changed

+20
-3
lines changed
  • test_conformance/math_brute_force

1 file changed

+20
-3
lines changed

test_conformance/math_brute_force/main.cpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -1043,13 +1043,14 @@ int IsTininessDetectedBeforeRounding(void)
10431043
{
10441044
int error;
10451045
const char *kernelSource =
1046-
R"(__kernel void IsTininessDetectedBeforeRounding( __global float *out )
1046+
R"(__kernel void IsTininessDetectedBeforeRounding( __global float *out, float a, float b )
10471047
{
1048-
volatile float a = 0x1.000002p-126f;
1049-
volatile float b = 0x1.fffffcp-1f;
10501048
out[0] = a * b; // product is 0x1.fffffffffff8p-127
10511049
})";
10521050

1051+
float a = 0x1.000002p-126f;
1052+
float b = 0x1.fffffcp-1f;
1053+
10531054
clProgramWrapper query;
10541055
clKernelWrapper kernel;
10551056
error =
@@ -1073,6 +1074,22 @@ int IsTininessDetectedBeforeRounding(void)
10731074
return error;
10741075
}
10751076

1077+
if ((error = clSetKernelArg(kernel, 1, sizeof(a), &a)))
1078+
{
1079+
vlog_error("Error: Unable to set kernel arg to detect how tininess is "
1080+
"detected for the device. Err = %d",
1081+
error);
1082+
return error;
1083+
}
1084+
1085+
if ((error = clSetKernelArg(kernel, 2, sizeof(b), &b)))
1086+
{
1087+
vlog_error("Error: Unable to set kernel arg to detect how tininess is "
1088+
"detected for the device. Err = %d",
1089+
error);
1090+
return error;
1091+
}
1092+
10761093
size_t dim = 1;
10771094
if ((error = clEnqueueNDRangeKernel(gQueue, kernel, 1, NULL, &dim, NULL, 0,
10781095
NULL, NULL)))

0 commit comments

Comments
 (0)