7

我是 OpenCL 的初学者,我正在尝试使以下内核工作。当我运行程序时,我在内核程序的构建过程中遇到错误。更具体的错误如下:

Error: Failed to build program executable!
<program source>:19:64: error: invalid address space for argument to __kernel function
__kernel void accelarate_flow(__global const          t_param  params,
                                                               ^

你可以在这里看到内核。一开始我认为这是因为我没有在内核中定义结构,但即使我添加了它们,问题仍然存在。我在这里做错了什么?

const char *accelerate_flow_kernel_source =  
#pragma OPENCL EXTENSION cl_khr_fp64 : enable                                 
typedef struct                                                                
{                                                                             
  int    nx;                                                                  
  int    ny;                                                                  
  int    maxIters;                                                            
  int    reynolds_dim;                                                        
  double density;                                                             
  double accel;                                                               
  double omega;                                                               
} t_param;                                                                    

typedef struct                                                                
{                                                                             
  double speeds[9];                                                           
} t_speed;                                                                    

__kernel void accelarate_flow(__global const          t_param  params,        
                              __global const          int*     obstacles,     
                              __global                t_speed* cells,         
                                       const unsigned int      count)         
{                                                                             
  int pos = get_global_id(0);                                                 
  if(pos >= count || pos % params.nx != 0) return;                            
  double w1,w2;                                                               
  w1 = params.density * params.accel / 9.0;                                   
  w2 = params.density * params.accel / 36.0;                                  
  if(!obstacles[pos] &&                                                       
     (cells[pos].speeds[3] - w1) > 0.0 &&                                     
     (cells[pos].speeds[6] - w2) > 0.0 &&                                     
     (cells[pos].speeds[7] - w2) > 0.0 )                                      
  {                                                                           
    cells[pos].speeds[1] += w1;                                               
    cells[pos].speeds[5] += w2;                                               
    cells[pos].speeds[8] += w2;                                               
    cells[pos].speeds[3] -= w1;                                               
    cells[pos].speeds[6] -= w2;                                               
    cells[pos].speeds[7] -= w2;                                               
  }                                                                           
}                                                                             
4

1 回答 1

5

global是一个指针限定符(地址空间),所以你必须通过global const t_param* params.

于 2012-04-04T20:32:37.587 回答