3 Replies Latest reply on Aug 27, 2014 3:50 AM by dipak

    Does the OpenCL2.0 SVM support allocate memory for images?

    sky3551211

      Does the OpenCL2.0 SVM support allocate memory for images?

      We can test the SVM performance like:

       

      d_a=(float*)clSVMAlloc(context,(CL_MEM_READ_WRITE|CL_MEM_SVM_FINE_GRAIN_BUFFER|CL_MEM_SVM_ATOMICS),size,0);

      d_b=(float*)clSVMAlloc(context,(CL_MEM_READ_WRITE|CL_MEM_SVM_FINE_GRAIN_BUFFER|CL_MEM_SVM_ATOMICS),size,0);

      d_c=(float*)clSVMAlloc(context,(CL_MEM_READ_WRITE|CL_MEM_SVM_FINE_GRAIN_BUFFER|CL_MEM_SVM_ATOMICS),size,0);

      for(int i=0;i<size;i++)

      {

         d_a[i]=Initial_value;

         d_b[i]=Initial_value;

      }

      clSetKernelArgSVMPointer(kernel, 0, d_a);

      clSetKernelArgSVMPointer(kernel, 0, d_b);

      clSetKernelArgSVMPointer(kernel, 0, d_c);

       

      The SVM performance has been verified good in the example of calculation of a vector,but the clSVMAlloc() cannot allocate memory for images,

      how should we do to utilize the SVM for image processing?

      Thank you!

       

       

      The test device is like:

       

              CL_DEVICE_NAME: AMD A10-7850 APU with Radeon (TM) R7 Graphics @ 3.70GHz

              CL_DEVICE_PROFILE:      FULL_PROFILE

              CL_DEVICE_VERSION:      OpenCL 2.0 (Build 8228)

              CL_DEVICE_OPENCL_C_VERSION:     OpenCL C 2.0

        • Re: Does the OpenCL2.0 SVM support allocate memory for images?
          gopal

          Hi,

           

          As per the (section 5.6.1 from OpenCL 2.0 spec, page 166):  you should be able to use SVM for Image objects.

            "Although SVM is generally not supported for image objects, clCreateImage may create an image from a buffer (a 1D image from a buffer or a 2D image from buffer) if the buffer specified in its image description parameter is a SVM buffer. Such images have a linear memory representation so their memory can be shared using SVM."

            • Re: Re: Does the OpenCL2.0 SVM support allocate memory for images?
              sky3551211

              Hi Gopal,

                      Thanks.

                      According to the OpenCL 2.0 spec, we tried to test it like:

                      ......

                      cl_image_desc imageDesc;

                      memset(&imageDesc, '\0', sizeof(cl_image_desc));

                      imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;

                      imageDesc.image_width = width;

                      imageDesc.image_height = height;

                      imageDesc.image_row_pitch=width*pitch_align;

                      imageDesc.image_slice_pitch=imageDesc.image_row_pitch*height;

               

                    svmbuffer=(cl_uchar4*)clSVMAlloc(context,CL_MEM_READ_WRITE,width*height*sizeof(cl_uchar4),0);//We use the coarse grained buffer

                    memcpy(svmbuffer,inputImageData,width*height*sizeof(cl_uchar4));//copy the inputimagedata to the svmbuffer

                    imageDesc.mem_object=(cl_mem)svmbuffer;

                    tem_inputImage2D=clCreateImage(context,CL_MEM_READ_WRITE ,&imageFormat,&imageDesc,NULL,&status);

                    CHECK_OPENCL_ERROR(status,"tem_inputImage2Dfailed. (tem_inputImage2D)");

                   

                    The inputImageData has been varified OK, but the clCreateImage returns the error vaule: CL_INVALID_IMAGE_DESCRIPTOR.