Cell Processor Lab
Cell Processor Lab Tools Required Cross compilers Simulator Cell SDK Introduced by IBM Contains  Cross compilers Debuggers Assemblers Profilers
Cell Processor Lab Cross Compilers spu-gcc ppu-gcc ppu-embedspu Simulator IBM Full System Simulator
Cell Processor Lab Code requirement SPU code PPU code SPU code Performs basic work Data required by code has to be transferred to SPU using DMA or mailboxes One SPU can only access LS directly
Cell Processor Lab PPU code Any code that runs on Linux can run on PPU PPU distributes the work to SPUs PPU should contain SPU handler PPU should contain context of each SPU
Cell Processor Lab PPU program flow Declare SPU program handler Declare SPU context for each SPU used Create SPU context Load SPU context  Loads SPU context to handler Run SPU context Runs the SPU code on SPU
Cell Processor Lab SPU code #include <stdio.h> int main (unsigned long long spe_id,  unsigned long long argp,  unsigned long long envp) { printf(&quot;Hello World! My thread id is %lld\n&quot;,  spe_id); return 0; } PPU Code Design and Animation Game Programming Graphics Programming Matthew Scarpino
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
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
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
Cell Processor Lab Setting the environment variable Make sure that CellSDK and Full System Simulator is installed on you machine Check whether /opt/cell/ is available Check that /opt/cell/ibm is avaiable Export path to SDK and simulator export PATH=$PATH:/opt/cell/toolchain/bin export PATH=$PATH:/opt/ibm/system-cell/bin
Cell Processor Lab Building an application Build SPU code spu-gcc <spu_source_file.c> -o <outfile> Embed SPU code to PPU ppu-embedspu <spu handler> <outfile> <embedfile> Build PPU code ppu-gcc <ppu_source_file.c> <embedfile> -lspe2 -o <cell_executable_file> Copy the executable at appropriate location cp <cell_executable_file> /tmp
Cell Processor Lab Starting the simulator Conform that the PATH variable is updated as described earlier Initialize the simulator systemsim –g Run the simulator as “systemsim%” interface appears
Cell Processor Lab Starting the simulator It will show two windows  Processor GUI dialog Simulated terminal Import the Cell executable to simulated environment Issue following command in simulated terminal callthru source /tmp/<cell_executable_file> > <file_name>
Cell Processor Lab Import the Cell executable to simulated environment Make file executable chmod +x <file_name>  Run the file  ./<file_name> [options]
Cell Processor Lab Running MPAC Cell benchmarks Go to MPAC parent directory cd /path/to/mpac/parent/directory Make MPAC for Cell make cell Go to CPU benchmark directory cd cbe/cpu_bench Move the executable to appropriate location cp mpac_cell_cpu /tmp
Cell Processor Lab Running MPAC Cell benchmarks Import the CPU benchmark executable to simulator callthru source /tmp/mpac_cell_cpu > mpac_cell_cpu Make the file executable chmod +x mpac_cell_cpu Execute the benchmark with appropriate options ./mpac_cell_bm [options]
Cell Processor Lab Running MPAC Cell benchmarks Repeat the procedure for memory benchmarks Why network benchmark is not ported for Cell processor? MPAC benchmark architecture for Cell processor

Cell processor lab

  • 1.
  • 2.
    Cell Processor LabTools Required Cross compilers Simulator Cell SDK Introduced by IBM Contains Cross compilers Debuggers Assemblers Profilers
  • 3.
    Cell Processor LabCross Compilers spu-gcc ppu-gcc ppu-embedspu Simulator IBM Full System Simulator
  • 4.
    Cell Processor LabCode requirement SPU code PPU code SPU code Performs basic work Data required by code has to be transferred to SPU using DMA or mailboxes One SPU can only access LS directly
  • 5.
    Cell Processor LabPPU code Any code that runs on Linux can run on PPU PPU distributes the work to SPUs PPU should contain SPU handler PPU should contain context of each SPU
  • 6.
    Cell Processor LabPPU program flow Declare SPU program handler Declare SPU context for each SPU used Create SPU context Load SPU context Loads SPU context to handler Run SPU context Runs the SPU code on SPU
  • 7.
    Cell Processor LabSPU code #include <stdio.h> int main (unsigned long long spe_id, unsigned long long argp, unsigned long long envp) { printf(&quot;Hello World! My thread id is %lld\n&quot;, spe_id); return 0; } PPU Code Design and Animation Game Programming Graphics Programming Matthew Scarpino
  • 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.
    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.
    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.
    Cell Processor LabSetting the environment variable Make sure that CellSDK and Full System Simulator is installed on you machine Check whether /opt/cell/ is available Check that /opt/cell/ibm is avaiable Export path to SDK and simulator export PATH=$PATH:/opt/cell/toolchain/bin export PATH=$PATH:/opt/ibm/system-cell/bin
  • 12.
    Cell Processor LabBuilding an application Build SPU code spu-gcc <spu_source_file.c> -o <outfile> Embed SPU code to PPU ppu-embedspu <spu handler> <outfile> <embedfile> Build PPU code ppu-gcc <ppu_source_file.c> <embedfile> -lspe2 -o <cell_executable_file> Copy the executable at appropriate location cp <cell_executable_file> /tmp
  • 13.
    Cell Processor LabStarting the simulator Conform that the PATH variable is updated as described earlier Initialize the simulator systemsim –g Run the simulator as “systemsim%” interface appears
  • 14.
    Cell Processor LabStarting the simulator It will show two windows Processor GUI dialog Simulated terminal Import the Cell executable to simulated environment Issue following command in simulated terminal callthru source /tmp/<cell_executable_file> > <file_name>
  • 15.
    Cell Processor LabImport the Cell executable to simulated environment Make file executable chmod +x <file_name> Run the file ./<file_name> [options]
  • 16.
    Cell Processor LabRunning MPAC Cell benchmarks Go to MPAC parent directory cd /path/to/mpac/parent/directory Make MPAC for Cell make cell Go to CPU benchmark directory cd cbe/cpu_bench Move the executable to appropriate location cp mpac_cell_cpu /tmp
  • 17.
    Cell Processor LabRunning MPAC Cell benchmarks Import the CPU benchmark executable to simulator callthru source /tmp/mpac_cell_cpu > mpac_cell_cpu Make the file executable chmod +x mpac_cell_cpu Execute the benchmark with appropriate options ./mpac_cell_bm [options]
  • 18.
    Cell Processor LabRunning MPAC Cell benchmarks Repeat the procedure for memory benchmarks Why network benchmark is not ported for Cell processor? MPAC benchmark architecture for Cell processor