cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

sampie
Adept I

OpenCL: How to allocate C++ vector in SVM memory?

Hi,

How to allocate SVM memory and use it for a C++ vector? I guess vector.data() needs to be at SVM memory. Are atomic_svm_vector fine_svm_vector definitions in OpenCL C++ bindings something that helps to do this?

BR,

Sami

0 Likes
11 Replies
dipak
Big Boss

Yes, <type>_svm_vector definitions  [where <type> value indicates SVM type say coarse-grained, fine-grained or fine-grained with atomic support] can be used for this purpose. These are just aliases with appropriate SVMAllocator to simplify the vector construction.

One point to note though.  The latest APP SDK does not support OpenCL 2.0 C++ binding so, it will not work here.

0 Likes

Does rocm support OpenCL 2.0 C++ bindings? I have rocm 1.7.

I have been also trying to reserve SVM with following code. However, I seem to get CL_INVALID_VALUE error. What could be wrong?

size_t SVM_size = 42;   

   

void* p = clSVMAlloc (

      context(),

      CL_MEM_READ_WRITE | CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_SVM_ATOMICS,

      SVM_size,

      0

);

cl_int err = clEnqueueSVMMap(queue(), CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, p, SVM_size, 0, NULL, NULL);

Thanks

btw. Is there somewhere a collection of OpenCL 2.0 example code for various operations (such as atomic operations, memory allocations and submitting kernels from the device)? I am trying to learn GPGPU programming.

0 Likes

I have been also trying to reserve SVM with following code. However, I seem to get CL_INVALID_VALUE error. What could be wrong?

The device needs to support SVM fine-grained buffer with atomics. Please check clinfo (or clGetDeviceInfo ) which should report this capabilities.

Also, before calling any SVM related functions, please ensure that clSVMAlloc is successful by checking the pointer returned by this call.

Is there somewhere a collection of OpenCL 2.0 example code for various operations (such as atomic operations, memory allocations and submitting kernels from the device)? I am trying to learn GPGPU programming.

AMD APP SDK 3.0 contains few samples that highlight the new features and benefits of OpenCL 2.0. The page below shows an overview  about the samples.

https://developer.amd.com/amd-accelerated-parallel-processing-app-sdk/opencl-2-0-samples/

Important Note:

Please do not use APP SDK with amdgpu-pro (or rocm) as APP SDK is no longer compatible with this driver.

Does rocm support OpenCL 2.0 C++ bindings? I have rocm 1.7.

ROCm-OpenCL-Runtime​ says:

OpenCL 1.2 compatible language runtime and compiler

OpenCL 2.0 compatible kernel language support with OpenCL 1.2 compatible runtime.

So, I don't think so. I'll check though for more information.

Regards,

0 Likes

Hi

Thank you for the links to code examples!

I have Radeon RX 460 on a Ryzen system. The device info is reporting fine grain capabilities: CL_DEVICE_SVM_FINE_GRAIN_BUFFER, but no CL_DEVICE_SVM_FINE_GRAIN_SYSTEM or CL_DEVICE_SVM_ATOMICS.  The clinfo is reporting following values/versions: Device Name = gfx803, Device Version = OpenCL 1.2, Device OpenCL C Version = OpenCL C 2.0.

What AMD device(s) I should have if I want CL_DEVICE_SVM_FINE_GRAIN_SYSTEM and CL_DEVICE_SVM_ATOMICS?

Thanks

0 Likes

So, your system does not support SVM atomics, that's why clSVMAlloc and clEnqueueSVMMap failed earlier.

What AMD device(s) I should have if I want CL_DEVICE_SVM_FINE_GRAIN_SYSTEM and CL_DEVICE_SVM_ATOMICS?

I'm not sure about that support on ROCm. Let me check with concerned team for more details.

On Windows, I think latest APUs can be used. For example, clinfo on a Carrizo laptop with Win10 reports both the above flags.

0 Likes

Hi,

> So, your system does not support SVM atomics, that's why clSVMAlloc and clEnqueueSVMMap failed earlier.

That seems to be the case. I wonder what PCIe atomics means and if it is somehow different than OpenCL atomics. Rockm page says: "The ROCm Platform leverages PCIe Atomics (Fetch ADD, Compare and SWAP, Unconditional SWAP, AtomicsOpCompletion)"... "Our GFX8 GPU's (Fiji & Polaris Family) and GFX9 (Vega) use PCIe Gen 3 and PCIe Atomics."

(GitHub - RadeonOpenCompute/ROCm: ROCm - Open Source Platform for HPC and Ultrascale GPU Computing )

> I'm not sure about that support on ROCm. Let me check with concerned team for more details.

Thanks

0 Likes

I wonder what PCIe atomics means

Here is a related page for more information: More about how ROCm uses PCIe Atomics — ROCm Documentation latest documentation

0 Likes

Hi,

Somehow it sounds to me that RX 460 with Rocm should support OpenCL atomics. Is this correct? Does Rocm have a separate forum where these kinds of questions can be asked?

Thanks

0 Likes

As per your clinfo output, ROCm OpenCL doesn't seem to support this feature. At least, the driver doesn't look like support it currently on this configuration. If you're asking about hardware level support, I'm not sure though.

For ROCm related issue or query, please post here: Issues · RadeonOpenCompute/ROCm · GitHub

0 Likes

Yes, clinfo output indicates that it is not supported, but rocm description saying that PCIe atomics are supported on polaris imply otherwise.

0 Likes

PCIe atomics are different from OpenCL SVM atomics that you are relating to. PCIe atomics are part of the PCIe spec.

0 Likes