SELECT(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’… SELECT β€” the choose-y one (3clc)

okay bestie, this is the OpenCL Manual page for select, and it's genuinely one of the cutest little built-ins out there. it's giving "pick me, choose me" but for vector components. let's go ✨


✨ NAME ✨

select β€” for each component of a vector type, result[i] = if MSB of c[i] is set ? b[i] : a[i]. For scalar type, result = c ? b : a.

and here's the whole squad of signatures, no cap:

gentype select(gentype a, gentype b, igentype c);

gentype select(gentype a, gentype b, ugentype c);

halfn select (halfn a, halfn b, shortn
c)      // if half extension enabled

halfn select (halfn a, halfn b, ushortn
c)      // if half extension enabled

🌸 DESCRIPTION 🌸

so for every single component of a vector type, it's literally:

result[i] = if MSB of c[i] is set ? b[i] : a[i].

and for the scalar type girlies, it's result = c ? b : a. periodt.

heads up 🫢 igentype and ugentype have to have the same number of elements and bits as gentype. matching energy only, bestie.

πŸŽ€ NOTES πŸŽ€

  • the argument type gentype can be char, charn, uchar, ucharn, short, shortn, ushort, ushortn, int, intn, uint, uintn, long, longn, ulong, ulongn, float, floatn, double, and doublen. that's the whole roster πŸ”₯
  • the argument type igentype refers to signed integer types, i.e. char, charn, short, shortn, int, intn, long, and longn.
  • the argument type ugentype refers to unsigned integer types, i.e. uchar, ucharn, ushort, ushortn, uint, uintn, ulong, and ulongn.
  • and n is 2, 3, 4, 8, or 16. those are the only sizes, iykyk πŸ’…

also, 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 drama, no exceptions raised πŸ™ˆ

and the built-in relational functions get 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. she's versatile like that πŸ’–


🌈 SPECIFICATION 🌈

OpenCL Specification[1] β€” iconic, we stan.


πŸ¦‹ SEE ALSO πŸ¦‹


πŸ‘‘ AUTHORS πŸ‘‘

The Khronos Group β€” the main characters, honestly.


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 (the footnote one, not the other one) ⭐

  1. OpenCL Specification β€” page 264, section 6.12.6 - Relational Functions

and that's the whole page, bestie!! 🫢 this beauty is brought to you by The Khronos Group, version dated 01/14/2021, and it lives in the SELECT(3clc) chapter of the OpenCL Manual. slay, study, and go select some components πŸ’…βœ¨

πŸ“¦ where this page comes from