Docsity

Lecture Notes on Cell/B.E. Programming - DMA | ECE 4893, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download Lecture Notes on Cell/B.E. Programming - DMA | ECE 4893 and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Cell/B.E. Programming: DMA

Kamesh Madduri

2

Lecture Outline

SPE MFC Overview

DMA commands, DMA list transfers

Double buffering and multi-buffering DMAtransfers

Example Cell code

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

4

Cell’s Primary Communication Mechanisms

ƒ

DMA transfers, mailbox messages,and signal-notification ƒ

All three are implemented andcontrolled by the SPE’s MFC

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

5

Element Interconnect Bus - Data Topology

ƒ

Four 16B data rings connecting 12 bus elements –

Two clockwise / Two counter-clockwise

ƒ

Physically overlaps all processor elements ƒ

Central arbiter supports up to three concurrent transfers per data ring –

Two stage, dual round robin arbiter

ƒ

Each element port simultaneously supports 16B in and 16B out data path –

Ring topology is transparent to element data interface

16B

16B

16B

16B

Data Arb

16B

16B

16B

16B

16B

16B

16B

16B

16B

16B

16B

16B

16B16B16B16B

16B16B16B16B

SPE

SPE

SPE

SPE7 SPE

SPE

SPE

SPE

PPE MIC

BIF/IOIF

IOIF

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

Sequences for Issuing MFC Commands^7

9

All operations on a given channel are unidirectional (they can be only read orwrite operations for a given channel,not bidirectional) 9

Accesses to channel-interface resources through MMIO addresses donot stall 9

Channel operations are done in program order 9

Channel read operations to reserved channels return ‘0’s 9

Channel write operations to reserved channels have no effect 9

Reading of channel counts on reserved channels returns ‘0’ 9

Channel instructions use the 32-bit preferred slot in a 128-bit transfer

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

DMA Overview^8

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

10

DMA Get and Put Command (SPU)

DMA get from main memory into local store (void) mfc_get( volatile void *ls, uint64_t ea, uint32_t

size, uint32_t tag, uint32_t tid, uint32_t rid)

DMA put into main memory from local store (void) mfc_put(volatile void *ls, uint64_t ea, uint32_t

size, uint32_t tag, uint32_t tid, uint32_t rid)

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

11

DMA-Command Tag Groups

5-bit DMA Tag for all DMA commands (except getllar, putllc, andputlluc)
Tag can be used to – determine status for entire group or command – check or wait on the completion of all queued commands in one or
more tag groups
Tagging is optional but can be useful when using barriers tocontrol the ordering of MFC commands within a single commandqueue.
Synchronization of DMA commands within a tag group: fence andbarrier – mfc_putf :

fenced

(all commands executed before within the same tag

group must finish first, later ones could be before)

  • mfc_putb :

barrier

(the barrier command and all commands issued

thereafter are not executed until all previously issued commands inthe same tag group have been performed)

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

13

DMA Characteristics

ƒ

DMA transfers – transfer sizes can be 1, 2, 4, 8, and n*16 bytes (n integer) – maximum is 16KB per DMA transfer – 128B alignment is preferable ƒ

DMA command queues per SPU – 16-element queue for SPU-initiated requests – 8-element queue for PPE-initiated requests ¾

SPU-initiated DMA is always preferable

ƒ

DMA tags – each DMA command is tagged with a 5-bit identifier – same identifier can be used for multiple commands – tags used for polling status or waiting on completion of DMA commands ƒ

DMA lists – a single DMA command can cause execution of a list of transfer requests (in LS) – lists implement scatter-gather functions – a list can contain up to 2K transfer requests

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

PPE – SPE DMA Transfer 14

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

16

DMA Command Status (SPE)

ƒ

DMA read and write commands are non-blocking ƒ

Tags, tag groups, and tag masks used for: – checking status of DMA commands – waiting for completion of DMA commands ƒ

Each DMA command has a 5-bit tag – commands with same tag value form a “tag group” ƒ

Tag mask is used to identify tag groups for status checks – tag mask is a 32-bit word – each bit in the tag mask corresponds to a specific tag id:

tag_mask = (1 << tag_id)

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

17

DMA Tag Status (SPE)

ƒ

Set tag mask unsigned int tag_mask; mfc_write_tag_mask(tag_mask); – tag mask remains set until changed ƒ

Fetch tag status unsigned int result; result = mfc_read_tag_status();

/* or mfc_stat_tag_status(); */

  • tag status is logically ANDed with current tag mask – tag status bit of ‘1’ indicates that no DMA requests tagged with the specific

tag id (corresponding to the status bit location) are still either in progress orin the DMA queue

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

19

DMA Example: Read into Local Store

inline

void

dma_mem_to_ls(unsigned

int

mem_addr,

volatile

void

*ls_addr,unsigned

int

size)

{

unsigned

int

tag

=

0;

unsigned

int

mask

=

1;

mfc_get(ls_addr,mem_addr,size,tag,0,0); mfc_write_tag_mask(mask); mfc_read_tag_status_all();

}

Set tag mask^ Wait for all tagDMA completed

Read contentsof mem_addr

into ls_addr

IBM Systems & Technology Group – Cell/Quasar Ecosystem & Solutions Enablement

20

DMA Example: Write to Main Memory

inline

void

dma_ls_to_mem(unsigned

int

mem_addr,volatile

void

*ls_addr,

unsigned

int

size)

{

unsigned

int

tag

=

0;

unsigned

int

mask

=

1;

mfc_put(ls_addr,mem_addr,size,tag,0,0); mfc_write_tag_mask(mask); mfc_read_tag_status_all();

}

Write contents of

mem_addr into

ls_addr

Set tag mask^ Set tag mask