Intel® C++ Compiler 16.0 User and Reference Guide
Shared Virtual Memory (SVM) is a programming model that allows sharing virtual address space between the CPU and the processor graphics. SVM gives you more opportunities to interact with the processor graphics than when not using SVM, as a wider range of algorithms can be easily adapted for executing on the processor graphics
There are no restrictions on using pointers inside GFX offload regions.
You can store pointers in data structures and dereference them.
You can use global or static pointer-typed data.
You can get an address of a pointer or a reference object.
You can use double indirection of pointers.
You do not need to specify pointers in any data sharing clause to GFX offload regions.
The compiler supports fine-grained buffered SVM: You must allocate and deallocate pointers that are operated upon by the processor graphics. _GFX_svm_alloc allocates a buffer in memory, and _GFX_svm_free deallocates a buffer previously set with _GFX_svm_alloc. Both of these APIs are declared in gfx_rt.h. Using non-SVM memory, when you compile for SVM, in GFX offload code might lead to incorrect results or to the program hanging.
To enable SVM, use the compiler option Qoffload-svm (Windows) or qoffload-svm (Linux).
Mixed memory mode is not allowed: All program units must be either compiled with or without SVM enabled. It is your responsibility as a programmer to control the consistency of memory modes for all program units.
This example demonstrates:
allocating SVM buffers
using pointers in the offload pragma. Notice that there is no need to list pointer objects on any data sharing clause like in, inout, out, or pin.
Using an array of pointers in the offload block, which is not allowed unless you use SVM.
Deallocating SVM buffers.
...
int** out = (int**)_GFX_svm_alloc(sizeof(int*) * N);
int* in = (int*)_GFX_svm_alloc(sizeof(int) * N);
...
__pragma(offload target(gfx))
_Cilk_for(int i = 0; i < N; i++) {
out[i] = &in[i];
}
...
_GFX_svm_free(in);
_GFX_svm_free(out);