Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

Shared Virtual Memory (SVM) Support

Hi,

I see in the release notes for v15 update 2, that "Adds OpenCL Shared Virtual Memory (SVM) application programming interface (API) support to emulation" - so apparently it is supported in general.

I cannot seem to be able to find in any documentation anything about SVM, how to use the SVM functions etc. (it appears that in CL/cl_ext.h there are functions like clSetKernelArgSVMPointerAltera()).

I cannot get them to work - i.e., successfully compile.

Can someone shed some light or provide any documentation with more details on SVM and how to get it work?

Thanks!

~~~

EDIT: Partially answering my question.

So, it seems that the following SMV-related functions are available (it is pretty much what OpenCL 2.0 supports, BUT you need to add the "Altera" suffix, so their arguments list, return types, errors, etc. should be what you can see for the corresponding OpenCL 2.0 functions):

clEnqueueSVMFreeAltera

clEnqueueSVMMapAltera

clEnqueueSVMMemFillAltera

clEnqueueSVMMemcpyAltera

clEnqueueSVMUnmapAltera

clSVMAllocAltera

clSVMFreeAltera

clSetKernelArgSVMPointerAltera

In order to use SVM your allocations have to be aligned, in my case at least 1024 - CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE shows 1024.

Then use the clSetKernelArgSVMPointerAltera() to set the SVM pointer argument.

int *test_arr=(int *)memalign(1024, sizeof(cl_int)*32);
...
clSetKernelArgSVMPointerAltera(kernel, 1, test_arr);

The kernel argument and use within the kernel is as with any global memory pointer.

Since, fine-grained system SVM is supported there is no need for map/unmaps, nor for explicit clSVMAllocPointerAltera() - at least to my understanding :)
No RepliesBe the first to reply