简体   繁体   中英

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!

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM