cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

skstronghold
Journeyman III

Code hangs when executed second time

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.

0 Likes
2 Replies
Wenju
Elite

Hi skstronghold,

I have run this code on Win7 64bit(AMD-APP-2.6, Opencl 1.2) , but failed. The message is "the variable 'm' is being used without being initialized". So I have fixed it, and the program runs well. So I think you'd better update your drivers and also fix the code.

Thank you.

0 Likes
nathan1986
Adept II

Are you sure that your kernel doesn't make the l.mo[l.size] out-of-array-border? try to reduce i and j in gen function from 64 to 16 and see the effect.

0 Likes