Results 1 to 2 of 2

Thread: atomics for shared memory variables?

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    26

    atomics for shared memory variables?

    Hi all,

    I haven't posted in the Message Boards for a while! However I'd like to thank you for all the help you did to me in all my previous questions!

    My question is about atomics, could I perform an atomic operation on a variable in shared memory? (__local)

    If not then how can I create an efficient semaphor on some variable or data structure in the shared memory???

    Thanks in advance

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

    Re: atomics for shared memory variables?

    Quote Originally Posted by naroqueen
    Hi all,
    I haven't posted in the Message Boards for a while! However I'd like to thank you for all the help you did to me in all my previous questions!

    My question is about atomics, could I perform an atomic operation on a variable in shared memory? (__local)
    See the opencl1.1 reference manual 6.11.11 "Atomic Functions".

    "6.11.11 Atomic Functions
    The OpenCL C programming language implements the following functions that provide atomic operations on 32-bit signed, unsigned integers and single precision floating-point50 to locations in __global or __local memory."

    e.g. see the prototypes:

    int atomic_add(volatile __global int *p, int val)
    unsigned int atomic_add(volatile __global unsigned int *p, unsigned int val)
    int atomic_add(volatile __local int *p, int val)
    unsigned int atomic_add(volatile __local unsigned int *p, unsigned int val)

    Shows that atomic_add can either be used on a global or local pointer, with signed or unsigned integers.

    (in opencl 1.0 atomics are an extension, listed in section 9.5, and begin with atom_)

    If not then how can I create an efficient semaphor on some variable or data structure in the shared memory???
    If you're trying to use GPU `threads' the same way as CPU threads, then you'll be disappointed, they're not the same thing: so using the same serialisation primitives you'd use for multi-threaded cpu code may not work very well at all.

Similar Threads

  1. Replies: 2
    Last Post: 11-22-2011, 04:05 PM
  2. different local variables share memory?
    By oakus in forum OpenCL
    Replies: 2
    Last Post: 12-17-2010, 02:15 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
  •