math_brute_force: Use clKernelWrapper in threaded tests (#1562)

Simplify code by relying on RAII to free resources.  Reduce code
duplication.

This commit only affects tests that use `BuildKernelInfo`, which are
the multi-threaded tests.  Another patch will deal with the
single-threaded tests, i.e., those using `BuildKernelInfo2`.

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-11-27 21:25:32 +00:00
committed by GitHub
parent e9d2abf705
commit 6ecf824122
16 changed files with 171 additions and 444 deletions

View File

@@ -24,7 +24,8 @@
#include <vector>
// Array of thread-specific kernels for each vector size.
using KernelMatrix = std::array<std::vector<cl_kernel>, VECTOR_SIZE_COUNT>;
using KernelMatrix =
std::array<std::vector<clKernelWrapper>, VECTOR_SIZE_COUNT>;
// Array of programs for each vector size.
using Programs = std::array<clProgramWrapper, VECTOR_SIZE_COUNT>;
@@ -82,4 +83,12 @@ struct BuildKernelInfo
bool relaxedMode;
};
using SourceGenerator = std::string (*)(const std::string &kernel_name,
const char *builtin,
cl_uint vector_size_index);
/// Build kernels for all threads in "info" for the given job_id.
cl_int BuildKernels(BuildKernelInfo &info, cl_uint job_id,
SourceGenerator generator);
#endif /* COMMON_H */