math_brute_force: treat reciprocal as unary function (#2281)

Treat reciprocal as a unary function, instead of handling it through the
binary function testing mechanism and special-casing it there.

This addresses two shortcomings of the previous implementation:

- Testing took significantly longer as the entire input domain was
tested many times (e.g. fp16 reciprocal has only 2^16 possible input
values, but binary function testing iterates over 2^16 * 2^16 input
values).

- The reciprocal test kernel was identical to the divide kernel. Thus
the device compiler would see a regular divide operation instead of a
reciprocal operation and would be unlikely to emit a specialized
reciprocal sequence.

This reverts all of the changes in binary_operator*.cpp made by
bcfa1f7c2 ("Added corrections to re-enable reciprocal test in
math_brute_force suite for relaxed math mode (#2221)", 2025-02-04).

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
Sven van Haastregt
2025-03-05 01:52:28 +01:00
committed by GitHub
parent 5167d7202b
commit 7feb93cdd7
7 changed files with 62 additions and 120 deletions

View File

@@ -28,7 +28,12 @@ cl_int BuildKernelFn(cl_uint job_id, cl_uint thread_id UNUSED, void *p)
BuildKernelInfo &info = *(BuildKernelInfo *)p;
auto generator = [](const std::string &kernel_name, const char *builtin,
cl_uint vector_size_index) {
return GetUnaryKernel(kernel_name, builtin, ParameterType::Float,
const char *builtinCall = builtin;
if (strcmp(builtin, "reciprocal") == 0)
{
builtinCall = "((RETTYPE)(1.0f))/";
}
return GetUnaryKernel(kernel_name, builtinCall, ParameterType::Float,
ParameterType::Float, vector_size_index);
};
return BuildKernels(info, job_id, generator);