ATOM_MAX(3clc)
β¨ ATOM_MAX β¨
okay bestie, gather round, we're doing 64-bit atom_max functions from the OpenCL manual (3clc) and honestly? she's iconic. let's get into it π
πΈ NAME πΈ
atom_max β the 64-bit atom_max functions. that's it, that's the name, short and sweet, main character energy π
π SYNOPSIS π
here's the whole squad, verbatim, no edits, no cap:
long atom_max(volatile global(3clc) long *p, long val);
long atom_max(volatile global(3clc) long *p, long val);
ulong atom_max(volatile local(3clc) ulong *p, ulong val);
ulong atom_max(volatile local(3clc) ulong *p, ulong val);
yes, two of them are literally identical to the two above them. not me noticing. we don't question the lore, we just report it π
π¦ DESCRIPTION π¦
okay so the vibe here is: read the 64-bit value (she's referred to as old) stored at the location pointed to by p. then compute commonMin(3clc) (old, val) and store that minimum value at the location pointed to by p. and what does the function hand back to you? old. she returns the original. queen behavior β¨
important extension tea: an application that wants to use this extension will need to include this in the OpenCL program source:
#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
this function is performed in one atomic transaction. these transactions are atomic for the device executing these atomic functions. but bestie, listen β there is no guarantee of atomicity if the atomic operations to the same memory location are being performed by kernels executing on multiple devices. so like, keep it on one device or accept the chaos π
and the fun cross-type lore: atomic operations on 64-bit integers and 32-bit integers (and float) are also atomic with regard to each other. slay π«Ά
side eye moment: the function is called atom_max but the description says it computes the minimum. i am simply reading the manual out loud, bestie. iykyk π
π SPECIFICATION π
OpenCL Specification[1] β that's the whole thing, she's brief and she knows it π
β SEE ALSO β
go read these next, bestie, they're the friend group:
π AUTHORS π
The Khronos Group. legends, fr fr π
πΈ 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.
(that's the legal bit, and yes, we keep every word of it, no skipping, no summarizing, because rules are rules π )
π NOTES π
- OpenCL Specification β page 279, section 6.12.11 - Atomic Functions for 32-bit integers
and that's the whole page, bestie!! this one was brought to you by The Khronos Group, dated 01/14/2021, and it lives in the manual as ATOM_MAX(3clc). stay atomic, stay iconic, don't cross devices with your atomics πβ¨π¦
π¦ 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