mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
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:
committed by
GitHub
parent
fb949f9256
commit
884c736525
@@ -35,9 +35,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.
|
||||
@@ -47,7 +49,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);
|
||||
}
|
||||
|
||||
@@ -57,7 +60,7 @@ int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
{
|
||||
int error;
|
||||
Programs programs;
|
||||
cl_kernel kernels[VECTOR_SIZE_COUNT];
|
||||
Kernels kernels;
|
||||
float maxError = 0.0f;
|
||||
double maxErrorVal = 0.0f;
|
||||
double maxErrorVal2 = 0.0f;
|
||||
@@ -213,11 +216,5 @@ int TestFunc_mad_Double(const Func *f, MTdata d, bool relaxedMode)
|
||||
vlog("\n");
|
||||
|
||||
exit:
|
||||
// Release
|
||||
for (auto k = gMinVectorSizeIndex; k < gMaxVectorSizeIndex; k++)
|
||||
{
|
||||
clReleaseKernel(kernels[k]);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user