Reputation: 1727
My OpenCL kernel requires a few MB of input data, about 300MB of temporary global memory for work, and it returns only a few MB. The only way I know to give the kernel this temporary memory is to allocate this memory with malloc and then pass it with clCreateBuffer, but it takes some time to copy 300MB to GPU and also requires 300MB of host RAM. Is it possible to skip it and either allocate global device memory inside of kernel or somehow declare a buffer with 300Mb but do not create it with malloc and do not copy it to GPU?
Upvotes: 3
Views: 2585
Reputation: 9925
If you just call clCreateBuffer
without using a host pointer, then memory will be allocated on the device without copying any data from the host. For example:
buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, size, NULL, &err);
Upvotes: 2