ATOMIC_SUB(3clc)

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

✨ ATOMIC_SUB ✨

okay bestie, welcome to atomic_sub from the OpenCL Manual β€” it's giving very niche, very powerful, very atomic πŸ’…


🌸 NAME 🌸

atomic_sub β€” the atomic_sub functions, obviously. no crumbs. πŸ’–

Here's the whole squad of them, exactly as they show up:

int atomic_sub(volatile global(3clc) int *p, int val);

unsigned int atomic_sub(volatile global(3clc) unsigned int *p,
                        unsigned int val);

int atomic_sub(volatile local(3clc) int *p, int val);

unsigned int atomic_sub(volatile local(3clc) unsigned int *p,
                        unsigned int val);

so there's four of them: global or local address space, int or unsigned int. pick your fighter 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the whole vibe. this function reads the 32-bit value chilling at the location pointed to by p β€” and we're calling that value old β€” then it computes (old - val) and stores that result back at the location pointed to by p. and then? it returns old. periodt. πŸ’«

not me casually reminding you that the subtraction is atomic, like nothing else can sneak in between the read and the write. main character energy fr fr. πŸ‘‘

and listen β€” there's a 64-bit version of this whole situation, atom_sub(3clc), and the way you unlock it is by enabling cl_khr_int64_base_atomics(3clc). iykyk. πŸ”₯


🌈 SPECIFICATION 🌈

OpenCL Specification[1] ✨


πŸ’œ SEE ALSO πŸ’œ

go read those too bestie, they're iconic in their own right 🌸


πŸŽ€ 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.

(yes bestie, that's the whole thing, every word, we do NOT skip the legal bits πŸ’…)


🧚 NOTES 🧚

  1. OpenCL Specification page 279, section 6.12.11 - Atomic Functions for 32-bit integers

okay that's the whole page!! tysm for reading, this was authored by The Khronos Group, dated 01/14/2021, and it lives under the name ATOMIC_SUB(3clc) in the OpenCL Manual. mwah, go atomically subtract something πŸ’–βœ¨

πŸ“¦ where this page comes from