cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

sky3551211
Journeyman III

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

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=Initial_value;

   d_b=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

Tags (1)
0 Likes
3 Replies
gopal
Staff
Staff

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

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

0 Likes
sky3551211
Journeyman III

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

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.

0 Likes
dipak
Staff
Staff

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

Hi,

I'm tracking this thread. Has your problem been solved or are you still facing the problem?

Regards,

0 Likes