Results 1 to 5 of 5

Thread: A simple technical question about memory access.

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    29

    A simple technical question about memory access.

    Hi all,

    let's assume the following kernel:

    Code :
    #define nx      (signed)get_global_id(0)
    #define ny      (signed)get_global_id(1)
    #define Nx      (signed)get_global_size(0)
    #define Ny      (signed)get_global_size(1)
     
    __kernel void parallelSum(__global float* matrix, __global float* sum)
    {
        sum[0] += matrix[nx + Nx * ny];
    }

    All work items have to access sum[0] at some point. But this can happen only sequentially. So actually there is not much parallelization in this example, right?

  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    4

    Re: A simple technical question about memory access.

    It wont work as intended although it wont throw out any errors. I imagine its because without synchronization of some sort the sum variable is not synced and hence doesnt get updated in anything nearing sequential.

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    29

    Re: A simple technical question about memory access.

    Quote Originally Posted by jam383
    It wont work as intended ...
    Actually it does. I thought OpenCL takes care of synchronization in such cases. Am I wrong?

  4. #4
    Junior Member
    Join Date
    Mar 2012
    Posts
    29

    Re: A simple technical question about memory access.

    You're right. It doesn't work like I thought. Thanks.

  5. #5
    Senior Member
    Join Date
    Dec 2011
    Posts
    161

    Re: A simple technical question about memory access.

    This is a reduction operation. There are ways to parallelize reductions, but they are obviously more complex than doing it serially. Search for "OpenCL parallel reduction" for ideas. "Divide and conquer" and use fast shared memory for partial results. Save the atomic operations for the last step.

Similar Threads

  1. Local memory access question in the specification
    By ikedanaruki in forum OpenCL
    Replies: 3
    Last Post: 10-26-2009, 11:36 AM

Posting Permissions

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