ATOMIC_ADD(3clc)
๐ 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 ๐
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 ๐
- 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
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 ยท other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 ยท other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms