mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
math_brute_force: Remove unnecessary gotos (#1605)
Simplify code by returning directly instead of using goto statements. Although intended as an NFC commit, this changes the behaviour around clFlush calls. Before this commit, failure of the third clFlush call would print "clFlush 3 failed" and return the clFlush error code. This behaviour is inconsistent with the other clFlush calls in math_brute_force, which are not fatal. The lack of a `goto exit` makes me suspect that this 3rd clFlush call was intended to be non-fatal too. As such, this commit makes all clFlush calls non-fatal by returning `CL_SUCCESS` even when the third clFlush call fails. Original patch by Marco Antognini. Signed-off-by: Marco Antognini <marco.antognini@arm.com> Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
committed by
GitHub
parent
11782f7650
commit
1e5b5c96e2
@@ -285,14 +285,14 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
buffer_size, p, 0, NULL, NULL)))
|
||||
{
|
||||
vlog_error("Error: clEnqueueWriteBuffer failed! err: %d\n", error);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
|
||||
if ((error = clEnqueueWriteBuffer(tinfo->tQueue, tinfo->inBuf2, CL_FALSE, 0,
|
||||
buffer_size, p2, 0, NULL, NULL)))
|
||||
{
|
||||
vlog_error("Error: clEnqueueWriteBuffer failed! err: %d\n", error);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
@@ -303,12 +303,12 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
if ((error = clWaitForEvents(1, e + j)))
|
||||
{
|
||||
vlog_error("Error: clWaitForEvents failed! err: %d\n", error);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
if ((error = clReleaseEvent(e[j])))
|
||||
{
|
||||
vlog_error("Error: clReleaseEvent failed! err: %d\n", error);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
{
|
||||
vlog_error("Error: clEnqueueUnmapMemObject failed! err: %d\n",
|
||||
error);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -368,7 +368,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
&vectorCount, NULL, 0, NULL, NULL)))
|
||||
{
|
||||
vlog_error("FAILED -- could not execute kernel\n");
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
{
|
||||
vlog_error("Error: clEnqueueMapBuffer %d failed! err: %d\n", j,
|
||||
error);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,8 +542,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
"%.13la}: *%.13la vs. %.13la\n",
|
||||
name, sizeNames[k], err, s[j], s2[j], r[j],
|
||||
test);
|
||||
error = -1;
|
||||
goto exit;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -579,8 +578,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
@@ -636,7 +634,7 @@ int TestFunc_Double_Double_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
vlog_error("Error: Unable to create sub-buffer of gInBuffer for "
|
||||
"region {%zd, %zd}\n",
|
||||
region.origin, region.size);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
test_info.tinfo[i].inBuf2 =
|
||||
clCreateSubBuffer(gInBuffer2, CL_MEM_READ_ONLY,
|
||||
@@ -646,7 +644,7 @@ int TestFunc_Double_Double_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
vlog_error("Error: Unable to create sub-buffer of gInBuffer2 for "
|
||||
"region {%zd, %zd}\n",
|
||||
region.origin, region.size);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
|
||||
for (auto j = gMinVectorSizeIndex; j < gMaxVectorSizeIndex; j++)
|
||||
@@ -659,7 +657,7 @@ int TestFunc_Double_Double_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
vlog_error("Error: Unable to create sub-buffer of "
|
||||
"gOutBuffer[%d] for region {%zd, %zd}\n",
|
||||
(int)j, region.origin, region.size);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
}
|
||||
test_info.tinfo[i].tQueue =
|
||||
@@ -667,27 +665,26 @@ int TestFunc_Double_Double_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
if (NULL == test_info.tinfo[i].tQueue || error)
|
||||
{
|
||||
vlog_error("clCreateCommandQueue failed. (%d)\n", error);
|
||||
goto exit;
|
||||
return error;
|
||||
}
|
||||
|
||||
test_info.tinfo[i].d = MTdataHolder(genrand_int32(d));
|
||||
}
|
||||
|
||||
// Init the kernels
|
||||
{
|
||||
BuildKernelInfo build_info{ test_info.threadCount, test_info.k,
|
||||
test_info.programs, f->nameInCode,
|
||||
relaxedMode };
|
||||
if ((error = ThreadPool_Do(BuildKernelFn,
|
||||
gMaxVectorSizeIndex - gMinVectorSizeIndex,
|
||||
&build_info)))
|
||||
goto exit;
|
||||
}
|
||||
BuildKernelInfo build_info{ test_info.threadCount, test_info.k,
|
||||
test_info.programs, f->nameInCode,
|
||||
relaxedMode };
|
||||
if ((error = ThreadPool_Do(BuildKernelFn,
|
||||
gMaxVectorSizeIndex - gMinVectorSizeIndex,
|
||||
&build_info)))
|
||||
return error;
|
||||
|
||||
// Run the kernels
|
||||
if (!gSkipCorrectnessTesting)
|
||||
{
|
||||
error = ThreadPool_Do(Test, test_info.jobCount, &test_info);
|
||||
if (error) return error;
|
||||
|
||||
// Accumulate the arithmetic errors
|
||||
for (cl_uint i = 0; i < test_info.threadCount; i++)
|
||||
@@ -700,8 +697,6 @@ int TestFunc_Double_Double_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
}
|
||||
}
|
||||
|
||||
if (error) goto exit;
|
||||
|
||||
if (gWimpyMode)
|
||||
vlog("Wimp pass");
|
||||
else
|
||||
@@ -712,6 +707,5 @@ int TestFunc_Double_Double_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
|
||||
vlog("\n");
|
||||
|
||||
exit:
|
||||
return error;
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user