Cell processor lab

18
Cell Processor Lab

description

by Mansoor MirzaTools RequiredCross compilersSimulatorCell SDKIntroduced by IBMContains Cross compilersDebuggersAssemblersProfilers

Transcript of Cell processor lab

Page 1: Cell processor lab

Cell Processor Lab

Page 2: Cell processor lab

Cell Processor Lab

Tools Required Cross compilers Simulator

Cell SDK Introduced by IBM Contains

Cross compilers Debuggers Assemblers Profilers

2

Page 3: Cell processor lab

Cell Processor Lab

Cross Compilers spu-gcc ppu-gcc ppu-embedspu

Simulator IBM Full System Simulator

3

Page 4: Cell processor lab

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

4

Page 5: Cell processor lab

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

5

Page 6: Cell processor lab

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

6

Page 7: Cell processor lab

Cell Processor Lab

SPU code#include <stdio.h>int main (unsigned long long spe_id, unsigned long long argp, unsigned long long envp) { printf("Hello World! My thread id is %lld\n", spe_id); return 0;}

PPU Code

7Design and Animation Game Programming Graphics Programming Matthew Scarpino

Page 8: Cell processor lab

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 */

8Design and Animation Game Programming Graphics Programming Matthew Scarpino

Page 9: Cell processor lab

Cell Processor Lab

/* Create the SPE Context */ spe = spe_context_create(0, NULL); if (!spe) { perror("spe_context_create"); exit(1); } /* Load the program handle into the context */ retval = spe_program_load(spe, &spu_basic); if (retval) { perror("spe_program_load"); exit(1); }

9Design and Animation Game Programming Graphics Programming Matthew Scarpino

Page 10: Cell processor lab

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("spe_context_run"); exit(1); } /* Deallocate the context */ retval = spe_context_destroy(spe); if (retval) { perror("spe_context_destroy"); exit(1); } return 0;}

10Design and Animation Game Programming Graphics Programming Matthew Scarpino

Page 11: Cell processor lab

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

11

Page 12: Cell processor lab

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

12

Page 13: Cell processor lab

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

13

Page 14: Cell processor lab

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>

14

Page 15: Cell processor lab

Cell Processor Lab

Import the Cell executable to simulated environment Make file executable

chmod +x <file_name> Run the file

./<file_name> [options]

15

Page 16: Cell processor lab

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

16

Page 17: Cell processor lab

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]

17

Page 18: Cell processor lab

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

18