ATOMIC_XOR(3clc)
β¨ ATOMIC_XOR β¨
okay bestie, welcome to atomic_xor β a whole page from the OpenCL Manual (the 3clc girlies know π
) and she's lowkey iconic. buckle up π
π NAME π
atomic_xor β the atomic_xor functions, fr fr. she does exactly what it says on the tin and she does it atomically.
here's the whole squad, copy-pasted exactly so nobody comes for me:
int atomic_xor(volatile global(3clc) int *p, int val);
unsigned int atomic_xor(volatile global(3clc) unsigned int *p,
unsigned int val);
int atomic_xor(volatile local(3clc) int *p, int val);
unsigned int atomic_xor(volatile local(3clc) unsigned int *p,
unsigned int val);
πΈ DESCRIPTION πΈ
so here's the vibe π: she reads the 32-bit value (we call her old, that's her name, she's the main character) that's stored at the location pointed to by p.
then she computes (old ^ val) β yes, the XOR, the spicy bit-flip moment β¨ β and stores that result at the location pointed to by p.
and what does the function return, you ask? she returns old. the original. the before picture. π«Ά
π and listen β there's a 64-bit version of this function,atom_xor(3clc), but she's locked behindcl_khr_int64_extended_atomics(3clc). you gotta have the extension enabled to hang out with her, no cap.
π SPECIFICATION π
OpenCL Specification[1] β that's the source of truth, periodt. π
π SEE ALSO π
go read those too, bestie, they're literally right there π¦
π AUTHORS π
The Khronos Group π«‘ absolute legends, ngl.
π 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 following conditions:
the above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials. that's the deal, no take-backs π
π NOTES π
- OpenCL Specification page 279, section 6.12.11 - Atomic Functions for 32-bit integers
and that's the whole page, bestie!! π§β¨ this was from The Khronos Group, dated 01/14/2021, and it's the ATOMIC_XOR(3clc) page from the OpenCL Manual β mwah, go forth and XOR responsibly ππ
π¦ 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