ISUNORDERED(3clc)

๐Ÿ“ฆ
version 1.0~svn33624 ยท 3 versions
, in ubuntu jammy, ubuntu noble

๐Ÿ’– 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 the double/doublen ones 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 take half, and half{2|3|4|8|16} as arguments and return values. ๐Ÿงš
  • The function returns a 0 if the specified relation is false and a 1 if the specified relation is true for scalar argument types. These functions shall return a 0 if 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 is 1, 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 ยฉ 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 ๐Ÿ™ˆ)

  1. 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