Use clProgramWrapper in math_brute_force (#1451)

Simplify code by avoiding manual resource management.

This allows removing clReleaseProgram from `MakeKernels` to reduce
behavioral differences between `MakeKernels` and `MakeKernel`.

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
2022-07-28 13:33:16 +01:00
committed by GitHub
parent 2cf24e63b7
commit 0a5a8f90c9
28 changed files with 120 additions and 105 deletions

View File

@@ -115,7 +115,7 @@ struct BuildKernelInfo
cl_uint offset; // the first vector size to build
cl_uint kernel_count;
KernelMatrix &kernels;
cl_program *programs;
Programs &programs;
const char *nameInCode;
bool relaxedMode; // Whether to build with -cl-fast-relaxed-math.
};
@@ -125,7 +125,7 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
BuildKernelInfo *info = (BuildKernelInfo *)p;
cl_uint i = info->offset + job_id;
return BuildKernel(info->nameInCode, i, info->kernel_count,
info->kernels[i].data(), info->programs + i,
info->kernels[i].data(), &(info->programs[i]),
info->relaxedMode);
}
@@ -148,7 +148,9 @@ struct TestInfo
{
size_t subBufferSize; // Size of the sub-buffer in elements
const Func *f; // A pointer to the function info
cl_program programs[VECTOR_SIZE_COUNT]; // programs for various vector sizes
// Programs for various vector sizes.
Programs programs;
// Thread-specific kernels for each vector size:
// k[vector_size][thread_id]
@@ -948,7 +950,6 @@ exit:
// Release
for (auto i = gMinVectorSizeIndex; i < gMaxVectorSizeIndex; i++)
{
clReleaseProgram(test_info.programs[i]);
for (auto &kernel : test_info.k[i])
{
clReleaseKernel(kernel);