ISUNORDERED(3clc)
๐ ISUNORDERED ๐
okay bestie, welcome to the OpenCL Manual โ yes it's a C function, yes it's giving very specific, yes you're gonna understand it. this one lives in the relational functions section of the OpenCL spec, and it's lowkey one of the most useful little guys in there. no cap. ๐ฆ
โจ NAME โจ
isunordered โ Test if arguments are unordered. ๐ซถ
and here's exactly how you call it, in every flavor it comes in:
int isunordered(float x, float y);
intn isunordered(floatn x, floatn y);
int isunordered(double x, double y);
longn isunordered(doublen x, double y);
int isunordered (half x, half y) //
if half extension enabled
shortn isunordered (halfn x, halfn y)
// if half extension enabled
wait bestie, look at thedouble/doublenones carefully โlongn isunordered(doublen x, doublen y). the return type changes depending on whether you're in scalar-land or vector-land, which is exactly the kind of chaos this function family loves. ๐
๐ DESCRIPTION ๐
so. Test if arguments are unordered. that's the whole vibe. ๐
isunordered() takes arguments x and y, and it returns non-zero if x or y is NaN, and zero otherwise. that's it. that's the function. it's a vibe check for NaN, and honestly? iconic. โจ
๐ธ NOTES ๐ธ
okay here's the part where you gotta pay attention, because this is where the spec gets real:
- If an implementation extends this specification to support IEEE-754 flags or exceptions, then all built-in relational functions shall proceed without raising the invalid floating-point exception when one or more of the operands are NaNs. so no surprise explosion, no dramatic flag, it just... handles it. slay. ๐
- The built-in relational functions are extended with
cl_khr_fp16(3clc)to include appropriate versions of functions that takehalf, andhalf{2|3|4|8|16}as arguments and return values. ๐ง - The function returns a
0if the specified relation is false and a1if the specified relation is true for scalar argument types. These functions shall return a0if the specified relation is false and a- 1(i.e. all bits set) if the specified relation is true for vector argument types.
bestie, seriously โ scalar true is1, vector true is- 1(i.e. all bits set). do NOT mix those up. it's giving "why is my mask full of all-ones, is that a bug" and no, it's the spec, it's on purpose, periodt. ๐ญ
๐ 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.
๐ NOTES ๐
(this is the footnote-y one, don't @ me, the original really does have two sections called NOTES ๐)
- OpenCL Specification page 264, section 6.12.6 - Relational Functions
okay and that's the whole page, bestie, you ate it. ๐ thanks for reading all the way down, this was brought to you by The Khronos Group on 01/14/2021, and yes the source is the OpenCL manual, mwah. go check if your floats are NaN. ๐ฆโจ๐ธ๐ซถ
๐ฆ 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