FDIM(3clc)
π fdim β the OpenCL Manual, bestie edition π
okay so you opened fdim(3clc) from the OpenCL Manual and you're like "what is this tiny lil function" β bestie it's SO simple and SO useful, let's go π«Ά
β¨ NAME β¨
fdim β the positive difference between x and y. that's it. that's the whole vibe. π
gentype fdim(gentype x, gentype y);
πΈ DESCRIPTION πΈ
okay so here's the tea β fdim computes x - y if x is greater than y. and if x is less than or equal to y? it gives you +0. no negatives, no drama, just zero. it's giving "clamp at the floor" energy fr fr β¨
π¦ NOTES π¦
- The vector versions of the math functions operate component-wise. The description is per-component. so every lane does its own lil thing independently π
- The built-in math functions are not affected by the prevailing rounding mode in the calling environment, and they always return the same value as they would if called with the round to nearest even rounding mode. consistent queen behavior π
- The built-in math functions take scalar or vector arguments. For any specific use of these functions, the actual type has to be the same for all arguments and the return type unless otherwise specified. no mixing, no matching, sorry babe π
- 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. that's a LOT of options and honestly? slay π - If extended with
cl_khr_fp16(3clc), the generic type namegentypemay indicatehalfandhalf{2|3|4|8|16}as arguments and return values. tiny floats, big energy π§ - The generic type name
gentypefis used to indicate that the function can takefloat,float2,float3,float4,float8, orfloat16as the type for the arguments. floats only, periodt π - The generic type name
gentypedis used to indicate that the function can takedouble,double2,double3,double4,double8, ordouble16as the type for the arguments. doubles only, also periodt π
not me listing every single generic type name because the manpage said so and we do NOT skip parts here π€
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
mathFunctions(3clc)β go read the whole family, iykyk π₯
π 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.
like yes bestie, you can use it, just keep the notice in there okay? don't be that person π
π NOTES π
- OpenCL Specification page 244, section 6.12.2 - Math Functions
and that's the whole page, bestie!! π₯³ shoutout to The Khronos Group, this page is from 01/14/2021 β go forth and compute your positive differences, you absolute main character πβ¨πΈ
π¦ 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