Cell processor lab
-
Upload
coolmirza143 -
Category
Technology
-
view
739 -
download
1
description
Transcript of Cell processor lab
![Page 1: Cell processor lab](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/1.jpg)
Cell Processor Lab
![Page 2: Cell processor lab](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/2.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/3.jpg)
Cell Processor Lab
Cross Compilers spu-gcc ppu-gcc ppu-embedspu
Simulator IBM Full System Simulator
3
![Page 4: Cell processor lab](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/4.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/5.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/6.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/7.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/8.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/9.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/10.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/11.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/12.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/13.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/14.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/15.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/16.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/17.jpg)
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](https://reader036.fdocuments.in/reader036/viewer/2022081821/547937d2b379597b2b8b46d0/html5/thumbnails/18.jpg)
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