math_brute_force: Use clKernelWrapper in single-threaded tests (#1590)

Simplify code by relying on RAII to free resources.

This commit only affects tests that use `BuildKernelInfo2`, which are
the single-threaded tests.

Original patch by Marco Antognini.

Signed-off-by: Marco Antognini <marco.antognini@arm.com>
Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>

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
2022-12-13 17:53:56 +00:00
committed by GitHub
parent fb949f9256
commit 884c736525
14 changed files with 84 additions and 126 deletions

View File

@@ -39,9 +39,11 @@ int BuildKernel(const char *name, int vectorSize, cl_kernel *k, cl_program *p,
relaxedMode);
}
using Kernels = std::array<clKernelWrapper, VECTOR_SIZE_COUNT>;
struct BuildKernelInfo2
{
cl_kernel *kernels;
Kernels &kernels;
Programs &programs;
const char *nameInCode;
bool relaxedMode; // Whether to build with -cl-fast-relaxed-math.
@@ -51,7 +53,8 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
{
BuildKernelInfo2 *info = (BuildKernelInfo2 *)p;
cl_uint vectorSize = gMinVectorSizeIndex + job_id;
return BuildKernel(info->nameInCode, vectorSize, info->kernels + vectorSize,
return BuildKernel(info->nameInCode, vectorSize,
&(info->kernels[vectorSize]),
&(info->programs[vectorSize]), info->relaxedMode);
}
@@ -134,7 +137,7 @@ int TestFunc_Double_Double_Double_Double(const Func *f, MTdata d,
{
int error;
Programs programs;
cl_kernel kernels[VECTOR_SIZE_COUNT];
Kernels kernels;
float maxError = 0.0f;
int ftz = f->ftz || gForceFTZ;
double maxErrorVal = 0.0f;
@@ -654,11 +657,5 @@ int TestFunc_Double_Double_Double_Double(const Func *f, MTdata d,
vlog("\n");
exit:
// Release
for (auto k = gMinVectorSizeIndex; k < gMaxVectorSizeIndex; k++)
{
clReleaseKernel(kernels[k]);
}
return error;
}