Intel® C++ Compiler 16.0 User and Reference Guide

Overview: Shared Virtual Memory (SVM)

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

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.

Example

This example demonstrates:

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