How to use C++ templates in OpenCL kernels?

前端 未结 6 1748
猫巷女王i
猫巷女王i 2020-12-24 08:53

I\'m a novice in OpenCL.

I have an algorithm which uses templates. It worked well with OpenMP parallelization but now the amount of data has grown and the only way t

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-24 09:28

    You can have a look at VexCL which uses expression templates to generate OpenCL kernels. You can get some ideas on how to make OpenCL to work nicely with templates.

    Another library that is being actively worked on is Boost.Compute which is a layer on top of OpenCL to allow generic C++ code.

    The general idea is to create the kernel as a C string more or less and pass it down to the OpenCL runtime for compilation and execution.

提交回复
热议问题