JanS

segment fault / memory error

Discussion created by JanS on May 19, 2010
Latest reply on May 19, 2010 by JanS

hi,

the following code crashes my program and i dont know why.

if i use local arrays (of size ~ 1400) and write to an external buffer -> CRASH

if i use local arrays and dont write to an external buffer -> NO CRASH

if i write to an external buffer and dont use local arrays -> NO CRASH

i write the global id to the externel buffer and just 5 to the local arrays, so they shouldnt depend on each other.

edit: this only happens if i use CL_DEVICE_TYPE_CPU, GPU just works fine... ?

 

 

 

works, most code outcommented __kernel void aida( __global unsigned long* membuff ) { const size_t gl_id = get_global_id(0); // global id = unique id(0 till membuff.count - 1) /* const int TMAX = 1200; const int TMIN = 1199; unsigned long lk[288+1200]; unsigned long summe = 0; for (int count2 = 0; count2 < 256; count2++) { for(int t = 0; t < 288; ++t) { lk[t] = count2; } for(int t = 1; t < TMAX; ++t) { if(t >= TMIN) { //summe = 1 & (lk[t+243] ^ lk[t+288] ^ lk[t+66] ^ lk[t+93] ^ lk[t+162] ^ lk[t+177]); } lk[287] = 5;//lk[t+243] ^ lk[t+288] ^ lk[t+69] ^ (lk[t+286] & lk[t+287]); lk[93] = 5;//lk[t+66] ^ lk[t+93] ^ lk[t+171] ^ (lk[t+91] & lk[t+92]); lk[177] = 5;//lk[t+162] ^ lk[t+177] ^ lk[t+264] ^ (lk[t+175] & lk[t+176]); } //summe ^= lk[1400]; } // count2 */ membuff[gl_id] = gl_id; } works, no crashes.... __kernel void aida( __global unsigned long* membuff ) { const size_t gl_id = get_global_id(0); // global id = unique id(0 till membuff.count - 1) const int TMAX = 1200; const int TMIN = 1199; unsigned long lk[288+1200]; unsigned long summe = 0; for (int count2 = 0; count2 < 256; count2++) { for(int t = 0; t < 288; ++t) { lk[t] = count2; } for(int t = 1; t < TMAX; ++t) { if(t >= TMIN) { //summe = 1 & (lk[t+243] ^ lk[t+288] ^ lk[t+66] ^ lk[t+93] ^ lk[t+162] ^ lk[t+177]); } //lk[287] = 5;//lk[t+243] ^ lk[t+288] ^ lk[t+69] ^ (lk[t+286] & lk[t+287]); //lk[93] = 5;//lk[t+66] ^ lk[t+93] ^ lk[t+171] ^ (lk[t+91] & lk[t+92]); //lk[177] = 5;//lk[t+162] ^ lk[t+177] ^ lk[t+264] ^ (lk[t+175] & lk[t+176]); } //summe ^= lk[1400]; } // count2*/ membuff[gl_id] = gl_id; } same as above, but lk[287] = 5; lk[93] = 5; lk[177] = 5; are not commented out. CRASHES. __kernel void aida( __global unsigned long* membuff ) { const size_t gl_id = get_global_id(0); // global id = unique id(0 till membuff.count - 1) const int TMAX = 1200; const int TMIN = 1199; unsigned long lk[288+1200]; unsigned long summe = 0; for (int count2 = 0; count2 < 256; count2++) { for(int t = 0; t < 288; ++t) { lk[t] = count2; } for(int t = 1; t < TMAX; ++t) { if(t >= TMIN) { //summe = 1 & (lk[t+243] ^ lk[t+288] ^ lk[t+66] ^ lk[t+93] ^ lk[t+162] ^ lk[t+177]); } lk[287] = 5;//lk[t+243] ^ lk[t+288] ^ lk[t+69] ^ (lk[t+286] & lk[t+287]); lk[93] = 5;//lk[t+66] ^ lk[t+93] ^ lk[t+171] ^ (lk[t+91] & lk[t+92]); lk[177] = 5;//lk[t+162] ^ lk[t+177] ^ lk[t+264] ^ (lk[t+175] & lk[t+176]); } //summe ^= lk[1400]; } // count2*/ membuff[gl_id] = gl_id; } and last, but not least: membuff[gl_id] = gl_id; is commented out, otherwise same as above: CRASHES. __kernel void aida( __global unsigned long* membuff ) { const size_t gl_id = get_global_id(0); // global id = unique id(0 till membuff.count - 1) const int TMAX = 1200; const int TMIN = 1199; unsigned long lk[288+1200]; unsigned long summe = 0; for (int count2 = 0; count2 < 256; count2++) { for(int t = 0; t < 288; ++t) { lk[t] = count2; } for(int t = 1; t < TMAX; ++t) { if(t >= TMIN) { //summe = 1 & (lk[t+243] ^ lk[t+288] ^ lk[t+66] ^ lk[t+93] ^ lk[t+162] ^ lk[t+177]); } lk[287] = 5;//lk[t+243] ^ lk[t+288] ^ lk[t+69] ^ (lk[t+286] & lk[t+287]); lk[93] = 5;//lk[t+66] ^ lk[t+93] ^ lk[t+171] ^ (lk[t+91] & lk[t+92]); lk[177] = 5;//lk[t+162] ^ lk[t+177] ^ lk[t+264] ^ (lk[t+175] & lk[t+176]); } //summe ^= lk[1400]; } // count2*/ //membuff[gl_id] = gl_id; }

Outcomes