source: soft/giet_vm/applications/transpose/transpose.py @ 775

Last change on this file since 775 was 775, checked in by alain, 8 years ago

Introduce the dump command in shell.

  • Property svn:executable set to *
File size: 5.7 KB
Line 
1#!/usr/bin/env python
2
3from mapping import *
4
5##################################################################################
6#   file   : transpose.py 
7#   date   : may 2014
8#   author : Alain Greiner
9##################################################################################
10#  This file describes the mapping of the multi-threaded "transpose"
11#  application on a multi-clusters, multi-processors architecture.
12#  There is one thread per processor.
13#  The mapping of virtual segments is the following:
14#    - There is one shared data vseg in cluster[0][0]
15#    - The code vsegs are replicated on all clusters containing processors.
16#    - There is one heap vseg per cluster containing processors.
17#    - The stacks vsegs are distibuted on all clusters containing processors.
18#  This mapping uses 5 platform parameters, (obtained from the "mapping" argument)
19#    - x_size    : number of clusters in a row
20#    - y_size    : number of clusters in a column
21#    - x_width   : number of bits coding x coordinate
22#    - y_width   : number of bits coding y coordinate
23#    - nprocs    : number of processors per cluster
24##################################################################################
25
26######################
27def extend( mapping ):
28
29    x_size    = mapping.x_size
30    y_size    = mapping.y_size
31    nprocs    = mapping.nprocs
32    x_width   = mapping.x_width
33    y_width   = mapping.y_width
34
35    # define vsegs base & size
36    code_base  = 0x10000000
37    code_size  = 0x00010000     # 64 Kbytes  (256 Mbytes max)
38   
39    data_base  = 0x20000000
40    data_size  = 0x00010000     # 64 Kbytes  (256 Mbytes max)
41
42    mmap_base  = 0x30000000 
43    mmap_size  = 0x10000000     # 256 Mbytes (non mapped)
44
45    stack_base = 0x40000000 
46    stack_size = 0x00010000     # 64 Kbytes per thread  (64 Mbytes max)
47
48    heap_base  = 0x60000000 
49    heap_size  = 0x00200000     # 2 Mbytes per cluster  (512 Mbytes max)
50
51    # create vspace
52    vspace = mapping.addVspace( name = 'transpose', startname = 'trsp_data', active = False )
53   
54    # data vseg : shared (only in cluster[0,0])
55    mapping.addVseg( vspace, 'trsp_data', data_base , data_size, 
56                     'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM', 
57                     binpath = 'bin/transpose/appli.elf',
58                     local = False )
59
60    # mmap vseg : non mapped in physical memory
61    mapping.addVseg( vspace, 'trsp_mmap', mmap_base , mmap_size, 
62                     'C_WU', vtype = 'MMAP', local = False )
63
64    # code vsegs : local (one copy in each cluster)
65    for x in xrange (x_size):
66        for y in xrange (y_size):
67            cluster_id = (x * y_size) + y
68            if ( mapping.clusters[cluster_id].procs ):
69
70                mapping.addVseg( vspace, 'trsp_code_%d_%d' %(x,y), 
71                                 code_base , code_size,
72                                 'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM', 
73                                 binpath = 'bin/transpose/appli.elf',
74                                 local = True )
75
76    # stacks vsegs: local (one stack per processor => nprocs stacks per cluster)
77    for x in xrange (x_size):
78        for y in xrange (y_size):
79            cluster_id = (x * y_size) + y
80            if ( mapping.clusters[cluster_id].procs ):
81                for p in xrange( nprocs ):
82                    proc_id = (((x * y_size) + y) * nprocs) + p
83                    base    = stack_base + (proc_id * stack_size)
84                    size    = stack_size - 4096
85                    mapping.addVseg( vspace, 'trsp_stack_%d_%d_%d' % (x,y,p), 
86                                     base , size , 'C_WU', vtype = 'BUFFER', 
87                                     x = x , y = y , pseg = 'RAM',
88                                     local = True )
89
90    # heap vsegs: distributed non local (all heap vsegs can be accessed by all tasks)
91    for x in xrange (x_size):
92        for y in xrange (y_size):
93            cluster_id = (x * y_size) + y
94            if ( mapping.clusters[cluster_id].procs ):
95                size  = heap_size
96                base  = heap_base + (cluster_id * size)
97
98                mapping.addVseg( vspace, 'trsp_heap_%d_%d' % (x,y), base, size, 
99                                 'C_WU', vtype = 'HEAP', x = x, y = y, pseg = 'RAM',
100                                 local = False, big = True )
101
102    # distribute one thread per processor / main on P[0,0,0]
103    for x in xrange (x_size):
104        for y in xrange (y_size):
105            cluster_id = (x * y_size) + y
106            if ( mapping.clusters[cluster_id].procs ):
107                for p in xrange( nprocs ):
108                    if (x == 0) and (y == 0) and (p == 0) :   # main thread
109                        startid = 1
110                        is_main = True
111                    else :                                    # other threads
112                        startid = 0
113                        is_main = False
114
115                    mapping.addThread( vspace,
116                                       'trsp_%d_%d_%d' % (x,y,p),
117                                       is_main,
118                                       x, y, p,
119                                       'trsp_stack_%d_%d_%d' % (x,y,p),
120                                       'trsp_heap_%d_%d' % (x,y),
121                                       startid )
122
123    # extend mapping name
124    mapping.name += '_transpose'
125
126    return vspace  # useful for test
127           
128################################ test ##################################################
129
130if __name__ == '__main__':
131
132    vspace = extend( Mapping( 'test', 2, 2, 4 ) )
133    print vspace.xml()
134
135
136# Local Variables:
137# tab-width: 4;
138# c-basic-offset: 4;
139# c-file-offsets:((innamespace . 0)(inline-open . 0));
140# indent-tabs-mode: nil;
141# End:
142#
143# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
144
Note: See TracBrowser for help on using the repository browser.