MAX(3clc)
π MAX (3clc) π
bestie. sit down. we're reading the OpenCL Manual page for max and honestly? it's giving short-and-sweet icon behavior. no cap, this one is genuinely easy. let's go π«Ά
β¨ NAME β¨
max β returns the greater of two values. that's it. that's the whole gig. slay π
here are the signatures, exactly as they live in the spec, do not touch them:
gentype max(gentype x, gentype y);
gentypef max(gentypef x, float y);
gentyped max(gentyped x, double y);
gentype max (gentype x, half y) //
if half extension enabled
πΈ DESCRIPTION πΈ
so max returns y if x < y, otherwise it returns x. literally just "which one's bigger, bestie" energy. the greater one walks away with the crown π
β οΈ but listen β ifxandyare infinite orNaN, the return values are undefined. undefined!! not "we'll figure it out", not "it'll be fine", undefined. do not come crying to me when yourNaNdoesNaNthings π
π NOTES π
okay this is the part where the spec explains its own nickname system, and it's actually kind of cute once you get it:
- the generic type name
gentypeis used to indicate that the function can takefloat,float2,float3,float4,float8,float16,double,double2,double3,double4,double8, ordouble16as the type for the arguments. sogentype= "any of these, pick your fighter" π - the generic type name
gentypefis used to indicate that the function can takefloat,float2,float3,float4,float8, orfloat16as the type for the arguments. thefis for float, obviously, keep up π - the generic type name
gentypedis used to indicate that the function can takedouble,double2,double3,double4,double8, ordouble16as the type for the arguments. and thedis for double. symmetry, we love her β¨
also, important vibe check: the built-in common functions are implemented using the round to nearest even rounding mode. remember that, it matters, iykyk π§
and if extended with cl_khr_fp16(3clc), generic type name gentype may indicate half and half{2|3|4|8|16} as arguments and return values. so half girlies are welcome too, but only with the extension enabled π₯
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
go read that one next, it's the friend group this function runs with π¦
π AUTHORS π
The Khronos Group
(the legends themselves, no cap π)
β 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 conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Materials.
the lawyers made me say it, but fr fr it's a very chill license. free to use, just keep the notice. periodt π
π NOTES (the footnote kind) π
OpenCL Specificationpage 260, section 6.12.4 - Common Functions
and that's the whole page, bestie, you ate it π
β¨ this was OpenCL Manual, MAX(3clc), courtesy of The Khronos Group, dated 01/14/2021. mwah, go call max on something π«ΆπΈ
π¦ 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