Results 1 to 4 of 4

Thread: Sending 2D data to device in openCL

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    17

    Sending 2D data to device in openCL

    Hello everyone !!

    Can I send 2 dimensional data to device? If yes then how can I do that? Means how will be the declaration of the buffer memory? And also how can I fetch/ use these values in kernel function/device ?
    Plz reply ASAP.

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    170
    Yes, of course you can do that. Two ways: Buffer and Image.
    Buffer: As on the host, dimension is just an abstraction since all memory is linear. Use Y * pitch + X to find a location.
    Image: OpenCL has 2D image support. Depending on your needs and access patterns, this might make more sense than using a buffer.

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    17

    Re:

    Quote Originally Posted by Dithermaster View Post
    Yes, of course you can do that. Two ways: Buffer and Image.
    Buffer: As on the host, dimension is just an abstraction since all memory is linear. Use Y * pitch + X to find a location.
    Image: OpenCL has 2D image support. Depending on your needs and access patterns, this might make more sense than using a buffer.
    Thanks Dithermaster!
    Actually I want to send following data to device.

    double **domimage[4];

    for (i=0; i<2; ++i)
    for (j=0; j<2; ++j)
    for (k=i; k<hsize-i; k += 2)
    for (l=j; l<vsize-j; l += 2)
    domimage[(i<<1)+j][l>>1][k>>1] =((double)image[l][k] + (double)image[l+1][k+1] +
    (double)image[l][k+1] + (double)image[l+1][k])*0.25;

    here hsize and vsize are int and used as image hieght and width. And image is a 2D array.
    I can send and use the data image by using your method. But how can I use "domimage" data?

  4. #4
    Senior Member
    Join Date
    Dec 2011
    Posts
    170
    In OpenCL 1.x buffer and image data needs to be contiguous. OpenCL 2.x SVM could support your pointer-based non-contiguous data structure but there are no shipping implementations yet. In the meantime you either need to change your data structure to be contiguous or copy it into contiguous memory before transferring it to your OpenCL device.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •