MAD_HI(3clc)
๐ MAD_HI โ the OpenCL manual, but make it make sense ๐
okay bestie, we're in the OpenCL Manual and this is page MAD_HI(3clc). yes it's a CLC thing. yes it's giving integer-math-girlie. let's go ๐
โจ NAME โจ
mad_hi โ literally just returns mul_hi(a, b) + c. that's the whole personality. that's the vibe. ๐ฆ
โจ SYNOPSIS โจ
gentype mad_hi(gentype a, gentype b, gentype c);
โจ DESCRIPTION โจ
so mad_hi returns mul_hi(3clc)(a, b) + c. no cap. it does the high-multiply thing and then adds c on top. iconic behaviour honestly ๐
โจ NOTES โจ
okay so here's the tea, and it matters, so pay attention ๐ซถ
- built-in integer functions take scalar or vector arguments. the vector versions of the integer functions operate component-wise. and the description? it's per component. so like, think of each lane doing its own little thing โจ
- we use the generic type name
gentypeto say "hey this function can take any of these as the type for the arguments":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, orulong{2|3|4|8|16}. yes all of them. all the flavors ๐ - we also use the generic type name
ugentypeto refer to the unsigned versions ofgentype. for example, ifgentypeischar4, thenugentypeisuchar4. easy math, bestie ๐งฎ - and we use the generic type name
sgentypeto indicate that the function can take a scalar data type, i.e.char,uchar,short,ushort,int,uint,long, orulongas the type for the arguments. for built-in integer functions that takegentypeandsgentypearguments, thegentypeargument must be a vector or scalar version of thesgentypeargument. for example, ifsgentypeisuchar,gentypemust beucharoruchar{2|3|4|8|16}. for vector versions,sgentypeis implicitly widened togentypeas described in section 6.3.a of the OpenCL specification. that's the rule, no skipping it ๐ - 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. so don't be mixing, it's not that kind of party ๐
โจ 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 that whole paragraph is verbatim and it has to stay verbatim, it's a license, we do not freestyle those ๐
โจ NOTES (the footnote kind) โจ
OpenCL Specificationโ page 256, section 6.12.3 - Integer Functions ๐
and that's the whole page, bestie!! this lil gem comes to you from The Khronos Group, dated 01/14/2021, and it lives at MAD_HI(3clc). go forth and multiply-high-and-add responsibly ๐โจ๐
๐ฆ 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