diff options
Diffstat (limited to 'test_conformance/math_brute_force/unary_two_results_double.cpp')
-rw-r--r-- | test_conformance/math_brute_force/unary_two_results_double.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/test_conformance/math_brute_force/unary_two_results_double.cpp b/test_conformance/math_brute_force/unary_two_results_double.cpp index 71dd4f44..6d7c61d6 100644 --- a/test_conformance/math_brute_force/unary_two_results_double.cpp +++ b/test_conformance/math_brute_force/unary_two_results_double.cpp @@ -14,14 +14,18 @@ // limitations under the License. // +#include "common.h" #include "function_list.h" #include "test_functions.h" #include "utility.h" +#include <cinttypes> #include <cstring> -static int BuildKernel(const char *name, int vectorSize, cl_kernel *k, - cl_program *p, bool relaxedMode) +namespace { + +int BuildKernel(const char *name, int vectorSize, cl_kernel *k, cl_program *p, + bool relaxedMode) { const char *c[] = { "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n", "__kernel void math_kernel", @@ -107,27 +111,28 @@ static int BuildKernel(const char *name, int vectorSize, cl_kernel *k, return MakeKernel(kern, (cl_uint)kernSize, testName, k, p, relaxedMode); } -typedef struct BuildKernelInfo +struct BuildKernelInfo2 { - cl_uint offset; // the first vector size to build cl_kernel *kernels; - cl_program *programs; + Programs &programs; const char *nameInCode; bool relaxedMode; // Whether to build with -cl-fast-relaxed-math. -} BuildKernelInfo; +}; -static cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p) +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->kernels + i, - info->programs + i, info->relaxedMode); + BuildKernelInfo2 *info = (BuildKernelInfo2 *)p; + cl_uint vectorSize = gMinVectorSizeIndex + job_id; + return BuildKernel(info->nameInCode, vectorSize, info->kernels + vectorSize, + &(info->programs[vectorSize]), info->relaxedMode); } +} // anonymous namespace + int TestFunc_Double2_Double(const Func *f, MTdata d, bool relaxedMode) { int error; - cl_program programs[VECTOR_SIZE_COUNT]; + Programs programs; cl_kernel kernels[VECTOR_SIZE_COUNT]; float maxError0 = 0.0f; float maxError1 = 0.0f; @@ -144,8 +149,8 @@ int TestFunc_Double2_Double(const Func *f, MTdata d, bool relaxedMode) // Init the kernels { - BuildKernelInfo build_info = { gMinVectorSizeIndex, kernels, programs, - f->nameInCode, relaxedMode }; + BuildKernelInfo2 build_info{ kernels, programs, f->nameInCode, + relaxedMode }; if ((error = ThreadPool_Do(BuildKernelFn, gMaxVectorSizeIndex - gMinVectorSizeIndex, &build_info))) @@ -287,7 +292,7 @@ int TestFunc_Double2_Double(const Func *f, MTdata d, bool relaxedMode) float err2 = Bruteforce_Ulp_Error_Double(test2, correct2); int fail = !(fabsf(err) <= f->double_ulps && fabsf(err2) <= f->double_ulps); - if (ftz) + if (ftz || relaxedMode) { // retry per section 6.5.3.2 if (IsDoubleResultSubnormal(correct, f->double_ulps)) @@ -410,8 +415,9 @@ int TestFunc_Double2_Double(const Func *f, MTdata d, bool relaxedMode) { if (gVerboseBruteForce) { - vlog("base:%14u step:%10zu bufferSize:%10zd \n", i, step, - BUFFER_SIZE); + vlog("base:%14" PRIu64 " step:%10" PRIu64 + " bufferSize:%10d \n", + i, step, BUFFER_SIZE); } else { @@ -439,7 +445,6 @@ exit: for (auto k = gMinVectorSizeIndex; k < gMaxVectorSizeIndex; k++) { clReleaseKernel(kernels[k]); - clReleaseProgram(programs[k]); } return error; |