如何解决OpenCL vstoren不在标量数组中存储矢量
我的内核如下。 我的问题是为什么vstore8不起作用?当在主机代码中打印输出时,它仅返回0。 我在代码中放入了“ if(all(v == 0)== 1)”,以检查是否将值从int4 *复制到v中的int8时是否引起了错误,但事实并非如此。 看来vstoren什么也没做。 我是OpenCL的新手,所以感谢您的帮助。
__kernel void select_vec(__global int4 *input1,__global int *input2,__global int *output){
//copy values in input arrays to vectors
int i = get_global_id(0);
int4 vA = input1[i];
int4 vB = input1[i+1];
__private int8 v = (int8)(vA.s0,vA.s1,vA.s2,vA.s3,vB.s0,vB.s1,vB.s2,vB.s3);
__private int8 v1 = vload8(0,input2);
__private int8 v2 = vload8(1,input2);
int8 results;
if(any(v > 10) == 1){
//if there is any of the elements in v that are greater than 10
// copy the corresponding elements from v1 for elements greater than 10
// for elements less than or equal to 17,copy the corresponding elements from v2
results = select(v1,v2,v > 10);
}else{
//results is the combination of the first half of v2 and v2
results = (int8) (v1.lo,v2.lo);
}
/* for testing of the error is due to vstoren */
// results = (int8) (1);
//store results in output array
vstore8(results,i,output);
}
解决方法
您是说->makeHidden('requestee.email')
,int8 v1 = vload8(i+0,input2);
和int8 v2 = vload8(i+1,input2);
吗?
当前,您从vstore8(results,i,output);
中的相同内存地址(input2
为0-7,v1
为8-15)读取并写入{{1} }(0-7)和 all 个线程。这是一种竞态条件,因为根据v2
和最后写入output
的线程,您可以获得随机不同的结果。但是,如果v
在地址0-15中以output
开头,并且input2
用所有0s
初始化,它将保留全部output
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。