VLOAD_HALFN(3clc)
π 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
gentypeis the lil placeholder used to mean any of the built-in data types:char,uchar,short,ushort,int,uint,long,ulong,float, ordouble. - the generic type name
gentypenmeans n-element vectors ofgentypeelements. and that littlensuffix shows up in the function names too (likevloadn,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
pcan point toglobal(3clc),local(3clc), orprivate(3clc)memory for store functions. for load functions,pcan point to__global,__local,constant(3clc), or__privatememory. π§ - when the
cl_khr_fp16(3clc)extension is doing its thing,gentypengets extended to includehalf,half2,half3,half4,half8, andhalf16. she's expanding her range π - and a lil special-case note:
vload3andvload_half3read thex,y,zcomponents from the address(p + (offset * 3))into a 3-component vector. three components, three components, three components. yes the3appears twice. no i will not elaborate. π
π SPECIFICATION π
OpenCL Specification[1]
π¦ SEE ALSO π¦
π AUTHORS π
The Khronos Group
π 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 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) β
OpenCL Specificationpage 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
- 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