[英]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). 因此,我想将指向自己的树项目数组传递给opencl内核,而SVM似乎是这样做的最好方法(我对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. 我的问题是如何使用boost :: compute做到这一点,以便内核将接收三进制整数或类似的东西。
Thanks! 谢谢!
Boost.Compute does support shared virtual memory using the boost::compute::svm_* functions. Boost.Compute确实使用boost :: compute :: svm_ *函数支持共享虚拟内存。
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). 对于您的应用程序,您应该能够使用svm_alloc()分配SVM内存区域,用输入数据填充该区域,然后使用常规kernel :: set_arg()函数将其传递给内核(该函数具有重载)用于SVM内存对象)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.