0
votes

I have some problem when working on OpenCL using Xcode. To handle the project, the shortest path form a point to another point in a grid should be found. Since I'm not familiar with Kernel programming, I need someone to help me figure out what's wrong in my code. The kernel is a Bidirectional bfs.

The function

ret = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);

return Error-11 to ret(when the line below disabled by the only comment works)

This is the kernel of Bi-directional BFS.

__kernel void BFS(__global int *dist,__global bool *blocked,__global char *visited,__global int2 *startpt,int N,int M,__global int* debug_arr){

    int i=get_global_id(0),queue[N*M],qr=0,dx[4]={0,1,0,-1},dy[4]={1,0,-1,0},s,d;
    debug_arr[i]=i+1;



    int px=startpt[i].x,py=startpt[i].y;



    queue[qr++]=px*M+py;

    for(s=0;s<qr ;++s){
        px=queue[s]/M,py=queue[s]%M;
        for(d=0;d<4 ;++d){
            int nx=px+dx[d],ny=py+dy[d];
            if(nx<0||nx>N||ny<0||ny>M||blocked[nx*M+ny]||visited[nx*M+ny]==visited[px*M+py])continue;
            if(visited[nx*M+ny]==0 && visited[nx*M+ny]!=visited[px*M+py]){
                dist[nx*M+ny]=dist[px*M+py]+1;
                visited[nx*M+ny]=visited[px*M+py];
                //queue[qr++]=nx*M+ny;

            }

            else if(visited[nx*M+ny]!=visited[px*M+py]){
                debug_arr[i]=dist[nx*M+ny]+dist[px*M+py]+1;
            }
        }   
    }
}

Building failed(error -11) when the line //queue[qr++]=nx*M+ny; is enable. I need a explanation.

1

1 Answers

1
votes

I would recommend getting program build log using clGetProgramBuildInfo [1] API function.