ATOM_INC(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

✨ 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 Β© 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 πŸ“

  1. OpenCL Specification page 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