openclboost-compute

How to use Shared Virtual Memory in Boost::Compute and custom kernel?


I have written a simple kernel that performs recursion over trees like:

struct item {
    int data;
    item *rnext, *lnext;
} *items[NUM_ITEMS];

So i'd like to pass such array of tree items which point to themselves to the opencl kernel, and SVM seems the best way to do so (I have no problem counting on opencl 2.0).

My question is how to do it with boost::compute such that the kernel will receive triples of integers or something like that.

Thanks!


Solution

  • Boost.Compute does support shared virtual memory using the boost::compute::svm_* functions.

    For your application, you should be able to just allocate a region of SVM memory with svm_alloc(), fill it with your input data, and then pass it to your kernel using the regular kernel::set_arg() function (which has an overload for SVM memory objects).