[英]error: subscripted value is not an array, pointer, or vector in a kernel
I'm working with the following code: 我正在使用以下代码:
__kernel
void addround(__global int **A, __global int *B, int kSize, int kRound, int kNb)
{
for (int i=0;i<kSize;i++){
for (int j=0;j<kSize;j++){
A[j][i]+=B[kRound*kNb*kSize+i*kNb+j];
}
}
}
And this line A[j][i]+=B[kRound*kNb*kSize+i*kNb+j];
这条线
A[j][i]+=B[kRound*kNb*kSize+i*kNb+j];
is marking an error, saying that it's not an array, pointer, or vector when I try to compile. 在标记错误,并说当我尝试编译时它不是数组,指针或向量。 I think the problem might have to do with the double pointer A, but I fail to see how.
我认为问题可能与双指针A有关,但我看不出如何解决。 Any suggestions?
有什么建议么?
Double pointers do not exist in OpenCL as an input/output. OpenCL中不存在双指针作为输入/输出。 Since the pointers are not allowed to travel from CPU <-> GPU.
由于不允许指针从CPU <-> GPU移动。
You have to manually address matrixes, this means: 您必须手动处理矩阵,这意味着:
__kernel
void addround(__global int *A, __global int *B, int kSize, int kRound, int kNb)
{
for (int i=0;i<kSize;i++){
for (int j=0;j<kSize;j++){
A[j+i*kSize]+=B[kRound*kNb*kSize+i*kNb+j];
}
}
}
NOTE: Just a small remark, the kernel code you are using is completely inefficient, it will take even longer than the CPU plain version. 注意:仅需说明一下,您正在使用的内核代码效率很低,它所花费的时间甚至比CPU普通版本更长。 I just did the minimal changes to solve your problem, thats all.
我只是做了最小的更改来解决您的问题,仅此而已。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.