ATOMIC_XOR(3clc)

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

✨ 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 behind cl_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 Β© 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 πŸ“

  1. 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