ATOM_MIN(3clc)

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

πŸ’– NAME πŸ’–

atom_min β€” the 64-bit atom_min functions, bestie. Yes, both of them. Multiple times. You'll see. ✨

long atom_min(volatile global(3clc) long *p, long val);

long atom_min(volatile global(3clc) long *p, long val);

ulong atom_min(volatile local(3clc) ulong *p, ulong val);

ulong atom_min(volatile local(3clc) ulong *p, ulong val);

iykyk β€” that's the whole signature list, exactly as it comes, no editing from me. πŸŽ€


🌸 DESCRIPTION 🌸

Okay so here's the vibe. You point it at a location p, it goes and reads the 64-bit value chillin' there β€” we're calling that one old β€” then it computes commonMin(3clc) of (old, val) and stores the minimum value right back at the location p points to. And what does it hand you back? old. That's it. That's the function. πŸ’…

If you're an application that wants to use this extension, you literally need to include this in your OpenCL program source, no cap:

#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable

Now the important part, so listen up: this function is performed in one atomic transaction. These transactions are atomic for the device executing these atomic functions. But β€” and this is the big but β€” 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, one device? Slay. Multiple devices touching the same spot? Chaos, fr fr.

Also iconic: atomic operations on 64-bit integers and 32-bit integers (and float) are also atomic with regard to each other. The way they all just coexist like that. πŸ¦‹


πŸ“œ SPECIFICATION πŸ“œ

OpenCL Specification<sup>[1]</sup>


πŸ‘€ 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, babe 🫢 this masterpiece of a manual page came to you from The Khronos Group, dated 01/14/2021, filed under ATOM_MIN(3clc) β€” go forth and atomically minimize responsibly πŸ’œβœ¨

πŸ“¦ where this page comes from