Results 1 to 2 of 2

Thread: Atomics and flushing

  1. #1

    Atomics and flushing

    I have the following code:

    if (localID == 0) {

    for (int i=0; i<49; i++) {
    aux+=count[i];
    atom_add(&cov[idy], aux);
    }
    }

    The problem is that if I just want to save those sums on cov array (which is global), outside the kernel I can read the data and everything is fine. But, if I want to do this after:

    *f = cov[0];

    The values stored on cov array (on any of its positions) are not consistent yet, even if before this line I put a fence or barrier. In this case, shouldn't occur some sort of flushing on the atomic operations so the values on cov[] could be used?

    Thanks

  2. #2
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Atomics and flushing

    I'm not sure I completely understand but maybe some of this will help. atom_add returns the old value before the add so you can use that to determine what the value is after the add. This will get you cov[idy], at any rate.

    If you want cov[0] at some point, you will get a version of that that is consistent with all the other atom_adds that may be executing. That is, you will not get the value half-way through an atom_add, but you are not guaranteed to get a value after all your kernels have finished. There is no way to do that in OpenCL except to wait for the kernel to finish and then run another kernel. (You can do this within a work-group by using a barrier.)

Similar Threads

  1. Cache flushing after 'clEnqueueNDRangeKernel'
    By nimitnigania in forum OpenCL
    Replies: 1
    Last Post: 03-11-2013, 02:11 AM
  2. 16 bit integer Atomics
    By thesmileman in forum Suggestions for next release
    Replies: 5
    Last Post: 12-15-2011, 03:22 PM

Posting Permissions

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