4 Replies Latest reply on Mar 11, 2013 10:35 PM by himanshu.gautam

    Probable usage of texture memory

    sajis997

      Hello forum,

       

       

      The simulation i am trying to run represents data on a 2D grid. The natural representation for this grid on the CPU is array . The analog of array on the GPU is  the texture. So i believe that different type of data structure can be represented with 3/4 color channels. In my simulation i shall store the vector data represented as float2 in the texture and i am confused about its representation within color channels while creating the 2D texture and its access inside the kernel by sampler.

       

       

       

       

      Some hint along with discussion will help me to get around this issue.

       

       

       

      cl_mem initTexture(int width,int height)

      {

         cl_int ciErrNum;

       

       

         cl_image_format image_format;

         image_format.image_channel_order = CL_RGBA;

         image_format.image_channel_data_type = CL_UNSIGNED_INT8;

       

       

         //create an empty image

         cl_mem imageTexture = clCreateImage2D(cxGPUContext,CL_MEM_READ_WRITE,

                                                         &image_format,width,height,0,NULL,

                                                         &ciErrNum);

         oclCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);

       

       

          

       

       

         return imageTexture;

      }

       

       

       

      The above snippet initialize the 2D texture. Please the texture will be containing the float2 type value which will be copied later from the host. Do i need to make any changes above to support float2 type?

       

       

      What should i look out for while configuring the sampler ?

       

       

      I shall be eagerly looking forward to your response.

       

       

      Regards

      Sajjad

        • Re: Probable usage of texture memory
          LeeHowes

          The analogue of the array on the GPU is the array. The analogue of a malloced memory region that might be interpreted as an array is the buffer.

           

          However, if you really want to use textures (whether they give a benefit or not is very application dependent and you might have to experiment) you will want to change the format to 2-channel floating point:

             image_format.image_channel_order = CL_RG;

             image_format.image_channel_data_type = CL_FLOAT;

          1 of 1 people found this helpful