Cell processor lab

626 views

Published on

by Mansoor Mirza
Tools Required
Cross compilers
Simulator
Cell SDK
Introduced by IBM
Contains
Cross compilers
Debuggers
Assemblers
Profilers

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
626
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cell processor lab

  1. 1. Cell Processor Lab
  2. 2. Cell Processor Lab <ul><li>Tools Required </li></ul><ul><ul><li>Cross compilers </li></ul></ul><ul><ul><li>Simulator </li></ul></ul><ul><li>Cell SDK </li></ul><ul><ul><li>Introduced by IBM </li></ul></ul><ul><ul><li>Contains </li></ul></ul><ul><ul><ul><li>Cross compilers </li></ul></ul></ul><ul><ul><ul><li>Debuggers </li></ul></ul></ul><ul><ul><ul><li>Assemblers </li></ul></ul></ul><ul><ul><ul><li>Profilers </li></ul></ul></ul>
  3. 3. Cell Processor Lab <ul><li>Cross Compilers </li></ul><ul><ul><li>spu-gcc </li></ul></ul><ul><ul><li>ppu-gcc </li></ul></ul><ul><ul><li>ppu-embedspu </li></ul></ul><ul><li>Simulator </li></ul><ul><ul><li>IBM Full System Simulator </li></ul></ul>
  4. 4. Cell Processor Lab <ul><li>Code requirement </li></ul><ul><ul><li>SPU code </li></ul></ul><ul><ul><li>PPU code </li></ul></ul><ul><li>SPU code </li></ul><ul><ul><li>Performs basic work </li></ul></ul><ul><ul><li>Data required by code has to be transferred to SPU using DMA or mailboxes </li></ul></ul><ul><ul><li>One SPU can only access LS directly </li></ul></ul>
  5. 5. Cell Processor Lab <ul><li>PPU code </li></ul><ul><ul><li>Any code that runs on Linux can run on PPU </li></ul></ul><ul><ul><li>PPU distributes the work to SPUs </li></ul></ul><ul><ul><li>PPU should contain SPU handler </li></ul></ul><ul><ul><li>PPU should contain context of each SPU </li></ul></ul>
  6. 6. Cell Processor Lab <ul><li>PPU program flow </li></ul><ul><ul><li>Declare SPU program handler </li></ul></ul><ul><ul><li>Declare SPU context for each SPU used </li></ul></ul><ul><ul><li>Create SPU context </li></ul></ul><ul><ul><li>Load SPU context </li></ul></ul><ul><ul><ul><li>Loads SPU context to handler </li></ul></ul></ul><ul><ul><li>Run SPU context </li></ul></ul><ul><ul><ul><li>Runs the SPU code on SPU </li></ul></ul></ul>
  7. 7. Cell Processor Lab <ul><li>SPU code </li></ul><ul><li>#include <stdio.h> </li></ul><ul><li>int main (unsigned long long spe_id, </li></ul><ul><li>unsigned long long argp, </li></ul><ul><li>unsigned long long envp) { </li></ul><ul><li>printf(&quot;Hello World! My thread id is %lldn&quot;, </li></ul><ul><li>spe_id); </li></ul><ul><li>return 0; </li></ul><ul><li>} </li></ul><ul><li>PPU Code </li></ul>Design and Animation Game Programming Graphics Programming Matthew Scarpino
  8. 8. Cell Processor Lab #include <stdio.h> #include <stdlib.h> #include <libspe2.h> extern spe_program_handle_t spu_basic; /* SPE program handle */ int main(int argc, char **argv) { spe_context_ptr_t spe; /* SPE context */ unsigned int entry_point; /* SPE start address */ int retval; /* Return value */ Design and Animation Game Programming Graphics Programming Matthew Scarpino
  9. 9. Cell Processor Lab /* Create the SPE Context */ spe = spe_context_create(0, NULL); if (!spe) { perror(&quot;spe_context_create&quot;); exit(1); } /* Load the program handle into the context */ retval = spe_program_load(spe, &spu_basic); if (retval) { perror(&quot;spe_program_load&quot;); exit(1); } Design and Animation Game Programming Graphics Programming Matthew Scarpino
  10. 10. Cell Processor Lab /* Run the program inside the context */ entry_point = SPE_DEFAULT_ENTRY; retval = spe_context_run(spe, &entry_point, 0, NULL, NULL, &stop_info); if (retval < 0) { perror(&quot;spe_context_run&quot;); exit(1); } /* Deallocate the context */ retval = spe_context_destroy(spe); if (retval) { perror(&quot;spe_context_destroy&quot;); exit(1); } return 0; } Design and Animation Game Programming Graphics Programming Matthew Scarpino
  11. 11. Cell Processor Lab <ul><li>Setting the environment variable </li></ul><ul><ul><li>Make sure that CellSDK and Full System Simulator is installed on you machine </li></ul></ul><ul><ul><ul><li>Check whether /opt/cell/ is available </li></ul></ul></ul><ul><ul><ul><li>Check that /opt/cell/ibm is avaiable </li></ul></ul></ul><ul><ul><li>Export path to SDK and simulator </li></ul></ul><ul><ul><ul><li>export PATH=$PATH:/opt/cell/toolchain/bin </li></ul></ul></ul><ul><ul><ul><li>export PATH=$PATH:/opt/ibm/system-cell/bin </li></ul></ul></ul>
  12. 12. Cell Processor Lab <ul><li>Building an application </li></ul><ul><ul><li>Build SPU code </li></ul></ul><ul><ul><ul><li>spu-gcc <spu_source_file.c> -o <outfile> </li></ul></ul></ul><ul><ul><li>Embed SPU code to PPU </li></ul></ul><ul><ul><ul><li>ppu-embedspu <spu handler> <outfile> <embedfile> </li></ul></ul></ul><ul><ul><li>Build PPU code </li></ul></ul><ul><ul><ul><li>ppu-gcc <ppu_source_file.c> <embedfile> -lspe2 -o <cell_executable_file> </li></ul></ul></ul><ul><ul><li>Copy the executable at appropriate location </li></ul></ul><ul><ul><ul><li>cp <cell_executable_file> /tmp </li></ul></ul></ul>
  13. 13. Cell Processor Lab <ul><li>Starting the simulator </li></ul><ul><ul><li>Conform that the PATH variable is updated as described earlier </li></ul></ul><ul><ul><li>Initialize the simulator </li></ul></ul><ul><ul><ul><li>systemsim –g </li></ul></ul></ul><ul><ul><li>Run the simulator as “systemsim%” interface appears </li></ul></ul>
  14. 14. Cell Processor Lab <ul><li>Starting the simulator </li></ul><ul><ul><li>It will show two windows </li></ul></ul><ul><ul><ul><li>Processor GUI dialog </li></ul></ul></ul><ul><ul><ul><li>Simulated terminal </li></ul></ul></ul><ul><li>Import the Cell executable to simulated environment </li></ul><ul><ul><li>Issue following command in simulated terminal </li></ul></ul><ul><ul><ul><li>callthru source /tmp/<cell_executable_file> > <file_name> </li></ul></ul></ul>
  15. 15. Cell Processor Lab <ul><li>Import the Cell executable to simulated environment </li></ul><ul><ul><li>Make file executable </li></ul></ul><ul><ul><ul><li>chmod +x <file_name> </li></ul></ul></ul><ul><ul><li>Run the file </li></ul></ul><ul><ul><ul><li>./<file_name> [options] </li></ul></ul></ul>
  16. 16. Cell Processor Lab <ul><li>Running MPAC Cell benchmarks </li></ul><ul><ul><li>Go to MPAC parent directory </li></ul></ul><ul><ul><ul><li>cd /path/to/mpac/parent/directory </li></ul></ul></ul><ul><ul><li>Make MPAC for Cell </li></ul></ul><ul><ul><ul><li>make cell </li></ul></ul></ul><ul><ul><li>Go to CPU benchmark directory </li></ul></ul><ul><ul><ul><li>cd cbe/cpu_bench </li></ul></ul></ul><ul><ul><li>Move the executable to appropriate location </li></ul></ul><ul><ul><ul><li>cp mpac_cell_cpu /tmp </li></ul></ul></ul>
  17. 17. Cell Processor Lab <ul><li>Running MPAC Cell benchmarks </li></ul><ul><ul><li>Import the CPU benchmark executable to simulator </li></ul></ul><ul><ul><ul><li>callthru source /tmp/mpac_cell_cpu > mpac_cell_cpu </li></ul></ul></ul><ul><ul><li>Make the file executable </li></ul></ul><ul><ul><ul><li>chmod +x mpac_cell_cpu </li></ul></ul></ul><ul><ul><li>Execute the benchmark with appropriate options </li></ul></ul><ul><ul><ul><li>./mpac_cell_bm [options] </li></ul></ul></ul>
  18. 18. Cell Processor Lab <ul><li>Running MPAC Cell benchmarks </li></ul><ul><ul><li>Repeat the procedure for memory benchmarks </li></ul></ul><ul><li>Why network benchmark is not ported for Cell processor? </li></ul><ul><li>MPAC benchmark architecture for Cell processor </li></ul>

×