MUL_HI(3clc)

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

πŸ’– 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 Β© 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 πŸŽ€

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