






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!























Dr. Rodric Rabbah, IBM.^
2 6.189 IAP 2007 MIT
4 6.189 IAP 2007 MIT
5 6.189 IAP 2007 MIT
7 6.189 IAP 2007 MIT
8 6.189 IAP 2007 MIT
10 6.189 IAP 2007 MIT
spu_write_out_intr_mboxspu_stat_out_mbox, spu_stat_out_intr_mboxspu_read_signal1/2spu_stat_signal1/2spu_write_event_maskspu_read_event_statusspu_stat_event_statusspu_write_event_ackspu_read_decrementerspu_write_decrementer
11 6.189 IAP 2007 MIT
13 6.189 IAP 2007 MIT
for current cell values ^ Use a second array^ nextbuffer[]
to store the values for next step Swap the buffers
14 6.189 IAP 2007 MIT /*^ Initialize^ cells^ */int^ x,^ n,^ *tmp;int^ buffer^ =^ (int)malloc(N Dr. Rodric Rabbah, IBM.
*^ sizeof(int)); int^ nextbuffer^ =^ (int)malloc(N
*^ sizeof(int)); FILE^ *fp^ =^ fopen("input.dat",
"r"); if^ (fp^ ==^ NULL)^ {^ exit(-1);^
for^ (x^ =^ 0;^ x^ <^ N;^ x++)^ {^ fscanf(fp,
"%d",^ &buffer[x]);^ } fclose(fp);/*^ Main^ loop^ */for^ (n^ =^ 0;^ n^ <^ steps;^ n++)^
{ for (x = 0; x < N; x++) { nextbuffer[x] = (buffer[(x-1+N)%N]+buffer[(x+1)%N])^ %
} tmp^ =^ buffer;^ buffer^ =^ nextbuffer;
nextbuffer^ =^ tmp;
Example adapted fromTaiga Nakamura
16 6.189 IAP 2007 MIT nlocal^ =^ N^ /^ size;buffer^ =^ (int*)malloc((nlocal+2) Dr. Rodric Rabbah, IBM.
^ sizeof(int)); nextbuffer^ =^ (int)malloc((nlocal+2)
^ sizeof(int)); /^ Main^ loop^ */for^ (n^ =^ 0;^ n^ <^ steps;^ n++)^ { for^ (x^ =^ 0;^ x^ <^ nlocal;^ x++)
{ nextbuffer[x] = (buffer[(x-1+N)%N]+buffer[(x+1)%N])^ %^
} /*^ Exchange^ boundary^ cells^ with
neighbors^ */ ... tmp^ =^ buffer;^ buffer^ =^ nextbuffer;
nextbuffer^ =^ tmp;
Where are the bugs? (nlocal+1)^ Example adapted fromTaiga Nakamura
17 6.189 IAP 2007 MIT nlocal^ =^ N^ /^ size;buffer^ =^ (int*)malloc((nlocal+2) Dr. Rodric Rabbah, IBM.
^ sizeof(int)); nextbuffer^ =^ (int)malloc((nlocal+2)
^ sizeof(int)); /^ Main^ loop^ */for^ (n^ =^ 0;^ n^ <^ steps;^ n++)^ { for^ (x^ =^ 0;^ x^ <^ nlocal;^ x++)
{ nextbuffer[x] = (buffer[(x-1+N)%N]+buffer[(x+1)%N])^ %^
} /*^ Exchange^ boundary^ cells^ with
neighbors^ */ ... tmp^ =^ buffer;^ buffer^ =^ nextbuffer;
nextbuffer^ =^ tmp;
Where are the bugs? N may not be divisible by^ size (x = 1; x < nlocal+1;^ x++) (nlocal+1)^ Example adapted fromTaiga Nakamura
19 6.189 IAP 2007 MIT /*^ Main^ loop^ */for^ (n^ =^ 0;^ n^ <^ steps;^ n++)^ { for^ (x^ =^ 1;^ x^ <^ nlocal+1;^ x++) Dr. Rodric Rabbah, IBM.
nextbuffer[x]^ =^ (buffer[(x-1+N)%N]+buffer[(x+1)%N])
} /*^ Exchange^ boundary^ cells^ with
neighbors^ */ receive (&nextbuffer[0],^
(rank+size-1)%size); send^ (&nextbuffer[nlocal],
(rank+1)%size); receive (&nextbuffer[nlocal+1], (rank+1)%size);send^ (&nextbuffer[1],^
(rank+size-1)%size); tmp^ =^ buffer;^ buffer^ =^ nextbuffer;
nextbuffer^ =^ tmp;
Where are the bugs? … ● Deadlock
20 6.189 IAP 2007 MIT