Day1-14_Hands-on_DMA_ControlBlock

Day1-14_Hands-on_DMA_ControlBlock - IBM Systems &...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Cell Programming Workshop 3/2/2008 © 2007 IBM Corporation 1 Hands-on - DMA Transfer Using Control Block Cell Programming Workshop Cell/Quasar Ecosystem & Solutions Enablement
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© 2007 IBM Corporation Cell Programming Workshop 3/2/2008 2 Class Objectives ! At the end of this class you should know how to do a DMA transfer using the control block Trademarks - Cell Broadband Engine and Cell Broadband Engine Architecture are trademarks of Sony Computer Entertainment, Inc.
Background image of page 2
© 2007 IBM Corporation Cell Programming Workshop 3/2/2008 3 Class Agenda ! The simpleDMA program ! The PPE program – simpleDMA.c ! The SPE program – simpleDMA_spu.c /opt/cell_class/Hands-on-30/DMA_getcb_libspe2/
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
© 2007 IBM Corporation Cell Programming Workshop 3/2/2008 4 The simpleDMA Program The actual executable resides in the ppu subdirectory. It's called 'simpleDMA'. It's a full CBE executable, with both PPE and SPE code. The job of this program is to get the SPEs to print out the address of an array which is passed to it by the PPE. Program Details: ! The PPE Program: The PPE uses a malloc() command to allocate a small array in main memory. The PPE then loads the address of the array into a control block. The PPU prints the address of the array. The PPE then creates the SPE thread, passing the address of the control block. ! The SPE Program: The SPE performs a simple DMA to load the contents of the control block into its local store. Then the SPE prints the array address contained within the contents of the control block, and exits.
Background image of page 4
© 2007 IBM Corporation Cell Programming Workshop 3/2/2008 5 The PPE program – simpleDMA.c #include ". ./simpleDMA.h" #include <sched.h> //#include <libspe.h> #include <stdio.h> #include <errno.h> #include <libspe2.h> /* we allocate one control block, to correspond to one SPE */ control_block cb __attribute__ ((aligned (128))); /* this is the pointer to the SPE code, to be used at thread creation time */ extern spe_program_handle_t simpleDMA_spu; spe_context_ptr_t speid; unsigned int flags = 0; unsigned int entry = SPE_DEFAULT_ENTRY; spe_stop_info_t stop_info; int rc; /* here is the variable to hold the address returned by the malloc() call. */ int *data; int main() { /* here is the malloc call */ data = (int *) malloc(128); printf("address being sent in control block: %x\n", (unsigned int) data); /* load the address into the control block */ cb.addr = (unsigned int) data; /* allocate the SPE task */ speid = spe_context_create(flags, NULL); spe_program_load(speid, &simpleDMA_spu); rc = spe_context_run(speid, &entry, 0, (unsigned long long *) &cb, NULL, &stop_info); spe_context_destroy(speid); return 0;
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/03/2011 for the course CDA 6938 taught by Professor Zou,c during the Spring '08 term at University of Central Florida.

Page1 / 9

Day1-14_Hands-on_DMA_ControlBlock - IBM Systems &...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online