Adding built-in functions to the API
December 3, 2011
Posted by on
It’s time to add (most of) the OpenCL 1.1 built-in functions:
- 9.3.2 Math Functions: acos acosh acospi asin asinh asinpi atan atan2 atanh atanpi atan2pi cbrt ceil copysign cos cosh cospi erfc erf exp exp2 exp10 expm1 fabs fdim floor fma fmax fmin fmod fract frexp hypot ilogb ldexp lgamma log log2 log10 log1p logb mad maxmag minmag modf nan nextafter pow pown powr remainder remquo rint rootn round rsqrt sin sincos sinh sinpi sqrt tan tanh tanpi tgamma trunc
- 9.3.5 Relational Functions: isequal isnotequal isgreater isgreaterequal isless islessequal islessgreater isfinite isinf isnan isnormal isordered isunordered
These functions are part of the standard C99 POSIX math libraries. It’s easy to maintain equivalent functionality between the interpreter and GPU back-end. No rocket-science. It will be a long weekend of drone work.
JIT back-end code generation is still very incomplete. Everything is working, though. Even the gather/scatter of application thread traces by the scheduler is working with the GPU. This is really support for OpenMP and loops, although regular Pthreads work just as well.
My experience is these kinds of problems can be endless. If you try to build the complete, bullet-proof virtual machine and JIT compiler up-front, it will take too long. Worse, by the time it is finished (if that ever happens), you may find that it has been optimized for the wrong problems.
Better is building out a platform as needed to support application functionality. That’s the only way to do this.