VLOAD_HALFN(3clc)

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

πŸ’– vload_halfn(3clc) β€” the OpenCL Manual, but make it make sense

okay bestie, listen. this is vload_halfn from the OpenCL Manual, and it's literally just "go get me a half-float vector out of memory and hand it back as a float vector." that's the whole vibe. no cap. πŸŽ€


✨ NAME ✨

vload_halfn β€” read a half float vector from a pointer to memory. that's it, that's the job. πŸ’…


🌸 SYNOPSIS 🌸

floatn vload_halfn(size_t offset, const __global half *p);

floatn vload_halfn(size_t offset, const __local half *p);

floatn vload_halfn(size_t offset, const __constant half *p);

floatn vload_halfn(size_t offset, const __private half *p);

four flavours, same energy. pick the one that matches where your pointer actually lives 🫢


πŸ’« DESCRIPTION πŸ’«

so here's the tea. it reads sizeof(halfn) bytes of data from the address (p + (offset * n)). and what it pulls out of there gets interpreted as a halfn value. cute.

then β€” and this is the glow-up β€” that halfn value it just read gets converted into a floatn value, and that's what gets returned. so you hand it halves, it hands you floats back. iconic behavior honestly ✨

🚨 alignment check bestie: the read address, computed as (p + (offset * n)), must be 16-bit aligned. no exceptions, no vibes-based alignment. πŸ’€

πŸ‘‘ NOTES πŸ‘‘

okay so context, because you deserve it:

  • Vector Data Load and Store Functions are the whole category here β€” they let you read and write vector types straight from a pointer to memory. very main character of them. πŸ”₯
  • the generic type gentype is the lil placeholder used to mean any of the built-in data types: char, uchar, short, ushort, int, uint, long, ulong, float, or double.
  • the generic type name gentypen means n-element vectors of gentype elements. and that little n suffix shows up in the function names too (like vloadn, vstoren, etc.), where n = 2, 3, 4, 8, or 16. so like, 2, 3, 4, 8, 16 β€” those are your options, periodt.
  • ⚠️ the scary part: the results of vector data load and store functions are undefined if the address you're reading from or writing to isn't correctly aligned. not "a little off," not "mostly fine" β€” undefined. respect the alignment fr fr 😭
  • the pointer argument p can point to global(3clc), local(3clc), or private(3clc) memory for store functions. for load functions, p can point to __global, __local, constant(3clc), or __private memory. 🧚
  • when the cl_khr_fp16(3clc) extension is doing its thing, gentypen gets extended to include half, half2, half3, half4, half8, and half16. she's expanding her range πŸ’œ
  • and a lil special-case note: vload3 and vload_half3 read the x, y, z components from the address (p + (offset * 3)) into a 3-component vector. three components, three components, three components. yes the 3 appears twice. no i will not elaborate. πŸ™ˆ

πŸ“œ SPECIFICATION πŸ“œ

OpenCL Specification[1]


πŸ¦‹ 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.

(yes bestie, the whole license paragraph, verbatim, because legal text does not get a remix πŸ’…)


⭐ NOTES (the footnote kind) ⭐

  1. OpenCL Specification page 267, section 6.12.7 - Vector Data Load and Store Functions

and that's the whole page!! thanks for coming to my ted talk, love u, go align your pointers πŸ’–

β€” The Khronos Group, dated 01/14/2021, signing off from the OpenCL Manual, page VLOAD_HALFN(3clc). slay 🫢✨

πŸ“¦ where this page comes from