SELECT(3clc)
π 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 π«Άigentypeandugentypehave to have the same number of elements and bits asgentype. matching energy only, bestie.
π NOTES π
- the argument type
gentypecan bechar,charn,uchar,ucharn,short,shortn,ushort,ushortn,int,intn,uint,uintn,long,longn,ulong,ulongn,float,floatn,double, anddoublen. that's the whole roster π₯ - the argument type
igentyperefers to signed integer types, i.e.char,charn,short,shortn,int,intn,long, andlongn. - the argument type
ugentyperefers to unsigned integer types, i.e.uchar,ucharn,ushort,ushortn,uint,uintn,ulong, andulongn. - and
nis2,3,4,8, or16. 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 π¦
relationalFunctions(3clc)β go say hi to the rest of the family, bestie
π AUTHORS π
The Khronos Group β the main characters, honestly.
π 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 (the footnote one, not the other one) β
- 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
- 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