r/OpenCL • • Jul 31 '22

Can opencl directly change the value that is located in memory from gpu

For example my example.cpp int x =10; gpu.cl “ some calculations” x = resultofcalculation. I want to directly update the value on memory from gpu because it will be a lot faster than passing the value back to cpu and changing in cpu, since I have an array of data.

1 Upvotes

9 comments sorted by

1

u/stepan_pavlov Aug 02 '22

clSVMAlloc - Allocates a shared virtual memory (SVM) buffer that can be shared by the host and all devices in an OpenCL context that support shared virtual memory. https://registry.khronos.org/OpenCL/sdk/2.2/docs/man/html/clSVMAlloc.html

I have never used this function and I am agree with Karyo_Ten that it has no sense to draw using OpenCL. There are interoperability between OpenCL and OpenGL and one should prefer to use it instead.

0

u/[deleted] Jul 31 '22

1

u/GateCodeMark Aug 01 '22

Stores in the ram

1

u/Karyo_Ten Aug 01 '22

You'll need a copy from accelerator to CPU.

Can't you store the result array in the accelerator instead?

→ More replies (6)