Hi everyone,
I'm trying to run a code using cilkplus. The idea is to initiallize an array in parallel, using cilk_for, and then read it, in parallel again, to compute some results. However, I have race conditions between instruction on the two consecutive cilk_for. Above you can find an example code that reproduces that error:
#include <stdlib.h> #include <stdio.h> #include <cilk/cilk.h> #include <cilk/cilk_api.h> #include <cilk/common.h> int main(int argc, char** argv) { struct sublist_node { int head; int next; }; uint i = 0; uint s = 100; struct sublist_node* sublist = malloc(s*sizeof(struct sublist_node)); cilk_for(i = 0; i < s; i++) { sublist[i].head = i; sublist[i].next = -1; } cilk_for(i = 0; i < s; i++) { int curr = sublist[i].next; } return EXIT_SUCCESS; }
When I run cilk screen I obtain this output
Cilkscreen Race Detector V2.0.0, Build 4421
Race condition on location 0xf0f014
write access at 0x4007fd: (/home/jose/Dropbox/Doctorado/Succinct Graph/bitbucket/code/race.c:21, __cilk_for_001.2888+0x41)
read access at 0x40083c: (/home/jose/Dropbox/Doctorado/Succinct Graph/bitbucket/code/race.c:25, __cilk_for_002.2912+0x2b)
called by 0x4007b0: (/home/jose/Dropbox/Doctorado/Succinct Graph/bitbucket/code/race.c:26, main+0xe3)
1 error found by Cilkscreen
Cilkscreen suppressed 62 duplicate error messages
I'm using gcc version 4.9.0 20130520 (experimental) (GCC).
It would be nice if anyone can give me any hint.
Thanks,
José Fuentes.