FMOD(3clc)
π FMOD β the OpenCL Manual's cutest little remainder machine π
okay bestie, gather round, because we're reading FMOD(3clc) from the OpenCL Manual and honestly? it's giving "math but make it modular." β¨
β¨ NAME β¨
fmod β Modulus. Returns x - y * trunc (x/y).
gentype fmod(gentype x, gentype y);
like. that's the whole vibe. it's the modulo function, she's simple, she's iconic, she does exactly what she says on the tin. π
π¦ DESCRIPTION π¦
Modulus, babes. It returns x - y * trunc(3clc) (x/y).
periodt. that's the formula. no notes. π
πΈ NOTES πΈ
okay so here's the fine print, and it's lowkey important, so lock in π₯
- The vector versions of the math functions operate component-wise. The description is per-component. meaning every lil lane of your vector does its own thing, independently, no cross-talk, no drama. π
- 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. so whatever chaos your environment is doing? she does not care. she is unbothered. she is consistent. π
- The built-in math functions take scalar or vector arguments. For any specific use of these function, the actual type has to be the same for all arguments and the return type unless otherwise specified. no mixing and matching bestie, everyone shows up in the same outfit or nobody goes. π«Ά
- 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? we love a flexible queen. β¨ - If extended with
cl_khr_fp16(3clc), generic type namegentypemay indicatehalfandhalf{2|3|4|8|16}as arguments and return values. half-precision girlies rise up π§ - 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. thedis for double. double the precision, double the slay π
β SPECIFICATION β
OpenCL Specification[1]
iykyk. the receipts are in the footnote, scroll down bestie π«Ά
π SEE ALSO π
go read that one next, it's the whole friend group and fmod is just one member of the squad π
π 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.
(the original says "the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials" β so yeah, keep the notice, it's the rules, no cap π«Ά)
π NOTES π
- OpenCL Specification β page 244, section 6.12.2 - Math Functions
and that's the whole page bestie!! π this was FMOD(3clc) from The Khronos Group, dated 01/14/2021, and honestly? she ate. π
β¨ no crumbs. go forth and take remainders responsibly, mwah ππ¦π
π¦ 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