OpenCL user defined inline functions

前端 未结 4 1828
梦谈多话
梦谈多话 2020-12-28 22:36

Is it possible to define my own functions in OpenCL code, in order that the kernels could call them? It yes, where can I see some simple example?

4条回答
  •  渐次进展
    2020-12-28 22:51

    Based on the code samples here you can just write functions like:

    inline int add(int a,int b)
    {
       return a+b;
    }
    

    (Eg. look at the .cl file in the DXTC or bitonic sort examples.)

    I don't know if that's an nvidia only extension but the OpenCL documentation talks about "auxiliary functions" as well as kernels.

提交回复
热议问题