cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

shaboinkin
Journeyman III

OpenCL Image Read/Write

I was reading over AMD's OpenCL Programming Guide and in section 1.5.3, it says

"For a single kernel invocation, up to 128 images can be bound at once for reading, and eight for writing"

What does this mean? I can have 128 images queued up, and on a single command, have them all be written to GPU memory? Rather than calling clCreateBuffer for each unique image?

0 Likes
5 Replies
matszpk
Adept III

Re: OpenCL Image Read/Write

You can use up to 128 images to read and 8 images to write inside kernel. You can allocate any number of images in device's memory.

0 Likes
cgrant78
Adept III

Re: OpenCL Image Read/Write

From the excerpt you posted from the Programming Guide. reading in that context means your kernel actually reading/sampling the image while writing refers to your kernel actually writing some result into the image, ie. a store operation. That is in no way related to the second question you asked or its rather vague as to what the question is. So to take a stab at it, my understanding of what you mean by "..written to GPU memory" is creating the image. The image MUST be created prior to any writing or reading from it otherwise how would the runtime know about the image ?

0 Likes
shaboinkin
Journeyman III

Re: OpenCL Image Read/Write

I made the assumption that I already had 128 images stores in main memory. I interpreted that passage as "when you write images to the device's memory, you can group these writes together as 1 massive write operation."

So I thought this meant something like, if I had 128 images, each of them being 10 megabytes large, I can execute 1 sequential 1.28GB write of data to the device rather than calling clCreateBuffer 128 times.

Is that what the words "can be bound at once for reading" mean?

0 Likes
matszpk
Adept III

Re: OpenCL Image Read/Write

OpenCL doesn't allow to operate in single call on multiple images or any memory resources (excepts memory migration). Any operation on an image requires single call (reading/writing/copying). Those limits concerns kernel environment (while kernel execution).

0 Likes
cgrant78
Adept III

Re: OpenCL Image Read/Write

matszpk already answer the question directly. However, I still think you are somewhat confused by either the wording in the programming guide or how OpenCL works. One does not write images into memory. The implementation creates the image in the appropriate memory specified during creation time ( clCreateImage/clCreateBuffer whatever the call maybe ). Kernels can be used to write( image store) values into images during invocation. Images are access through samplers so each kernel invocation can only write a small amount of data to any given image. What the specification is saying is that any single kernel invocation can access only 8 images for write operation( image store). If you want the images to be created in device memory, then create them in device memory instead of host memory.

0 Likes