mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-23 23:49:02 +00:00
Reduce difference between files in math_brute_force (#1138)
* Reduce differences between files This will help reduce code duplication is future commits. Some code is moved around, some variables are renamed and some statements are slightly altered to reduce differences between files in math_brute_force, yet the semantics remains the same. The differences were identified using n-way diffs. Many differences remain however. Signed-off-by: Marco Antognini <marco.antognini@arm.com> * Workaround clang-format limitation Introduces some insignificant spaces to force clang-format to reduce the indentation and reduce differences between files. Signed-off-by: Marco Antognini <marco.antognini@arm.com>
This commit is contained in:
@@ -34,13 +34,14 @@ static int BuildKernel(const char *name, int vectorSize, cl_uint kernel_count,
|
||||
sizeNames[vectorSize],
|
||||
"* out, __global float",
|
||||
sizeNames[vectorSize],
|
||||
"* in)\n"
|
||||
"* in )\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" out[i] = ",
|
||||
name,
|
||||
"( in[i] );\n"
|
||||
"}\n" };
|
||||
|
||||
const char *c3[] = {
|
||||
"__kernel void math_kernel",
|
||||
sizeNames[vectorSize],
|
||||
@@ -115,7 +116,7 @@ static int BuildKernelDouble(const char *name, int vectorSize,
|
||||
sizeNames[vectorSize],
|
||||
"* out, __global double",
|
||||
sizeNames[vectorSize],
|
||||
"* in)\n"
|
||||
"* in )\n"
|
||||
"{\n"
|
||||
" int i = get_global_id(0);\n"
|
||||
" out[i] = ",
|
||||
@@ -178,7 +179,6 @@ static int BuildKernelDouble(const char *name, int vectorSize,
|
||||
kernSize = sizeof(c3) / sizeof(c3[0]);
|
||||
}
|
||||
|
||||
|
||||
char testName[32];
|
||||
snprintf(testName, sizeof(testName) - 1, "math_kernel%s",
|
||||
sizeNames[vectorSize]);
|
||||
@@ -258,6 +258,7 @@ int TestMacro_Int_Float(const Func *f, MTdata d, bool relaxedMode)
|
||||
test_info.subBufferSize = BUFFER_SIZE
|
||||
/ (sizeof(cl_float) * RoundUpToNextPowerOfTwo(test_info.threadCount));
|
||||
test_info.scale = getTestScale(sizeof(cl_float));
|
||||
|
||||
if (gWimpyMode)
|
||||
{
|
||||
test_info.subBufferSize = gWimpyBufferSize
|
||||
@@ -279,6 +280,7 @@ int TestMacro_Int_Float(const Func *f, MTdata d, bool relaxedMode)
|
||||
test_info.f = f;
|
||||
test_info.ftz =
|
||||
f->ftz || gForceFTZ || 0 == (CL_FP_DENORM & gFloatCapabilities);
|
||||
|
||||
// cl_kernels aren't thread safe, so we make one for each vector size for
|
||||
// every thread
|
||||
for (i = gMinVectorSizeIndex; i < gMaxVectorSizeIndex; i++)
|
||||
@@ -328,8 +330,8 @@ int TestMacro_Int_Float(const Func *f, MTdata d, bool relaxedMode)
|
||||
®ion, &error);
|
||||
if (error || NULL == test_info.tinfo[i].outBuf[j])
|
||||
{
|
||||
vlog_error("Error: Unable to create sub-buffer of gOutBuffer "
|
||||
"for region {%zd, %zd}\n",
|
||||
vlog_error("Error: Unable to create sub-buffer of "
|
||||
"gOutBuffer for region {%zd, %zd}\n",
|
||||
region.origin, region.size);
|
||||
goto exit;
|
||||
}
|
||||
@@ -355,6 +357,7 @@ int TestMacro_Int_Float(const Func *f, MTdata d, bool relaxedMode)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// Run the kernels
|
||||
if (!gSkipCorrectnessTesting)
|
||||
{
|
||||
error = ThreadPool_Do(TestFloat, test_info.jobCount, &test_info);
|
||||
@@ -501,7 +504,6 @@ static cl_int TestFloat(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get that moving
|
||||
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush failed\n");
|
||||
|
||||
@@ -569,7 +571,6 @@ static cl_int TestFloat(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get that moving
|
||||
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush 2 failed\n");
|
||||
|
||||
@@ -594,6 +595,7 @@ static cl_int TestFloat(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the last buffer
|
||||
out[j] = (cl_int *)clEnqueueMapBuffer(tinfo->tQueue, tinfo->outBuf[j],
|
||||
CL_TRUE, CL_MAP_READ, 0, buffer_size,
|
||||
@@ -711,12 +713,14 @@ int TestMacro_Int_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
size_t i, j;
|
||||
|
||||
logFunctionInfo(f->name, sizeof(cl_double), relaxedMode);
|
||||
|
||||
// Init test_info
|
||||
memset(&test_info, 0, sizeof(test_info));
|
||||
test_info.threadCount = GetThreadCount();
|
||||
test_info.subBufferSize = BUFFER_SIZE
|
||||
/ (sizeof(cl_double) * RoundUpToNextPowerOfTwo(test_info.threadCount));
|
||||
test_info.scale = getTestScale(sizeof(cl_double));
|
||||
|
||||
if (gWimpyMode)
|
||||
{
|
||||
test_info.subBufferSize = gWimpyBufferSize
|
||||
@@ -782,12 +786,9 @@ int TestMacro_Int_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
|
||||
for (j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
{
|
||||
/* Qualcomm fix: 9461 read-write flags must be compatible with
|
||||
* parent buffer */
|
||||
test_info.tinfo[i].outBuf[j] = clCreateSubBuffer(
|
||||
gOutBuffer[j], CL_MEM_WRITE_ONLY, CL_BUFFER_CREATE_TYPE_REGION,
|
||||
®ion, &error);
|
||||
/* Qualcomm fix: end */
|
||||
if (error || NULL == test_info.tinfo[i].outBuf[j])
|
||||
{
|
||||
vlog_error("Error: Unable to create sub-buffer of gInBuffer "
|
||||
@@ -817,6 +818,7 @@ int TestMacro_Int_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// Run the kernels
|
||||
if (!gSkipCorrectnessTesting)
|
||||
{
|
||||
error = ThreadPool_Do(TestDouble, test_info.jobCount, &test_info);
|
||||
@@ -846,8 +848,9 @@ int TestMacro_Int_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
// Run the kernels
|
||||
for (j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
{
|
||||
size_t vectorSize = sizeValues[j] * sizeof(cl_double);
|
||||
size_t localCount = (BUFFER_SIZE + vectorSize - 1) / vectorSize;
|
||||
size_t vectorSize = sizeof(cl_double) * sizeValues[j];
|
||||
size_t localCount = (BUFFER_SIZE + vectorSize - 1)
|
||||
/ vectorSize; // BUFFER_SIZE / vectorSize rounded up
|
||||
if ((error = clSetKernelArg(test_info.k[j][0], 0,
|
||||
sizeof(gOutBuffer[j]), &gOutBuffer[j])))
|
||||
{
|
||||
@@ -900,6 +903,7 @@ int TestMacro_Int_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
vlog("\n");
|
||||
|
||||
exit:
|
||||
// Release
|
||||
for (i = gMinVectorSizeIndex; i < gMaxVectorSizeIndex; i++)
|
||||
{
|
||||
clReleaseProgram(test_info.programs[i]);
|
||||
@@ -936,9 +940,9 @@ static cl_int TestDouble(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
cl_uint base = job_id * (cl_uint)job->step;
|
||||
ThreadInfo *tinfo = job->tinfo + thread_id;
|
||||
dptr dfunc = job->f->dfunc;
|
||||
int ftz = job->ftz;
|
||||
cl_uint j, k;
|
||||
cl_int error;
|
||||
int ftz = job->ftz;
|
||||
const char *name = job->f->name;
|
||||
|
||||
Force64BitFPUPrecision();
|
||||
@@ -1027,7 +1031,6 @@ static cl_int TestDouble(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get that moving
|
||||
if ((error = clFlush(tinfo->tQueue))) vlog("clFlush 2 failed\n");
|
||||
|
||||
@@ -1052,6 +1055,7 @@ static cl_int TestDouble(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for the last buffer
|
||||
out[j] = (cl_long *)clEnqueueMapBuffer(tinfo->tQueue, tinfo->outBuf[j],
|
||||
CL_TRUE, CL_MAP_READ, 0, buffer_size,
|
||||
@@ -1062,14 +1066,12 @@ static cl_int TestDouble(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
// Verify data
|
||||
cl_long *t = (cl_long *)r;
|
||||
for (j = 0; j < buffer_elements; j++)
|
||||
{
|
||||
cl_long *q = out[0];
|
||||
|
||||
|
||||
// If we aren't getting the correctly rounded result
|
||||
if (gMinVectorSizeIndex == 0 && t[j] != q[j])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user