Results 1 to 2 of 2

Thread: Is there any way of making a particular thread to wait for o

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    2

    Is there any way of making a particular thread to wait for o

    <pre>

    __kernel
    void example(__global int *a, __global int *dependency, uint cols)
    {
    int j = genter code hereet_global_id(0);
    int i = get_global_id(1);
    if(i > 0 && j > 0)
    {
    while(1)
    {
    test = 1;
    }
    //Wait for the dependents

    -----------------------------

    --------------------------
    }
    }

    </pre>
    In the above kernel code why the while loop is just skipped in all the threads with out infinitely looping. Any ideas on this.
    I'm working on some interesting problem which requires a thread to wait for some other threads to finish based on some criteria but every time while of above or while(wait_condition) is skipped when it is being run on GPU.

    Is there any other way of making a particular thread to wait for the other threads in OpenCL kernel on GPU?

    Thanks in advance!

  2. #2
    Senior Member
    Join Date
    Aug 2011
    Posts
    271

    Re: Is there any way of making a particular thread to wait f

    Please read up on the memory model of opencl c - it uses a relaxed memory model where for example memory accesses may be cached in registers.

    You probably want to use barriers and local memory (although to be honest it's impossible to tell from your example fragment what you're even trying to accomplish), and/or maybe atomics.

    They are well described in the opencl specification and the vendor programming guides.

    One hint: you cannot synchronise outside of a workgroup: simply because the hardware may be incapable of running all work items concurrently, and so there is no way to talk to work items which haven't started yet/have already finished.

Similar Threads

  1. Wait if CL_DEVICE_NOT_AVAILABLE is returned?
    By clint3112 in forum OpenCL
    Replies: 4
    Last Post: 11-15-2012, 09:38 AM
  2. OpenCL CL_OUT_OF_RESOURCES on event.wait()
    By Henrik23 in forum OpenCL
    Replies: 5
    Last Post: 11-20-2010, 03:01 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
  •