Editing SPE to SPE DMA transfer

From Cellbe

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Current revision Your text
Line 4: Line 4:
#PGET communicates to the PPE the target address via mailbox, then synchronizes with the PPE with a mailbox read
#PGET communicates to the PPE the target address via mailbox, then synchronizes with the PPE with a mailbox read
#The PPE calculates the effective address of the target, and sends it to PPUT via mailbox, and synchronizes with PPUT with a mailbox read
#The PPE calculates the effective address of the target, and sends it to PPUT via mailbox, and synchronizes with PPUT with a mailbox read
-
#PPUT reads the target's effective address from mailbox, starts the dma transfer, waits for it to finish and wakes up the PPE with a mailbox write
+
#PPUT reads the target's effective address from mailbox, starts the dma trasfer, waits for it to finish and wakes up the PPE with a mailbox write
#The PPE wakes up, and writes a mailbox to PGET to wake it up.
#The PPE wakes up, and writes a mailbox to PGET to wake it up.
#PGET wakes up, and  prints the content of the target memory area.
#PGET wakes up, and  prints the content of the target memory area.
===Considerations===
===Considerations===
-
Please note that this kind of synchronization is not recommended, because it involves the PPE. Signals would be surely better. Also the PPE waits actively for the mailbox messages. while it should do some kind of passive wait. Synchronization through mailbox has been chosen just because of simplicity.
+
Please note that this kind of synchronization is not recommended, because it involves the PPE. Signals would be surely better. Also the PPE waits actively for the mailbox messages. while it should do some kind of passive wait. Synchronization through mailbox has ben chosen just because of simplicity.
-
 
+
-
==Code snippet: Pointer passing structure==
+
-
This structure is used to ensure compatibility when compiling with 32 or 64 bits word size.
+
-
 
+
-
[http://www.professays.com/research-papers/ professional custom essays, buy essays]
+
-
<pre>
+
-
/* =============================================================================
+
-
*      Filename:  common.h
+
-
*    Description:  common data structure used to pass pointers
+
-
*        Author:  Alessandro Piras
+
-
* =============================================================================
+
-
*/
+
-
#pragma once
+
-
union eat{
+
-
    struct{
+
-
        unsigned h;
+
-
        unsigned l;
+
-
    }; 
+
-
    unsigned long long e;
+
-
    struct{
+
-
#ifndef __powerpc64__
+
-
        unsigned int reserved;
+
-
#endif 
+
-
        volatile void *p;
+
-
    }; 
+
-
}; 
+
-
</pre>
+
-
 
+
==Code snippet: PPE side==
==Code snippet: PPE side==
<pre>
<pre>
Line 81: Line 53:
{
{
spe_context_ptr_t ctx1, ctx2;
spe_context_ptr_t ctx1, ctx2;
-
union eat shared_lsaddr;
+
unsigned int shared_lsaddr;
pthread_t pth1, pth2;
pthread_t pth1, pth2;
union eat ls_base_addr;
union eat ls_base_addr;
Line 98: Line 70:
/* 1. Getting the ls address of the memory area where the put will be */
/* 1. Getting the ls address of the memory area where the put will be */
/*    executed (via mailboxes)                                        */
/*    executed (via mailboxes)                                        */
-
while(!spe_out_mbox_status(ctx1));
+
-
spe_out_mbox_read(ctx1, &shared_lsaddr.h, 1);
+
-
while(!spe_out_mbox_status(ctx1));
+
-
spe_out_mbox_read(ctx1, &shared_lsaddr.l, 1);
+
 +
while(!spe_out_mbox_status(ctx1));
 +
spe_out_mbox_read(ctx1, &shared_lsaddr, 1);
/* 2. constructing the effective address adding the base address of  */
/* 2. constructing the effective address adding the base address of  */
/*    LS area of the "get" process to the LS address just received    */
/*    LS area of the "get" process to the LS address just received    */
-
ls_base_addr.e = 0;   /* assigning 0 to make sure garbage is removed */
+
ls_base_addr.e = 0;
-
ls_base_addr.p = spe_ls_area_get(ctx1);
+
ls_base_addr.e =(unsigned long long) spe_ls_area_get(ctx1);
-
shared_ea.e = shared_lsaddr.e + ls_base_addr.e;
+
shared_ea.e = shared_lsaddr + ls_base_addr.e;
/* 3. Sending the calculated address to the "put" process.            */
/* 3. Sending the calculated address to the "put" process.            */
Line 129: Line 100:
}
}
-
 
-
 
</pre>
</pre>
-
 
==Code snippet: process ''PGET'', SPE side==
==Code snippet: process ''PGET'', SPE side==
<pre>
<pre>
Line 150: Line 118:
#include <spu_intrinsics.h>
#include <spu_intrinsics.h>
#include <spu_mfcio.h>
#include <spu_mfcio.h>
-
#include "../common.h"
+
#include <commonlib.h>
#define MYALIGN(vardecl, n) vardecl\\
#define MYALIGN(vardecl, n) vardecl\\
Line 160: Line 128:
int main(unsigned long long spe_id, unsigned long long argp, unsigned long long envp)
int main(unsigned long long spe_id, unsigned long long argp, unsigned long long envp)
{
{
-
union eat cane_addr;
+
unsigned int cane_addr;
cane = 200;
cane = 200;
/* spu_dsync();                                                  */
/* spu_dsync();                                                  */
/* I'm not sure if it's indeed useful/required, it worked without */
/* I'm not sure if it's indeed useful/required, it worked without */
-
 
+
cane_addr = &cane;
-
cane_addr.e=0;    /* assigning 0 to make sure garbage is removed */
+
-
 
+
-
cane_addr.p = &cane;
+
/* Sending the address of the memory area where the other spe    */
/* Sending the address of the memory area where the other spe    */
/* process will transfer its data                                */
/* process will transfer its data                                */
-
spu_write_out_mbox(cane_addr.h);
+
spu_write_out_mbox((unsigned int)cane_addr);
-
spu_write_out_mbox(cane_addr.l);
+
/* Synchronizing with the ppe                                    */
/* Synchronizing with the ppe                                    */
spu_read_in_mbox();
spu_read_in_mbox();
Line 220: Line 184:
return 0;
return 0;
}
}
-
 
</pre>
</pre>
-
[[Category:Tutorial]]
 

Please note that all contributions to Cellbe may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Project:Copyrights for details). DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION!


Cancel | Editing help (opens in new window)
Personal tools