preesm tutorial€¦ · cps summer school, september 25-29, 2017, porto conte ricerche, alghero...

68
CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) PREESM Tutorial Antoine MORVAN, Karol DESNOS Open source tool : https://github.com/preesm/preesm Web page: http://preesm.sourceforge.net/website/ 1

Upload: others

Post on 16-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

PREESM Tutorial

Antoine MORVAN, Karol DESNOS

Open source tool : https://github.com/preesm/preesm

Web page: http://preesm.sourceforge.net/website/

1

Page 2: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Get familiar with PREESM– Play with SDF MoC/SLAM MoA/Y-codesign

– Go from imperative to PREESM implementation

• Observe Results

• For Cerbero Partners: – grasp hints about how to integrate the tool in the

global toolchain and apply the MoC/MoA approach

on the use cases

Objectives

2

Page 3: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Play with embedded systems/dev boards

• Play with stereo vision or stabilization

• See how to extend PREESM– especially how to target a new processor

• See communication implementation*

• Go to production

Tutos available online

! Objectives

3

Page 4: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• (Quick) Recall

• What we will do in this “hands on” session

• Sobel Filter

• Actor Decomposition

• Single Core

• Multi Core

Outline (hidden slide)

4

Page 5: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Y- co design approach: keep archi and appli

separate

• SDF: actors, fifo, hierarchy, delays, parameters

• SLAM: PE (processors), memories, links

• Scenario: “joint point”:

mapping/scheduling/allocation directives

(Quick) Recall on Concepts

5

Page 6: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Y- co design approach: keep archi and appli

separate

• SDF: actors, fifo, hierarchy, delays, parameters

• SLAM: PE (processors), memories, links

• Scenario: “joint point”:

mapping/scheduling/allocation directives

(Quick) Recall on Concepts

6

PiSDF (Parametrized Interfaced SDF)

Page 7: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Y- co design approach: keep archi and appli

separate

• SDF: actors, fifo, hierarchy, delays, parameters

• SLAM: PE (processors), memories, links

• Scenario: “joint point”:

mapping/scheduling/allocation directives

(Quick) Recall on Concepts

7

S-LAM Single Corewith shared memory

(simple Von Neuman)

Page 8: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Setup a simple example (Sobel filter), imperative

+ procedural MoC

• Design the same filter with actors in PREESM

• Generate code for 1 core archi, observe results

• Generate code for N cores archi, observe results

Materials @ http://preesm.sourceforge.net/website/data/uploads/tutorial_zips/preesm-tuto.zip

SourceForge is kinda down at the time of writing :-(

Practice Overview

8

Page 9: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Sobel Edge Detection

9

Page 10: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

/org.ietr.preesm.sobel/Code/imperative-implem/sample_main.c

#define width 352#define height 288

uchar y[101376];uchar u[25344];uchar v[25344];

void simple_display() { initReadYUV(width,height); yuvDisplayInit(0,width,height); while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV yuvDisplay(0,y,u,v); // display }}

Display Init & Test

10

Page 11: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

/org.ietr.preesm.sobel/Code/imperative-implem/sample_main.c

#define width 352#define height 288

uchar y[101376];uchar u[25344];uchar v[25344];

void simple_display() { initReadYUV(width,height); yuvDisplayInit(0,width,height); while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV yuvDisplay(0,y,u,v); // display }}

Display Init & Test

11

Page 12: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

/org.ietr.preesm.sobel/Code/imperative-implem/sample_main.c

#define width 352#define height 288

uchar y[101376];uchar u[25344];uchar v[25344];

void simple_display() { initReadYUV(width,height); yuvDisplayInit(0,width,height); while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV yuvDisplay(0,y,u,v); // display }}

Display Init & Test

12

Page 13: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

/org.ietr.preesm.sobel/Code/imperative-implem/sample_main.c

#define width 352#define height 288

uchar y[101376];uchar u[25344];uchar v[25344];

void simple_display() { initReadYUV(width,height); yuvDisplayInit(0,width,height); while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV yuvDisplay(0,y,u,v); // display }}

Display Init & Test

13

Page 14: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

/org.ietr.preesm.sobel/Code/imperative-implem/sample_main.c

#define width 352#define height 288

uchar y[101376];uchar u[25344];uchar v[25344];

void simple_display() { initReadYUV(width,height); yuvDisplayInit(0,width,height); while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV yuvDisplay(0,y,u,v); // display }}

Insert Sobel Edge Detection

14

#define width 352#define height 288

uchar y[101376]; uchar u[25344]; uchar v[25344];

void simple_sobel() { initReadYUV(width,height); yuvDisplayInit(0,width,height); //extra array uchar y_sobeled[101376]; while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV sobel(width,height,y,y_sobeled); // Sobel yuvDisplay(0,y_sobeled,u,v); // display }}

Page 15: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

/org.ietr.preesm.sobel/Code/imperative-implem/sample_main.c

#define width 352#define height 288

uchar y[101376];uchar u[25344];uchar v[25344];

void simple_display() { initReadYUV(width,height); yuvDisplayInit(0,width,height); while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV yuvDisplay(0,y,u,v); // display }}

Insert Sobel Edge Detection

15

#define width 352#define height 288

uchar y[101376]; uchar u[25344]; uchar v[25344];

void simple_sobel() { initReadYUV(width,height); yuvDisplayInit(0,width,height); //extra array uchar y_sobeled[101376]; while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV sobel(width,height,y,y_sobeled); // Sobel yuvDisplay(0,y_sobeled,u,v); // display }}

Page 16: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

/org.ietr.preesm.sobel/Code/imperative-implem/sample_main.c

#define width 352#define height 288

uchar y[101376];uchar u[25344];uchar v[25344];

void simple_display() { initReadYUV(width,height); yuvDisplayInit(0,width,height); while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV yuvDisplay(0,y,u,v); // display }}

Insert Sobel Edge Detection

16

#define width 352#define height 288

uchar y[101376]; uchar u[25344]; uchar v[25344];

void simple_sobel() { initReadYUV(width,height); yuvDisplayInit(0,width,height); //extra array uchar y_sobeled[101376]; while(!stopThreads){ readYUV(width,height,y,u,v); // Read_YUV sobel(width,height,y,y_sobeled); // Sobel yuvDisplay(0,y_sobeled,u,v); // display }}

Page 17: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Compile & Run Code– Open terminal in the Code folder

Try out

17

cd imperative-implem

make

./sobel

Page 18: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

PREESMisation - Display

18

• Model Algorithm

• Model Architecture

• Join algo & archi

• Execute using Workflow

Page 19: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Actor Decomposition - Display

19

● (Index = 0; actor is used in stereo algo)

● Actor = init + body

● Size of data tokens

● Fifo token types

/org.ietr.preesm.sobel/Algo/01-simple_display.diagram

Page 20: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

PREESMisation - Display

20

• Model Algorithm

• Model Architecture

• Join algo & archi

• Execute using Workflow

Page 21: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Single Core Target

21

/org.ietr.preesm.sobel/Archi/1CoreX86.slam

Page 22: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

PREESMisation - Display

22

• Model Algorithm

• Model Architecture

• Join algo & archi

• Execute using Workflow

Page 23: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Join using Scenario

23

/org.ietr.preesm.sobel/Scenarios/01-display_1core.scenario

● algo & archi join● data type sizes● target folders● more accurate timings● simulation parameters● PE <-> actors affinity● ...

Page 24: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

PREESMisation - Display

24

• Model Algorithm

• Model Architecture

• Join algo & archi

• Execute using Workflow

Page 25: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Execution with a Workflow

25

/org.ietr.preesm.sobel/Workflows/Codegen.workflow

... ...

• Tells what to do– can reuse workflows

– some Tasks are parametrized

Page 26: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

PREESMisation - Display

26

• Model Algorithm

• Model Architecture

• Join algo & archi

• Execute using Workflow

Page 27: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

PREESMisation

27

• Model Algorithm

• Model Architecture

• Join algo & archi

• Execute using Workflow

Y-co design flow

Page 28: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Generate code– Right click on the Workflow / Preesm / Run Workflow

– Select 01-display...scenario and click on OK

– Observe ABC simulator results

Try out

28

Page 29: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Simulation Results

29

Page 30: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Generate code– Right click on the Workflow / Preesm / Run Workflow

– Select 01-display...scenario and click on OK

– Observe ABC simulator results

– Observe generated code• main.c

• Core0.c

Try out

30

Page 31: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Display - main

31

int main(void){ pthread_barrier_init(&iter_barrier, NULL, 1); communicationInit(); // ... pthread_create(&threadCore0, NULL, computationThread_Core0, NULL); // Waiting for thread terminations pthread_join(threadCore0,NULL);}

Init threads & coms, launch, synchro, wait...

Page 32: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Display - Core0

32

char Shared[152064]; // size:= 152064*charuchar *const u__u__0 = (uchar*) (Shared+0); // Read_YUV_u > display_u size:= 25344*ucharuchar *const v__v__0 = (uchar*) (Shared+25344); // Read_YUV_v > display_v size:= 25344*uchar//...void *computationThread_Core0(void *arg){ // Initialisation(s) initReadYUV(352/*width*/,288/*height*/); // Read_YUV yuvDisplayInit(0/*id*/,352/*width*/,288/*height*/); // display // Begin the execution loop //... while(1){ pthread_barrier_wait(&iter_barrier); readYUV(352/*width*/,288/*height*/,y__y__0,u__u__0,v__v__0); // Read_YUV yuvDisplay(0/*id*/,y__y__0,u__u__0,v__v__0); // display }}

Page 33: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Display - Core0

33

char Shared[152064]; // size:= 152064*charuchar *const u__u__0 = (uchar*) (Shared+0); // Read_YUV_u > display_u size:= 25344*ucharuchar *const v__v__0 = (uchar*) (Shared+25344); // Read_YUV_v > display_v size:= 25344*uchar//...void *computationThread_Core0(void *arg){ // Initialisation(s) initReadYUV(352/*width*/,288/*height*/); // Read_YUV yuvDisplayInit(0/*id*/,352/*width*/,288/*height*/); // display // Begin the execution loop //... while(1){ pthread_barrier_wait(&iter_barrier); readYUV(352/*width*/,288/*height*/,y__y__0,u__u__0,v__v__0); // Read_YUV yuvDisplay(0/*id*/,y__y__0,u__u__0,v__v__0); // display }}

● Total memory requirements● Custom allocation

Page 34: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Display - Core0

34

char Shared[152064]; // size:= 152064*charuchar *const u__u__0 = (uchar*) (Shared+0); // Read_YUV_u > display_u size:= 25344*ucharuchar *const v__v__0 = (uchar*) (Shared+25344); // Read_YUV_v > display_v size:= 25344*uchar//...void *computationThread_Core0(void *arg){ // Initialisation(s) initReadYUV(352/*width*/,288/*height*/); // Read_YUV yuvDisplayInit(0/*id*/,352/*width*/,288/*height*/); // display // Begin the execution loop //... while(1){ pthread_barrier_wait(&iter_barrier); readYUV(352/*width*/,288/*height*/,y__y__0,u__u__0,v__v__0); // Read_YUV yuvDisplay(0/*id*/,y__y__0,u__u__0,v__v__0); // display }}

● Generate calls for init & loop● Automatically replaces

parameter values● Properly pass memory

addresses as arguments

Page 35: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Compile & Run Code– Open terminal in the Code folder

Try out

35

sh CMakeGCC.sh

cd bin/make && make

./Release/sobel

Page 36: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Insert Sobel Filter

36

• Only edit algorithm – well, also scenario, but not architecture

• Insert sobel actor

• Run workflow (generate code)

• Observe Gantt & Code

• Try out

Page 37: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Insert Sobel Filter

37

Page 38: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Insert Sobel Filter

38

Page 39: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Insert Sobel Filter

39

Page 40: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Insert Sobel Filter

40

Scenarios differences:Algo & Actor-PE affinity

Page 41: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Compile & Run Code– Open terminal in the Code folder

Try out

41

sh CMakeGCC.sh

cd bin/make && make

./Release/sobel

Page 42: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Multi Core Target

42

Is there any parallelism ?

Page 43: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Multi Core Target

43

Is there any parallelism ?

while(1){ pthread_barrier_wait(&iter_barrier);

NO Pipeline

Page 44: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Multi Core Target

44

• Add split/merge actors– sobel_input =split_output/nbSlice (i.e. nbSlice = 8)– for one split execution, there will be 8 sobels– 8 sobels can execute in parallel

Page 45: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Multi Core Target

45

• Add split/merge actors– #split input = #split output*nbSlice (i.e. nbSlice = 8)– for one split execution, there will be 8 sobels– 8 sobels can execute in parallel

352 288 0 8

Page 46: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Multi Core Target

46

• Add split/merge actors– #split input = #split output*nbSlice (i.e. nbSlice = 8)– for one split execution, there will be 8 sobels– 8 sobels can execute in parallel

352 288 0 813376 * 8 = 107008

Page 47: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Multi Core Target

47

● Change architecture

● Change scenario

● Run workflow

○ (generate code)

Page 48: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Single Rate DAG

48

After workflow execution : /org.ietr.preesm.sobel/Algo/generated/singlerate/03-parallel_sobel.graphml

Page 49: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Single Rate DAG

49

After workflow execution : /org.ietr.preesm.sobel/Algo/generated/singlerate/03-parallel_sobel.graphml

8 sobels

Page 50: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Observe Simulation

50

8 sobels

Page 51: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Sobel - main

51

//main()...

//…

pthread_create(&threadCore0, NULL, computationThread_Core0, NULL);pthread_create(&threadCore1, NULL, computationThread_Core1, NULL);pthread_create(&threadCore2, NULL, computationThread_Core2, NULL);pthread_create(&threadCore3, NULL, computationThread_Core3, NULL);

//...

Launch more threads.

Page 52: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Sobel - Core0

52

Core0 = main operator

Page 53: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Sobel - Core0

53

Core0 = main operator

• in charge of shared memory (because main op);

• in charge of read & split (see Gantt chart);

• in charge of 2 sobels (0 and 4, see Gantt chart);

Page 54: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Sobel - Core0

54

Core0 = main operator

• in charge of shared memory (because main op);

• in charge of split (see Gantt chart);

• in charge of 2 sobels (0 and 4, see Gantt chart);Allocation of memory

+ declaration of buffer zones within the memory

Page 55: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Sobel - Core0

55

Core0 = main operator

• in charge of shared memory (because main op);

• in charge of split (see Gantt chart);

• in charge of 2 sobels (0 and 4, see Gantt chart);Split + send to all coresDoes the actual copy

see /org.ietr.preesm.sobel/Code/src/communication.c

Page 56: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Sobel - Core0

56

Core0 = main operator

• in charge of shared memory (because main op);

• in charge of split (see Gantt chart);

• in charge of 2 sobels (0 and 4, see Gantt chart);

Compute sobel*2 +Send results

Page 57: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code - Sobel - Core3

57

• access to shared memory;

• in charge of receives + 2 sobels;

• in charge of merge & display (see Gantt chart);

Page 58: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• access to shared memory;

• in charge of receives + 2 sobels;

• in charge of merge & display (see Gantt chart);

Generated Code - Sobel - Core3

58

Access to memory

Page 59: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• access to shared memory;

• in charge of receives + 2 sobels;

• in charge of merge & display (see Gantt chart);

Generated Code - Sobel - Core3

59

Receive dataCompute sobel*2

Page 60: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• access to shared memory;

• in charge of receives + 2 sobels;

• in charge of merge & display (see Gantt chart);

Generated Code - Sobel - Core3

60

● Receive all sobel results○ from other cores only

● Merge○ Does the memcpy

● then display

Page 61: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Generated Code Sobel - Core1,2

61

• Access memory

• Receive*2

• Sobel*2

• Send*2

Page 62: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Compile & Run Code– Open terminal in the Code folder

Try out

62

sh CMakeGCC.sh

cd bin/make && make

./Release/sobel

Observe performance

Page 63: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Further

63

• Why poor perf ?

• Instrument the code ?

• Reuse memory ?

• Dynamic scheduling ?

• Coprime integers Fifo input/output?

• Specify an architecture with different cores, having

different timings ?

Page 64: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Further

64

• Why poor perf ? -> Pipeline (delays), timings

• Instrument the code ? -> Accurate schedule input

• Reuse memory ? -> memory scripts

• Dynamic scheduling ? -> Spider

• Coprime integers Fifo input/output? -> EXPLOSION

• Specify an architecture with different cores, having

different timings ? -> scenario timings

Page 65: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Further - Dynamic Algos

65

Dynamic parameters (set by actor)

=> Spider

Page 66: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Further - Dynamic Algos

66

Dynamic parameters (set by actor)

=> Spider

Actor sets parameter value

Page 67: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

Further - Dynamic Algos

67

Page 68: PREESM Tutorial€¦ · CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy) •Get familiar with PREESM – Play with SDF MoC/SLAM MoA/Y-codesign – Go

CPS Summer School, September 25-29, 2017, Porto Conte Ricerche, Alghero (Italy)

• Rapid prototyping tool

– SDF MoC + SLAM MoA, Y codesign flow

• Parallelism is not free

– in term of design (where/when to add split/merge)

– in term of execution (memcpy everywhere)

• Research Objective (PREESM is a research tool)

– reduce parallelism design and execution cost

– tackle memory optimizations further

Conclusion

68