OpenCL built-in math functions accept abstract gentype
as argument types, so you have only one exp(x)
or log(x)
function and the compiler switches automatically to the right one depending on the actual arguments type when you call them.
I need to program other math functions that will perform a set of basic algebraic operations like (log(a / b) - c) / d
(no vertical vector algebra), but sometimes on float
scalars, sometimes on float4
vectors. Is there a clean way to only code them once and have the compiler switch the same depending on argument type ?
Alternatively, if I write only the float
scalar code and loop over a float4
to apply it, is the compiler able to vectorize it ?