source: soft/giet_vm/applications/rosenfeld/rosenfeld.py @ 772

Last change on this file since 772 was 772, checked in by meunier, 8 years ago
  • Ajout de l'application rosenfeld
  • Changement du nom du flag O_CREATE en O_CREAT
  • Property svn:executable set to *
File size: 5.3 KB
Line 
1#!/usr/bin/env python
2
3from mapping import *
4
5##################################################################################
6#   file   : rosenfeld.py
7#   date   : January 2016
8#   author : Quentin Meunier
9##################################################################################
10#  This file describes the mapping of the single-threaded "rosenfeld".
11#  This include both the mapping of virtual segments on the clusters,
12#  and the mapping of tasks on 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 (replicated in each cluster)
38   
39    data_base  = 0x20000000
40    data_size  = 0x00010000     # 64 Kbytes (non replicated)
41
42    stack_base = 0x40000000 
43    stack_size = 0x00200000     # 2 Mbytes (per cluster)
44
45    heap_base  = 0x60000000 
46    heap_size  = 0x00200000     # 2 Mbytes (per cluster)
47
48    # create vspace
49    vspace = mapping.addVspace( name = 'rosenfled', startname = 'rosen_data' )
50   
51    # data vseg : shared (only in cluster[0,0])
52    mapping.addVseg( vspace, 'rosen_data', data_base, data_size, 
53                     'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM', 
54                     binpath = 'bin/rosenfled/appli.elf',
55                     local = False )
56
57    # code vsegs : local (one copy in each cluster)
58    for x in xrange (x_size):
59        for y in xrange (y_size):
60            cluster_id = (x * y_size) + y
61            if ( mapping.clusters[cluster_id].procs ):
62
63                mapping.addVseg( vspace, 'rosen_code_%d_%d' %(x,y), 
64                                 code_base , code_size,
65                                 'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM', 
66                                 binpath = 'bin/rosenfled/appli.elf',
67                                 local = True )
68
69    # stacks vsegs: local (one stack per processor => nprocs stacks per cluster)
70    for x in xrange (x_size):
71        for y in xrange (y_size):
72            cluster_id = (x * y_size) + y
73            if ( mapping.clusters[cluster_id].procs ):
74                for p in xrange( nprocs ):
75                    proc_id = (((x * y_size) + y) * nprocs) + p
76                    size    = (stack_size / nprocs) & 0xFFFFF000
77                    base    = stack_base + (proc_id * size)
78
79                    mapping.addVseg( vspace, 'rosen_stack_%d_%d_%d' % (x,y,p), 
80                                     base, size, 'C_WU', vtype = 'BUFFER', 
81                                     x = x , y = y , pseg = 'RAM',
82                                     local = True, big = True )
83
84    # heap vsegs: distributed non local (all heap vsegs can be accessed by all tasks)
85    for x in xrange (x_size):
86        for y in xrange (y_size):
87            cluster_id = (x * y_size) + y
88            if ( mapping.clusters[cluster_id].procs ):
89                size  = heap_size
90                base  = heap_base + (cluster_id * size)
91
92                mapping.addVseg( vspace, 'rosen_heap_%d_%d' % (x,y), base, size, 
93                                 'C_WU', vtype = 'HEAP', x = x, y = y, pseg = 'RAM',
94                                 local = False, big = True )
95
96    # distributed tasks / one task per processor
97    #for x in xrange (x_size):
98    #    for y in xrange (y_size):
99    #        cluster_id = (x * y_size) + y
100    #        if ( mapping.clusters[cluster_id].procs ):
101    #            for p in xrange( nprocs ):
102    #                trdid = (((x * y_size) + y) * nprocs) + p
103
104    #                mapping.addTask( vspace, 'rosen_%d_%d_%d' % (x,y,p),
105    #                                 trdid, x, y, p,
106    #                                 'rosen_stack_%d_%d_%d' % (x,y,p),
107    #                                 'rosen_heap_%d_%d' % (x,y), 0 )
108    mapping.addThread( vspace, 'main', True, 0, 0, 0,
109                       'rosen_stack_0_0_0',
110                       'rosen_heap_0_0',
111                       0 )                      # index in start_vector
112
113
114    # extend mapping name
115    mapping.name += '_rosenfeld'
116
117    return vspace  # useful for test
118           
119################################ test ##################################################
120
121if __name__ == '__main__':
122
123    vspace = extend( Mapping( 'test', 2, 2, 4 ) )
124    print vspace.xml()
125
126
127# Local Variables:
128# tab-width: 4;
129# c-basic-offset: 4;
130# c-file-offsets:((innamespace . 0)(inline-open . 0));
131# indent-tabs-mode: nil;
132# End:
133#
134# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
135
Note: See TracBrowser for help on using the repository browser.