ATOM_INC(3clc)
β¨ ATOM_INC β¨
okay bestie, welcome to ATOM_INC(3clc) β it's the 64-bit atom_inc functions from the OpenCL Manual, and honestly? she's lowkey iconic. π
πΈ NAME πΈ
atom_inc β the 64-bit atom_inc functions, periodt.
long atom_inc(volatile global(3clc) long *p, long val);
long atom_inc(volatile global(3clc) long *p, long val);
ulong atom_inc(volatile local(3clc) ulong *p, ulong val);
ulong atom_inc(volatile local(3clc) ulong *p, ulong val);
yes bestie, that's the same signature twice. that's literally what the page says. we don't question the elders. π
π¦ DESCRIPTION π¦
okay so here's the vibe. you read the 64-bit value (we're calling her old, she's the main character) that lives at the location pointed to by p. then you compute (old + 1) and store that result right back at the location pointed to by p. and the function? she hands you back old. like, the before-picture. π
if your app wants in on this extension, you gotta include this in your OpenCL program source, fr fr:
#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
this function gets done in one atomic transaction β¨. and here's the tea: those transactions are atomic for the device executing these atomic functions. but if the same memory location is getting atomic'd on by kernels running on multiple devices? no guarantee of atomicity, sorry babe, that's just how it is. π
oh and also β atomic operations on 64-bit integers and 32-bit integers (and float) are also atomic with regard to each other. slay. π
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
π 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 condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
π NOTES π
OpenCL Specificationpage 279, section 6.12.11 - Atomic Functions for 32-bit integers
and that's the whole page, bestie π this gorgeous lil doc came to you from The Khronos Group, dated 01/14/2021 β go forth and atomically increment, no cap π«Άβ¨
π¦ 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