简体   繁体   English

错误:下标的值不是内核中的数组,指针或向量

[英]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.

相关问题 错误:下标值不是数组、指针或向量 - Error: subscripted value is not an array, pointer, or vector 下标的值不是数组,指针或向量,当我尝试执行此内核代码时收到此错误消息 - subscripted value is not an array, pointer, or vector, i get this error message when i try to execute this kernel code 持续错误:下标值既不是数组也不是指针也不是向量 - persistent error: subscripted value is neither array nor pointer nor vector 错误:C中的下标值既不是数组也不是指针也不是矢量 - error: subscripted value is neither array nor pointer nor vector in C “错误:下标值既不是数组,也不是指针,也不是矢量” - “error: subscripted value is neither array nor pointer nor vector” 错误-下标值既不是数组也不是指针也不是向量 - error - subscripted value is neither array nor pointer nor vector 下标值既不是数组也不是指针也不是向量的错误 - Error with subscripted value being neither array nor pointer nor vector 下标值的错误既不是数组也不是指针也不是向量 - Error on subscripted value is neither array nor pointer nor vector “错误:下标值既不是数组,也不是指针,也不是矢量”,但是为什么呢? - “error: subscripted value is neither array nor pointer nor vector”, but why? 错误:下标值既不是数组也不是指针也不是向量 - Error: subscripted value is neither array nor pointer nor vector
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM