Topic
No replies
soultrav
soultrav
1 Post
ACCEPTED ANSWER

Pinned topic Problem synchronizing transfers

‏2010-05-24T05:09:59Z |
Hello! I want the PPU to transfer his command line arguments to each of the SPU's...but the messages the PPU puts in the mailbox overwrites the previous ones...what can I do?

PPU code:
uint32_t v128 __attribute__ ((aligned(128)));
int j;
/* send 5 arguments */
for(j=1;j<=5;j++) {
memset(v,0,sizeof(v));
strcpy(v,argv[j]);
int a = v;
for(i=0;i<SPU_THREADS;i++) {
while(spe_in_mbox_status(ctxs[i]) == 0);
if(spe_in_mbox_write(ctxs[i], (void*)&a, 1, SPE_MBOX_ANY_BLOCKING) == 0)
printf("Message could not be written\n");
}
}

SPU code:
uint32_t mbox_data;
uint32_t v128 __attribute__ ((aligned(128)));
for(i=0;i<5;i++) {
while(spu_stat_in_mbox() <= 0);
mbox_data = spu_read_in_mbox();
memset(v,0,128);
mfc_get((void*)v, mbox_data, 128*sizeof(uint32_t), tag_id, 0, 0);
waitag(tag_id);
printf("%s\n", v);
}