MUL_HI(3clc)
π MUL_HI (3clc) β the OpenCL Manual, but make it make sense β¨
okay bestie, buckle up, because this one is genuinely one of the cutest little integer functions in the whole OpenCL spec and i need you to know about it π
πΈ NAME πΈ
mul_hi β returns the high half of the product of x and y. that's it. that's the whole vibe. π
gentype mul_hi(gentype x, gentype y);
π¦ DESCRIPTION π¦
so mul_hi goes ahead and computes x * y, and then β instead of handing you the whole entire product like some overachiever β it gives you back the high half of the product of x and y. the top bits. the VIP section. the upper half of the result. π
like, that's literally it, that's the function, and honestly? iconic.
β¨ NOTES β¨
okay so here's the lore you actually need π«Ά
built-in integer functions take scalar or vector arguments. the vector versions of the integer functions operate component-wise, and the description is per component. so every lane does its own lil thing and nobody's stepping on anybody's toes π
we use the generic type name gentype to say that the function can take char, char{2|3|4|8|16}, uchar, uchar{2|3|4|8|16}, short, short{2|3|4|8|16}, ushort, ushort{2|3|4|8|16}, int, int{2|3|4|8|16}, uint, uint{2|3|4|8|16}, long, long{2|3|4|8|16}, ulong, or ulong{2|3|4|8|16} as the type for the arguments. (yes bestie, that is a lot of types, and yes, you're gonna memorize the pattern. it's giving "just add a number to the end" energy β¨)
we also use the generic type name ugentype to refer to unsigned versions of gentype. for example, if gentype is char4, ugentype is uchar4. see? predictable. slay. π
and then there's sgentype, which we use to indicate that the function can take a scalar data type, i.e. char, uchar, short, ushort, int, uint, long, or ulong, as the type for the arguments. for built-in integer functions that take gentype and sgentype arguments, the gentype argument must be a vector or scalar version of the sgentype argument. for example, if sgentype is uchar, gentype must be uchar or uchar{2|3|4|8|16}. for vector versions, sgentype is implicitly widened to gentype as described in section 6.3.a of the OpenCL specification. π
and the rule that catches people out fr fr: for any specific use of a function, the actual type has to be the same for all arguments and the return type unless otherwise specified. no mixing, no matching, no chaos. π
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
integerFunctions(3clc) β go read it, it's the whole friend group π«Ά
π§ 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 following condition: the above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials.
π NOTES π
- OpenCL Specification β page 256, section 6.12.3 - Integer Functions
and that's the whole page, bestie π this one shipped from The Khronos Group and the manual page is dated 01/14/2021 β go forth and take the high half of every product you meet, no cap β¨π¦πΈ
π¦ 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