ATOMIC_ADD(3clc)

๐Ÿ“ฆ
version 1.0~svn33624 ยท 3 versions
, in ubuntu jammy, ubuntu noble

๐Ÿ’– NAME ๐Ÿ’–

okay bestie, gather round, this is atomic_add โ€” the atomic_add functions. that's it, that's the name, iconic behavior honestly โœจ

this page lives in the OpenCL Manual (3clc), so likeโ€ฆ yeah, we're in OpenCL land now ๐Ÿฆ‹

here's the whole squad, exactly as they show up:

int atomic_add(volatile global(3clc) int *p, int val);

unsigned int atomic_add(volatile global(3clc) unsigned int *p,
                        unsigned int val);

int atomic_add(volatile local(3clc) int *p, int val);

unsigned int atomic_add(volatile local(3clc) unsigned int *p,
                        unsigned int val);

four flavors, no cap ๐Ÿซถ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

okay so here's the tea, and it's actually so simple it's giving main character energy:

  • read the 32-bit value (we call it old) that's stored at the location p is pointing at ๐Ÿ‘€
  • compute (old + val) ๐Ÿงฎ
  • store that result right back at the location p points to ๐Ÿ’พ
  • and the function returns old โ€” like, the value from before you added anything, she remembers the past fr fr ๐Ÿ’…

and then, plot twist ๐ŸŒˆ โ€” there's a 64-bit version of this function, and it's called atom_add(3clc). it does NOT come free, bestie. it's only enabled by cl_khr_int64_base_atomics(3clc). no extension, no 64-bit, periodt ๐Ÿ”ฅ


๐ŸŽ€ SPECIFICATION ๐ŸŽ€

OpenCL Specification[1] ๐Ÿ‘‘


โœจ SEE ALSO โœจ

go read those too, they're the friend group ๐Ÿฆ‹


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

The Khronos Group ๐Ÿ’œ


Copyright ยฉ 2007-2011 The Khronos Group Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the following conditions:

the above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials.

like fr fr, keep the notice in there. it's not optional and it's not a vibe suggestion ๐Ÿ’€

๐Ÿ’€ NOTES ๐Ÿ’€

  1. OpenCL Specification page 279, section 6.12.11 - Atomic Functions for 32-bit integers

The Khronos Group dropped this on 01/14/2021, and the whole thing answers to the name ATOMIC_ADD(3clc) โ€” anyway that's the page, you ate it, go forth and atomically add bestie ๐Ÿซถ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from