It's not clear for me what is a purpose of built-in OpenCL function select
. Can somebody, please, clarify?
From OpenCL specification:
function select(gentype a, gentype b, igentype c)
returns: for each component of a vector type, result[i] = if MSB of c[i] is set ? b[i] : a[i].
What is a MSB in this case? I know that MSB stands for most significant bit, but I have no idea how it's related to this case.
OpenCL select
is to select elements from a pair of vectors (a, b)
, based on the truth value of a condition vector (c
), returning a new vector composed of elements from the vectors a
and b
.
The MSB (most significant bit) is mentioned here, because the truth value of a vector element is defined to be -1
and the MSB should therefore be set (as the sign bit):
a = {1 , 2} // Pseudocode for select operands
b = {3 , 4}
c = {0 ,-1}
r = {1 , 4} // The result r contains some of a and b
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With