5 Replies Latest reply on Dec 14, 2015 1:41 PM by cgrant78@netzero.com

    OpenCL Image Read/Write

    shaboinkin

      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?

        • Re: OpenCL Image Read/Write
          matszpk

          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.

          • Re: OpenCL Image Read/Write
            cgrant78@netzero.com

            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 ?

              • Re: OpenCL Image Read/Write
                shaboinkin

                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?

                  • Re: OpenCL Image Read/Write
                    matszpk

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

                    • Re: OpenCL Image Read/Write
                      cgrant78@netzero.com

                      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.