ISEQUAL(3clc)
β¨ NAME β¨
isequal β the vibe check where we ask "is x literally equal to y?" π
Manual page from the OpenCL Manual, bestie. Here's every single flavor it comes in:
int isequal(float x, float y);
intn isequal(floatn x, floatn y);
int isequal(double x, double y);
longn isequal(doublen x, doublen y);
int isequal (half x, half y) // if
half extension enabled
shortn isequal (halfn x, halfn y) //
if half extension enabled
π¦ DESCRIPTION π¦
Returns the component-wise compare of x == y. That's it, that's the whole tea. Every lane does its own little comparison, no cross-talk, no drama. π«Ά
π NOTES π
Okay so if an implementation extends this spec 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 like, NaN shows up and everyone just... keeps it moving. No exceptions raised, no meltdown. π
The built-in relational functions are extended with cl_khr_fp16(3clc) to include the appropriate versions of functions that take half, and half{2|3|4|8|16} as arguments and return values. Half-precision girlies, you're included. π
Here's the scoring system, and it's giving scalar vs vector energy:
- Scalar argument types: returns a
0if the specified relation is false, and a1if the specified relation is true. - Vector argument types: returns a
0if the specified relation is false, and a-1(i.e. all bits set) if the specified relation is true.
Not me realizing the vector version returns all-bits-set instead of a humble little 1. That's the iconic choice and honestly? Respect. π
And the NaN rule, which applies to the whole friend group:
The relational functions isequal, isgreater, isgreaterequal, isless, islessequal, and islessgreater always return 0 if either argument is not a number (NaN). Meanwhile isnotequal returns 1 if one or both arguments are not a number (NaN) and the argument type is scalar, and returns -1 if one or both arguments are not a number (NaN) and the argument type is vector. So isnotequal is out here switching up its return value based on the argument type. Main character behavior fr fr. π
π 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 π
- OpenCL Specification page 264, section 6.12.6 - Relational Functions
And that's the whole page, bestie β brought to you by The Khronos Group, dated 01/14/2021, manual section 3clc. Go forth and compare responsibly. πβ¨π¦
π¦ 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