source: soft/giet_vm/applications/convol/convol.py

Last change on this file was 825, checked in by alain, 7 years ago

1) introduce a new classif application, using the vci_master_nic network controler.
2) use the HEAP type in the python file for heap vsegs in all applications.

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