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

Last change on this file since 825 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.1 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 threads 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    nthreads    = 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', active = False )
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 = 'bin/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 = 'bin/sort/appli.elf',
64                                 local = True )
65
66    # stacks vsegs : local (one stack per thread)
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 threads 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 = 'HEAP', x = x, y = y, pseg = 'RAM',
91                                 local = False, big = True )
92
93    # distributed threads / one thread 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                    if (x == 0) and (y == 0) and (p == 0) :   # main thread
100                        startid = 1
101                        is_main = True
102                    else :                                    # other threads
103                        startid = 0
104                        is_main = False
105
106                    mapping.addThread( vspace, 
107                                       'sort_%d_%d_%d' % (x,y,p),
108                                       is_main,
109                                       x, y, p,
110                                       'sort_stack_%d_%d_%d' % (x,y,p),
111                                       'sort_heap_%d_%d' % (x,y),
112                                       startid )
113
114    # extend mapping name
115    mapping.name += '_sort'
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.