forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing variables to SPE

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS3 Linux Development
View previous topic :: View next topic  
Author Message
vivi



Joined: 08 Jul 2009
Posts: 7

PostPosted: Thu Jul 30, 2009 12:01 pm    Post subject: Passing variables to SPE Reply with quote

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, &params);
   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
View user's profile Send private message Send e-mail
ouasse



Joined: 30 Jul 2007
Posts: 91
Location: Paris, France

PostPosted: Thu Jul 30, 2009 11:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
vivi



Joined: 08 Jul 2009
Posts: 7

PostPosted: Mon Aug 03, 2009 8:18 am    Post subject: Reply with quote

thanks
Back to top
View user's profile Send private message Send e-mail
imhotep



Joined: 13 Dec 2005
Posts: 41

PostPosted: Tue Aug 11, 2009 5:57 am    Post subject: Reply with quote

a good read is also "Programming the Cell processor" by matthew scarpino
(at this site, there's also the source codes for every single example in the book)
http://www.informit.com/store/product.aspx?isbn=9780136008866
http://www.informit.com/content/images/9780136008866/downloads/0136008860_Sample_code.zip


http://www.lemma.ufpr.br/wiki/index.php/Cell_BE_Tutorial
http://cell.grondklont.nl/?p=60
Back to top
View user's profile Send private message
vivi



Joined: 08 Jul 2009
Posts: 7

PostPosted: Wed Aug 12, 2009 6:32 am    Post subject: Reply with quote

Looks, pretty good. But the link for the source doesn't work. Do you know an alternate source?
Back to top
View user's profile Send private message Send e-mail
carlosn



Joined: 10 Mar 2005
Posts: 38
Location: Orlando, Florida, US

PostPosted: Wed Aug 12, 2009 10:35 am    Post subject: Reply with quote

There is a great introductory article about programming the cell at the IBM site. The code at the end for the article answers your question about passing data from PPE to the SPEs. The only drawback is the article uses libspe library.
Few months ago, I ported the code to use libspe2. Here is the link to the updated source code
http://home.earthlink.net/~carlos_neto/distance.tar.gz

Here is the article's link
http://www.ibm.com/developerworks/power/library/pa-linuxps3-1/index.html

Enjoy,
Carlos
Back to top
View user's profile Send private message Visit poster's website
ouasse



Joined: 30 Jul 2007
Posts: 91
Location: Paris, France

PostPosted: Wed Aug 12, 2009 3:48 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS3 Linux Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group