source: soft/giet_vm/applications/sort/sort.py @ 589

Last change on this file since 589 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.

  • Property svn:executable set to *
File size: 4.7 KB
Line 
1#!/usr/bin/env python
2
3from mapping import *
4
5####################################################################################
6#   file   : sort.py
7#   date   : may 2014
8#   author : Alain Greiner
9####################################################################################
10#  This file describes the mapping of the multi-threaded "sort"
11#  application on a multi_clusters, multi-processors architecture.
12#  This include both the mapping of virtual segments on the clusters,
13#  and the mapping of tasks on processors.
14#  This mapping uses 5 platform parameters, (obtained from the "mapping" argument)
15#  - x_size    : number of clusters in a row
16#  - y_size    : number of clusters in a column
17#  - x_width   : number of bits coding x coordinate
18#  - y_width   : number of bits coding y coordinate
19#  - nprocs    : number of processors per cluster
20####################################################################################
21
22######################
23def extend( mapping ):
24
25    x_size    = mapping.x_size
26    y_size    = mapping.y_size
27    nprocs    = mapping.nprocs
28    x_width   = mapping.x_width
29    y_width   = mapping.y_width
30
31    ntasks    = x_size * y_size * nprocs
32
33    # define vsegs base & size
34    code_base  = 0x10000000
35    code_size  = 0x00010000     # 64 Kbytes (replicated in each cluster)
36
37    data_base  = 0x20000000
38    data_size  = 0x00010000     # 64 Kbyte (non replicated)
39
40    stack_base = 0x40000000
41    stack_size = 0x00200000     # 2 Mbytes (per cluster)
42
43    heap_base  = 0x60000000
44    heap_size  = 0x00200000     # 2 Mbytes (per cluster)
45
46    # create Vspace
47    vspace = mapping.addVspace( name = 'sort', startname = 'sort_data' )
48
49    # data vseg : non local (only in cluster[0,0])
50    mapping.addVseg( vspace, 'sort_data', data_base , data_size,
51                     'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
52                     binpath = 'build/sort/appli.elf',
53                     local = False )
54
55    # code vsegs : local (one copy per cluster)
56    for x in xrange (x_size):
57        for y in xrange (y_size):
58            cluster_id = (x * y_size) + y
59            if ( mapping.clusters[cluster_id].procs ):
60
61                mapping.addVseg( vspace, 'sort_code', code_base , code_size,
62                                 'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
63                                 binpath = 'build/sort/appli.elf',
64                                 local = True )
65
66    # stacks vsegs : local (one stack per task)
67    for x in xrange (x_size):
68        for y in xrange (y_size):
69            cluster_id = (x * y_size) + y
70            if ( mapping.clusters[cluster_id].procs ):
71                for p in xrange (nprocs):
72                    proc_id = (((x * y_size) + y) * nprocs) + p
73                    size    = stack_size / nprocs
74                    base    = stack_base + (proc_id * size)
75
76                    mapping.addVseg( vspace, 'sort_stack_%d_%d_%d' % (x,y,p), 
77                                     base, size, 'C_WU', vtype = 'BUFFER',
78                                     x = x, y = y, pseg = 'RAM',
79                                     local = True, big = True )
80
81    # heap vsegs : distributed but non local (all tasks can access all heap vsegs)
82    for x in xrange (x_size):
83        for y in xrange (y_size):
84            cluster_id = (x * y_size) + y
85            if ( mapping.clusters[cluster_id].procs ):
86                size       = heap_size
87                base       = heap_base + (cluster_id * size)
88
89                mapping.addVseg( vspace, 'sort_heap_%d_%d' % (x,y), base, size,
90                                 'C_WU', vtype = 'BUFFER', x = x, y = y, pseg = 'RAM',
91                                 local = False, big = True )
92
93    # distributed tasks / one task per processor
94    for x in xrange (x_size):
95        for y in xrange (y_size):
96            cluster_id = (x * y_size) + y
97            if ( mapping.clusters[cluster_id].procs ):
98                for p in xrange( nprocs ):
99                    trdid = (((x * y_size) + y) * nprocs) + p
100
101                    mapping.addTask( vspace, 'sort_%d_%d_%d' % (x,y,p),
102                                     trdid, x, y, p,
103                                     'sort_stack_%d_%d_%d' % (x,y,p),
104                                     'sort_heap_%d_%d' % (x,y), 0 )
105
106    # extend mapping name
107    mapping.name += '_sort'
108
109    return vspace  # useful for test
110
111################################ test ###################################################
112
113if __name__ == '__main__':
114
115    vspace = extend( Mapping( 'test', 2, 2, 4 ) )
116    print vspace.xml()
117
118
119# Local Variables:
120# tab-width: 4;
121# c-basic-offset: 4;
122# c-file-offsets:((innamespace . 0)(inline-open . 0));
123# indent-tabs-mode: nil;
124# End:
125#
126# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
127
Note: See TracBrowser for help on using the repository browser.