VSTOREN(3clc)
π VSTOREN π (that's the 3clc one, from the OpenCL Manual, bestie)
okay so real talk, this page is about vstoren and it lives in section 3clc of the OpenCL manual. sit down, hydrate, and let's get into it π«Ά
β¨ NAME β¨
vstoren β write sizeof bytes (gentypen) to memory. literally just yeeting a whole vector into memory in one go π
here's the whole squad of signatures, exactly as they are:
void vstoren(gentypen data, size_t offset, __global gentype *p);
void vstoren(gentypen data, size_t offset, __local gentype *p);
void vstoren(gentypen data, size_t offset, __private gentype *p);
πΈ DESCRIPTION πΈ
so what it does: it writes sizeof(gentypen) bytes, given by data, to the address (p + (offset * n)). that's the whole vibe. π«
but here's the part where you gotta pay attention, because alignment is NOT a suggestion, it's a personality trait:
- the address computed as
(p + (offset * n))must be 8-bit aligned ifgentypeischaroruchar - it must be 16-bit aligned if
gentypeisshort,ushort, orhalf - it must be 32-bit aligned if
gentypeisint,uint, orfloat - it must be 64-bit aligned if
gentypeislongorulong
like, the alignment has to match the type. it's giving "dress code but for memory addresses" π
π¦ NOTES π¦
Vector Data Load and Store Functions are the ones that let you read and write vector types from a pointer to memory. iconic behavior honestly. β¨
the generic type gentype is used to indicate these built-in data types: char, uchar, short, ushort, int, uint, long, ulong, float, or double.
the generic type name gentypen represents n-element vectors of gentype elements. the suffix n also shows up in the function names (i.e. vloadn, vstoren, etc.), where n = 2, 3, 4, 8, or 16. so like, n is not playing around, it's one of exactly those five numbers. π
β οΈ big warning energy: the results of vector data load and store functions are undefined if the address being read from or written to is not correctly aligned. not "a little weird", not "slightly off" β undefined. do not test this. π
for store functions, the pointer argument p can be a pointer to global(3clc), local(3clc), or private(3clc) memory. for load functions, the pointer argument p can be a pointer to __global, __local, constant(3clc) or __private memory.
when extended by the cl_khr_fp16(3clc) extension, the generic type gentypen gets extended to include half, half2, half3, half4, half8, and half16. slay π
also, quick lil fact: vstore3, and vstore_half3 write x, y, z components from a 3-component vector to address (p + (offset * 3)). yes, times three, because three components. math is mathing. π§
π SPECIFICATION π
OpenCL Specification[1]
β SEE ALSO β
vectorDataLoadandStoreFunctions(3clc)
π 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.
π NOTES π
- OpenCL Specification page 267, section 6.12.7 - Vector Data Load and Store Functions
and that's the whole page bestie!! brought to you by The Khronos Group, dated 01/14/2021, no cap. go forth and align your pointers correctly, i'm begging ππβ¨
π¦ 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