dcompute icon indicating copy to clipboard operation
dcompute copied to clipboard

Add a helper function `callBuiltin`

Open FinalEvilution opened this issue 1 month ago • 1 comments

Adds a helper function callBuiltin which allows for easy calling of OpenCL built-in functions.

rationale: Looking at section "6.15.2. Math Functions" of the opencl c spec as an example, there are approximately 96 fuctions of the generic type name gentype, multiply that by the number of combinations of gentype (18 if you include half's) you get 1,728 multiply by 3 (one pragma mangle, function def and a blank line) and you get a 5184 line file. Way too much. This function makes it easy to make function templates for these generic built-in functions. like so.

T acos(T)(T x)
{
    return callBuiltin!("acos", T)(x);
}

Cutting the number of definitions back down to a more reasonable 96. That's the idea anyway.

FinalEvilution avatar Dec 07 '25 23:12 FinalEvilution