I am naive OpenCL user and I am trying to run an OpenCL code on my AMD device. The program executes successfully when run for first time but fails when executed there after(system hangs) after successful termination of first execution. The kernel program is:
struct __attribute__ ((aligned (128))) ch {
unsigned long W;
unsigned long B;
};
struct __attribute__ ((aligned (128))) M {
int a;
int b;
};
struct __attribute__ ((aligned (128))) MB {
int size;
struct M mo[256] __attribute__ ((packed));
};
struct MB gen( unsigned long A )
{
int i,j;
unsigned long t;
struct MB l;
struct M mt;
l.size = -1;
//Filling array mo of struct MB on the basis of some bit-operations
for( i = 0; i < 64; i++ ) {
if( 1UL << i & A ) {
t = 0xFFFFFFFFFFFFFFFFUL;
for( j = 0; j < 64; j++ ) {
if( 1UL << j & t ) {
mt.a = i;
mt.b = j;
l.size++;
l.mo[l.size] = mt;
}
}
}
}
return l;
}
__kernel void board( __global struct ch* cc, __global struct M* mt)
{
int sid = get_global_id(0);
struct ch c = cc[sid];
struct M m;
struct MB mb;
mb = gen(c.W);
}
I do not know why this happens, but I have to reboot my system every second time I run this code. Also, code hangs in first run when I add one more call to "gen" function in kernel. Why is this happening? Please help (I am using 64 bit CentOS with AMD-APP-2.6 and ATI Catalyst 12.2 drivers.)
I have attached my main(host) file in attachments.