| View previous topic :: View next topic |
| Author |
Message |
vivi

Joined: 08 Jul 2009 Posts: 7
|
Posted: Thu Jul 30, 2009 12:01 pm Post subject: Passing variables to SPE |
|
|
Hi, i'm not sure how to pass variables to the SPE's. I want to pass "xd" and "packlist" to the SPE so that start_md5_hash know's what to create a checksum for .
Here is the SPE code.
| Code: |
int main(unsigned long long spe_id, unsigned long long)
{
ioutput(CALLTYPE_NORMAL, OUT_S|OUT_L|OUT_D, COLOR_NO_COLOR, "MD5 pack %d sent to SPE...", packnum);
start_md5_hash(xd, packnum);
return 0;
} |
"The fourth and fifth arguments are argp and envp. These are used at SPE program startup to pass arguments and environment information to the SPE program (this is the same as the same parameters in libspe1's spe_create_thread)."
I found this from http://www.ibm.com/developerworks/library/pa-libspe2/
Unfortunately i'm still having difficulty as the (correct me if i'm wrong) example code doesn't pass anything to the spe:
| Code: | #include <sys/send_to_ppe.h>
/* Type declarations */
typedef unsigned int spe_offset_t;
typedef struct {
spe_offset_t str; /* Input param */
int length; /* Output param */
} my_strlen_param_t;
/* Function declarations */
int my_strlen(char *str);
/* Callback Stub */
int my_strlen(char *str) {
my_strlen_param_t params = { (spe_offset_t)str, 0 };
__send_to_ppe(0x2110, 0, ¶ms);
return params.length;
}
/* Example Usage */
int main(unsigned long long spe_id, unsigned long long argp, unsigned long long envp) {
char *my_str = "Hello there!";
printf("The length of '%s' is %d\n", my_str, my_strlen(my_str));
return 0;
} |
Any help is appreciated. Thanks |
|
| Back to top |
|
 |
ouasse
Joined: 30 Jul 2007 Posts: 91 Location: Paris, France
|
Posted: Thu Jul 30, 2009 11:25 pm Post subject: |
|
|
I strongly recommend to document yourself about the basics of Cell programming. You can start with the following tutorial.
http://www.ibm.com/developerworks/power/library/pa-tacklecell1/
It deals with using the MFC for memory transfers between ram and spe local store, and the following chapter talks about mailboxes for SPE/PPE communication. |
|
| Back to top |
|
 |
vivi

Joined: 08 Jul 2009 Posts: 7
|
Posted: Mon Aug 03, 2009 8:18 am Post subject: |
|
|
| thanks |
|
| Back to top |
|
 |
imhotep
Joined: 13 Dec 2005 Posts: 41
|
|
| Back to top |
|
 |
vivi

Joined: 08 Jul 2009 Posts: 7
|
Posted: Wed Aug 12, 2009 6:32 am Post subject: |
|
|
| Looks, pretty good. But the link for the source doesn't work. Do you know an alternate source? |
|
| Back to top |
|
 |
carlosn
Joined: 10 Mar 2005 Posts: 38 Location: Orlando, Florida, US
|
|
| Back to top |
|
 |
ouasse
Joined: 30 Jul 2007 Posts: 91 Location: Paris, France
|
Posted: Wed Aug 12, 2009 3:48 pm Post subject: |
|
|
very good links, imhotep
Carlos, good effort, I hadn't talked about this tutorial (which I knew about of course, I learned Cell programming by following it) because it was using libspe1. I think a problem is that you cannot only provide libspe2-"translated" code without the proper information about how this works.
The link I provided is some kind of equivalent introduction to Cell programming, which uses libspe2. |
|
| Back to top |
|
 |
|