source: soft/giet_vm/applications/router/router.py @ 595

Last change on this file since 595 was 589, checked in by alain, 9 years ago

Modify all applications to support two new rules:
1) introduce a local Makefile for each application.
2) change "application.elf" name to "application/appli.elf" name in the application.py" file.
Introduce the shell application.

File size: 5.0 KB
Line 
1#!/usr/bin/env python
2
3from mapping import *
4
5######################################################################################
6#   file   : router.py
7#   date   : november 2014
8#   author : Alain Greiner
9#######################################################################################
10#  This file describes the mapping of the multi-threaded "router"
11#  application on a multi-clusters, multi-processors architecture.
12#  This application contains N+2 parallel tasks communicating through MWMR channels:
13#  The mapping of virtual segments on the clusters is the following:
14#    - The code vsegs are replicated on all clusters.
15#    - the data_0 vseg is mapped on cluster[0,0].
16#    - the data_1 vseg is mapped on cluster[x_size-1,y_size-1].
17#    - the stacks vsegs are distibuted on all clusters.
18#  The mapping of tasks on processors is the following:
19#    - one "producer" task  => on proc[0,0,0]
20#    - one "consume"  task  => on proc[x_size-1,y_size-1,nprocs-1]
21#    - N   "router"   tasks => on all others processors
22#  This mapping uses 5 platform parameters, (obtained from the "mapping" argument)
23#    - x_size    : number of clusters in a row
24#    - y_size    : number of clusters in a column
25#    - nprocs    : number of processors per cluster
26####################################################################################
27
28######################
29def extend( mapping ):
30
31    x_size    = mapping.x_size
32    y_size    = mapping.y_size
33    nprocs    = mapping.nprocs
34    x_width   = mapping.x_width
35    y_width   = mapping.y_width
36
37    # define vsegs base & size
38    code_base    = 0x10000000
39    code_size    = 0x00010000     # 64 Kbytes (replicated in each cluster)
40   
41    data_0_base  = 0x20000000
42    data_0_size  = 0x00010000     # 64 Kbytes (non replicated)
43
44    data_1_base  = 0x30000000
45    data_1_size  = 0x00010000     # 64 Kbytes (non replicated)
46
47    stack_base   = 0x40000000 
48    stack_size   = 0x00200000     # 2 Mbytes (per cluster)
49
50    # create vspace
51    vspace = mapping.addVspace( name = 'router', startname = 'router_data_0' )
52   
53    # data_0 vseg : shared / in cluster [0,0]
54    mapping.addVseg( vspace, 'router_data_0', data_0_base , data_0_size, 
55                     'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM', 
56                     binpath = 'build/router/appli.elf',
57                     local = False )
58
59    # data_1 vseg : shared / in cluster[x_size-1,y_size-1]
60    mapping.addVseg( vspace, 'router_data_1', data_1_base , data_1_size, 
61                     'C_WU', vtype = 'ELF', x = x_size - 1, y = y_size - 1, pseg = 'RAM', 
62                     binpath = 'build/router/appli.elf',
63                     local = False )
64
65    # code vsegs : local (one copy in each cluster)
66    for x in xrange (x_size):
67        for y in xrange (y_size):
68            mapping.addVseg( vspace, 'router_code_%d_%d' %(x,y), code_base , code_size,
69                             'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM', 
70                             binpath = 'build/router/router.elf',
71                             local = True )
72
73    # stacks vsegs: local (one stack per processor => nprocs stacks per cluster)           
74    for x in xrange (x_size):
75        for y in xrange (y_size):
76            for p in xrange( nprocs ):
77                proc_id = (((x * y_size) + y) * nprocs) + p
78                size    = stack_size / nprocs
79                base    = stack_base + (proc_id * size)
80                mapping.addVseg( vspace, 'router_stack_%d_%d_%d' % (x,y,p), base, size,
81                                 'C_WU', vtype = 'BUFFER', x = x , y = y , pseg = 'RAM',
82                                 local = True, big = True )
83
84    # distributed tasks / one task per processor
85    for x in xrange (x_size):
86        for y in xrange (y_size):
87            for p in xrange( nprocs ):
88                trdid = (((x * y_size) + y) * nprocs) + p
89                if   (x==0) and (y==0) and (p== 0):                      # task producer
90                    task_index = 2
91                    task_name  = 'producer'           
92                elif (x==x_size-1) and (y==y_size-1) and (p==nprocs-1):  # task consumer
93                    task_index = 1 
94                    task_name  = 'consumer'
95                else :                                                   # task router
96                    task_index = 0
97                    task_name  = 'router_%d_%d_%d' % (x,y,p)
98                mapping.addTask( vspace, task_name, trdid, x, y, p,
99                                 'router_stack_%d_%d_%d' % (x,y,p), '' , task_index )
100
101    # extend mapping name
102    mapping.name += '_router'
103
104    return vspace  # useful for test
105           
106################################ test ######################################################
107
108if __name__ == '__main__':
109
110    vspace = extend( Mapping( 'test', 2, 2, 4 ) )
111    print vspace.xml()
112
113
114# Local Variables:
115# tab-width: 4;
116# c-basic-offset: 4;
117# c-file-offsets:((innamespace . 0)(inline-open . 0));
118# indent-tabs-mode: nil;
119# End:
120#
121# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
122
Note: See TracBrowser for help on using the repository browser.