Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6334

OpenCL: how to avoid duplicate scalar/vector functions?

$
0
0

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 ?


Viewing all articles
Browse latest Browse all 6334

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>