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:
Sven van Haastregt
2023-02-07 17:01:07 +00:00
committed by GitHub
parent 11782f7650
commit 1e5b5c96e2
24 changed files with 410 additions and 523 deletions

View File

@@ -291,14 +291,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++)
@@ -309,12 +309,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;
}
}
@@ -329,7 +329,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
@@ -374,7 +374,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;
}
}
@@ -386,7 +386,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
if ((error = clFinish(tinfo->tQueue)))
{
vlog_error("Error: clFinish failed! err: %d\n", error);
goto exit;
return error;
}
return CL_SUCCESS;
}
@@ -441,7 +441,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;
}
}
@@ -698,8 +698,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
name, sizeNames[k], err, s[j], ((cl_uint *)s)[j],
s2[j], ((cl_uint *)s2)[j], r[j], test,
((cl_uint *)&test)[0], j);
error = -1;
goto exit;
return -1;
}
}
}
@@ -738,8 +737,7 @@ cl_int Test(cl_uint job_id, cl_uint thread_id, void *data)
fflush(stdout);
}
exit:
return error;
return CL_SUCCESS;
}
} // anonymous namespace
@@ -795,7 +793,7 @@ int TestFunc_Float_Float_Float(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,
@@ -805,7 +803,7 @@ int TestFunc_Float_Float_Float(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++)
@@ -818,7 +816,7 @@ int TestFunc_Float_Float_Float(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 =
@@ -826,27 +824,26 @@ int TestFunc_Float_Float_Float(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++)
@@ -859,8 +856,6 @@ int TestFunc_Float_Float_Float(const Func *f, MTdata d, bool relaxedMode)
}
}
if (error) goto exit;
if (gWimpyMode)
vlog("Wimp pass");
else
@@ -871,6 +866,5 @@ int TestFunc_Float_Float_Float(const Func *f, MTdata d, bool relaxedMode)
vlog("\n");
exit:
return error;
return CL_SUCCESS;
}