OpenCL内置功能“选择" [英] OpenCL built-in function 'select'

查看:93
本文介绍了OpenCL内置功能“选择"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不清楚内置的OpenCL函数select的用途是什么.有人可以澄清一下吗?

It's not clear for me what is a purpose of built-in OpenCL function select. Can somebody, please, clarify?

根据OpenCL规范:

From OpenCL specification:

功能 select(基因型a,基因型b,基因型c)

返回:对于矢量类型的每个分量,结果[i] =是否设置了c [i]的MSB? b [i]:a [i].

在这种情况下,什么是MSB?我知道MSB代表最高有效位,但是我不知道它与这种情况有何关系.

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将基于条件向量(c)的真值从一对向量(a, b)中选择元素,并返回一个由向量​​ab的元素组成的新向量.

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.

此处提到了MSB(最高有效位),因为矢量元素的真值定义为-1,因此应设置MSB(作为符号位):

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

这篇关于OpenCL内置功能“选择"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆