source: soft/giet_vm/applications/classif/classif.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.

File size: 5.6 KB
RevLine 
[457]1#!/usr/bin/env python
2
3from mapping import *
4
[502]5###################################################################################
[589]6#   file   : classif.py
[457]7#   date   : november 2014
8#   author : Alain Greiner
[502]9###################################################################################
[457]10#  This file describes the mapping of the multi-threaded "classif"
11#  application on a multi-clusters, multi-processors architecture.
[708]12#  The mapping of threads on processors is the following:
13#    - the "main" on cluster[0][0] 
[825]14#    - one "analyse" thread per processor,
[502]15#  The mapping of virtual segments is the following:
[473]16#    - There is one shared data vseg in cluster[0][0]
[502]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.
[457]20#  This mapping uses 5 platform parameters, (obtained from the "mapping" argument)
21#    - x_size    : number of clusters in a row
22#    - y_size    : number of clusters in a column
23#    - x_width   : number of bits for x field
24#    - y_width   : number of bits for y field
25#    - nprocs    : number of processors per cluster
[502]26##################################################################################
[457]27
[589]28######################
29def extend( mapping ):
[457]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
[708]38    code_base  = 0x10000000     
39    code_size  = 0x00010000     # 64 Kbytes (per cluster)
[457]40   
41    data_base  = 0x20000000
[708]42    data_size  = 0x00010000     # 64 Kbytes (non replicated)
[457]43
[825]44    stack_base = 0x30000000 
[708]45    stack_size = 0x00010000     # 64 Kbytes (per thread)
[457]46
[825]47    heap_base  = 0x40000000     
48    heap_size  = 0x00200000     # 2 Mbytes (per cluster)
49
[457]50    # create vspace
[720]51    vspace = mapping.addVspace( name = 'classif', 
52                                startname = 'classif_data', 
[825]53                                active = True )
[457]54   
[473]55    # data vseg : shared / cluster[0][0]
56    mapping.addVseg( vspace, 'classif_data', data_base , data_size, 
57                     'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM', 
[610]58                     binpath = 'bin/classif/appli.elf',
[473]59                     local = False )
60
[708]61    # code vsegs : local (one copy per cluster)
[457]62    for x in xrange (x_size):
63        for y in xrange (y_size):
[502]64            cluster_id = (x * y_size) + y
65            if ( mapping.clusters[cluster_id].procs ):
[457]66
[502]67                mapping.addVseg( vspace, 'classif_code_%d_%d' %(x,y), 
68                                 code_base , code_size,
69                                 'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM', 
[610]70                                 binpath = 'bin/classif/appli.elf',
[502]71                                 local = True )
[457]72
[720]73    # stacks vsegs: local (one stack per thread => nprocs stacks per cluster)
[708]74    # ... plus main_stack in cluster[0][0]
75    mapping.addVseg( vspace, 'main_stack',
76                     stack_base, stack_size, 'C_WU', vtype = 'BUFFER', 
77                     x = 0 , y = 0 , pseg = 'RAM',
78                     local = True )
79
[457]80    for x in xrange (x_size):
81        for y in xrange (y_size):
[502]82            cluster_id = (x * y_size) + y
83            if ( mapping.clusters[cluster_id].procs ):
84                for p in xrange( nprocs ):
85                    proc_id = (((x * y_size) + y) * nprocs) + p
[708]86                    base    = stack_base + (proc_id * stack_size) + stack_size
[457]87
[502]88                    mapping.addVseg( vspace, 'classif_stack_%d_%d_%d' % (x,y,p), 
[708]89                                     base, stack_size, 'C_WU', vtype = 'BUFFER', 
[502]90                                     x = x , y = y , pseg = 'RAM',
[708]91                                     local = True )
[457]92
[825]93    # heap vsegs : distributed but non local (any heap can be accessed by any thread)
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                base       = heap_base + (cluster_id * heap_size)
99
100                mapping.addVseg( vspace, 'classif_heap_%d_%d' % (x,y), base, heap_size,
101                                 'C_WU' , vtype = 'HEAP' , x = x , y = y , pseg = 'RAM',
102                                 local = False, big = True )
103
[708]104    # distributed threads / one thread per processor
105    # ... plus main on P[0][0][0]
[825]106    mapping.addThread( vspace, 'main', True, 0, 0, 0,
107                       'main_stack', '' ,
[708]108                       0 )                      # index in start_vector
109
[457]110    for x in xrange (x_size):
111        for y in xrange (y_size):
[502]112            cluster_id = (x * y_size) + y
113            if ( mapping.clusters[cluster_id].procs ):
114                for p in xrange( nprocs ):
[825]115                    start_index = 1
116                    thread_name = 'analyse_%d_%d_%d' % (x,y,p)
[473]117
[708]118                    mapping.addThread( vspace, thread_name, False , x, y, p,
[825]119                                       'classif_stack_%d_%d_%d' % (x,y,p),
[708]120                                       'classif_heap_%d_%d' % (x,y),
[825]121                                        1 )      # index in start_vector
[457]122
123    # extend mapping name
124    mapping.name += '_classif'
125
126    return vspace  # useful for test
127           
[533]128################################ test ############################################
[457]129
130if __name__ == '__main__':
131
[589]132    vspace = extend( Mapping( 'test', 2, 2, 4 ) )
[457]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.