mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-23 07:39:01 +00:00
Remove gTestFastRelaxed Dependencies in Brute Force (#807)
* The global variable `gTestFastRelaxed` has state which is used to control the behaviour of the compiler flag `-cl-fast-relaxed-math` and the precision testing of relaxed, fp32 and fp64 types. This is confusing since the global variable is being set and read in different translation units, making it very difficult to reason about the logic of the brute force framework. It is particular difficult to follow since the global variables is cached and then turned off in the case of fp32 and f64 in order to use the same code path as relaxed testing, after it is then turned back on. * Remove uses of the global variable outside of `main.cpp` (the global variable remains in use within `main.cpp` since it is a command line option and used to turn of relaxed testing completely). Replace all uses of the global variable with boolean `relaxedMode` which is passed as a function paramter but replaces `gTestFastRelaxed` semantically.
This commit is contained in:
@@ -21,15 +21,19 @@
|
||||
#define CORRECTLY_ROUNDED 0
|
||||
#define FLUSHED 1
|
||||
|
||||
int TestFunc_Float_Float_Float_Float(const Func *f, MTdata);
|
||||
int TestFunc_Double_Double_Double_Double(const Func *f, MTdata);
|
||||
int TestFunc_Float_Float_Float_Float(const Func *f, MTdata, bool relaxedMode);
|
||||
int TestFunc_Double_Double_Double_Double(const Func *f, MTdata,
|
||||
bool relaxedMode);
|
||||
|
||||
extern const vtbl _ternary = { "ternary", TestFunc_Float_Float_Float_Float,
|
||||
TestFunc_Double_Double_Double_Double };
|
||||
|
||||
static int BuildKernel( const char *name, int vectorSize, cl_kernel *k, cl_program *p );
|
||||
static int BuildKernelDouble( const char *name, int vectorSize, cl_kernel *k, cl_program *p );
|
||||
static int BuildKernel( const char *name, int vectorSize, cl_kernel *k, cl_program *p )
|
||||
static int BuildKernel(const char *name, int vectorSize, cl_kernel *k,
|
||||
cl_program *p, bool relaxedMode);
|
||||
static int BuildKernelDouble(const char *name, int vectorSize, cl_kernel *k,
|
||||
cl_program *p, bool relaxedMode);
|
||||
static int BuildKernel(const char *name, int vectorSize, cl_kernel *k,
|
||||
cl_program *p, bool relaxedMode)
|
||||
{
|
||||
const char *c[] = {
|
||||
"__kernel void math_kernel", sizeNames[vectorSize], "( __global float", sizeNames[vectorSize], "* out, __global float", sizeNames[vectorSize], "* in1, __global float", sizeNames[vectorSize], "* in2, __global float", sizeNames[vectorSize], "* in3 )\n"
|
||||
@@ -93,11 +97,11 @@ static int BuildKernel( const char *name, int vectorSize, cl_kernel *k, cl_progr
|
||||
char testName[32];
|
||||
snprintf( testName, sizeof( testName ) -1, "math_kernel%s", sizeNames[vectorSize] );
|
||||
|
||||
return MakeKernel(kern, (cl_uint) kernSize, testName, k, p);
|
||||
|
||||
return MakeKernel(kern, (cl_uint)kernSize, testName, k, p, relaxedMode);
|
||||
}
|
||||
|
||||
static int BuildKernelDouble( const char *name, int vectorSize, cl_kernel *k, cl_program *p )
|
||||
static int BuildKernelDouble(const char *name, int vectorSize, cl_kernel *k,
|
||||
cl_program *p, bool relaxedMode)
|
||||
{
|
||||
const char *c[] = {
|
||||
"#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n",
|
||||
@@ -163,8 +167,7 @@ static int BuildKernelDouble( const char *name, int vectorSize, cl_kernel *k, cl
|
||||
char testName[32];
|
||||
snprintf( testName, sizeof( testName ) -1, "math_kernel%s", sizeNames[vectorSize] );
|
||||
|
||||
return MakeKernel(kern, (cl_uint) kernSize, testName, k, p);
|
||||
|
||||
return MakeKernel(kern, (cl_uint)kernSize, testName, k, p, relaxedMode);
|
||||
}
|
||||
|
||||
typedef struct BuildKernelInfo
|
||||
@@ -173,6 +176,7 @@ typedef struct BuildKernelInfo
|
||||
cl_kernel *kernels;
|
||||
cl_program *programs;
|
||||
const char *nameInCode;
|
||||
bool relaxedMode; // Whether to build with -cl-fast-relaxed-math.
|
||||
}BuildKernelInfo;
|
||||
|
||||
static cl_int BuildKernel_FloatFn( cl_uint job_id, cl_uint thread_id UNUSED, void *p );
|
||||
@@ -180,7 +184,8 @@ static cl_int BuildKernel_FloatFn( cl_uint job_id, cl_uint thread_id UNUSED, voi
|
||||
{
|
||||
BuildKernelInfo *info = (BuildKernelInfo*) p;
|
||||
cl_uint i = info->offset + job_id;
|
||||
return BuildKernel( info->nameInCode, i, info->kernels + i, info->programs + i );
|
||||
return BuildKernel(info->nameInCode, i, info->kernels + i,
|
||||
info->programs + i, info->relaxedMode);
|
||||
}
|
||||
|
||||
static cl_int BuildKernel_DoubleFn( cl_uint job_id, cl_uint thread_id UNUSED, void *p );
|
||||
@@ -188,7 +193,8 @@ static cl_int BuildKernel_DoubleFn( cl_uint job_id, cl_uint thread_id UNUSED, vo
|
||||
{
|
||||
BuildKernelInfo *info = (BuildKernelInfo*) p;
|
||||
cl_uint i = info->offset + job_id;
|
||||
return BuildKernelDouble( info->nameInCode, i, info->kernels + i, info->programs + i );
|
||||
return BuildKernelDouble(info->nameInCode, i, info->kernels + i,
|
||||
info->programs + i, info->relaxedMode);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +214,7 @@ static const float specialValuesFloat[] = {
|
||||
static size_t specialValuesFloatCount = sizeof( specialValuesFloat ) / sizeof( specialValuesFloat[0] );
|
||||
|
||||
|
||||
int TestFunc_Float_Float_Float_Float(const Func *f, MTdata d)
|
||||
int TestFunc_Float_Float_Float_Float(const Func *f, MTdata d, bool relaxedMode)
|
||||
{
|
||||
uint64_t i;
|
||||
uint32_t j, k;
|
||||
@@ -227,7 +233,7 @@ int TestFunc_Float_Float_Float_Float(const Func *f, MTdata d)
|
||||
cl_uchar overflow[BUFFER_SIZE / sizeof( float )];
|
||||
float float_ulps;
|
||||
|
||||
logFunctionInfo(f->name,sizeof(cl_float),gTestFastRelaxed);
|
||||
logFunctionInfo(f->name, sizeof(cl_float), relaxedMode);
|
||||
if( gWimpyMode )
|
||||
{
|
||||
step = (1ULL<<32) * gWimpyReductionFactor / (512);
|
||||
@@ -239,7 +245,8 @@ int TestFunc_Float_Float_Float_Float(const Func *f, MTdata d)
|
||||
float_ulps = f->float_ulps;
|
||||
|
||||
// Init the kernels
|
||||
BuildKernelInfo build_info = { gMinVectorSizeIndex, kernels, programs, f->nameInCode };
|
||||
BuildKernelInfo build_info = { gMinVectorSizeIndex, kernels, programs,
|
||||
f->nameInCode, relaxedMode };
|
||||
if( (error = ThreadPool_Do( BuildKernel_FloatFn, gMaxVectorSizeIndex - gMinVectorSizeIndex, &build_info ) ))
|
||||
return error;
|
||||
/*
|
||||
@@ -851,7 +858,8 @@ static const double specialValuesDouble[] = {
|
||||
static const size_t specialValuesDoubleCount = sizeof( specialValuesDouble ) / sizeof( specialValuesDouble[0] );
|
||||
|
||||
|
||||
int TestFunc_Double_Double_Double_Double(const Func *f, MTdata d)
|
||||
int TestFunc_Double_Double_Double_Double(const Func *f, MTdata d,
|
||||
bool relaxedMode)
|
||||
{
|
||||
uint64_t i;
|
||||
uint32_t j, k;
|
||||
@@ -863,7 +871,7 @@ int TestFunc_Double_Double_Double_Double(const Func *f, MTdata d)
|
||||
double maxErrorVal = 0.0f;
|
||||
double maxErrorVal2 = 0.0f;
|
||||
double maxErrorVal3 = 0.0f;
|
||||
logFunctionInfo(f->name,sizeof(cl_double),gTestFastRelaxed);
|
||||
logFunctionInfo(f->name, sizeof(cl_double), relaxedMode);
|
||||
|
||||
size_t bufferSize = (gWimpyMode)? gWimpyBufferSize: BUFFER_SIZE;
|
||||
uint64_t step = bufferSize / sizeof( double );
|
||||
@@ -875,7 +883,8 @@ int TestFunc_Double_Double_Double_Double(const Func *f, MTdata d)
|
||||
Force64BitFPUPrecision();
|
||||
|
||||
// Init the kernels
|
||||
BuildKernelInfo build_info = { gMinVectorSizeIndex, kernels, programs, f->nameInCode };
|
||||
BuildKernelInfo build_info = { gMinVectorSizeIndex, kernels, programs,
|
||||
f->nameInCode, relaxedMode };
|
||||
if( (error = ThreadPool_Do( BuildKernel_DoubleFn,
|
||||
gMaxVectorSizeIndex - gMinVectorSizeIndex,
|
||||
&build_info ) ))
|
||||
|
||||
Reference in New Issue
Block a user