Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCL built-in function 'select'

Tags:

opencl

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.

like image 810
Volodymyr Avatar asked Dec 27 '22 13:12

Volodymyr


1 Answers

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
like image 91
grrussel Avatar answered Feb 24 '23 06:02

grrussel