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

Last change on this file since 610 was 610, checked in by alain, 9 years ago

Rename the path to .elf file in the "appli.py" files,
because the "build" directory has been renamed to "bin" on virtual disk.

  • Property svn:executable set to *
File size: 4.7 KB
RevLine 
[318]1#!/usr/bin/env python
2
3from mapping import *
4
5####################################################################################
[589]6#   file   : sort.py
[318]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.
[407]12#  This include both the mapping of virtual segments on the clusters,
[318]13#  and the mapping of tasks 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
[416]19#  - nprocs    : number of processors per cluster
[318]20####################################################################################
21
[589]22######################
23def extend( mapping ):
[318]24
25    x_size    = mapping.x_size
26    y_size    = mapping.y_size
[416]27    nprocs    = mapping.nprocs
[318]28    x_width   = mapping.x_width
29    y_width   = mapping.y_width
30
[416]31    ntasks    = x_size * y_size * nprocs
[318]32
33    # define vsegs base & size
34    code_base  = 0x10000000
[502]35    code_size  = 0x00010000     # 64 Kbytes (replicated in each cluster)
[407]36
[318]37    data_base  = 0x20000000
[502]38    data_size  = 0x00010000     # 64 Kbyte (non replicated)
[318]39
[407]40    stack_base = 0x40000000
[416]41    stack_size = 0x00200000     # 2 Mbytes (per cluster)
[318]42
[416]43    heap_base  = 0x60000000
44    heap_size  = 0x00200000     # 2 Mbytes (per cluster)
[318]45
46    # create Vspace
47    vspace = mapping.addVspace( name = 'sort', startname = 'sort_data' )
[407]48
[416]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',
[610]52                     binpath = 'bin/sort/appli.elf',
[502]53                     local = False )
[318]54
[416]55    # code vsegs : local (one copy per cluster)
56    for x in xrange (x_size):
57        for y in xrange (y_size):
[502]58            cluster_id = (x * y_size) + y
59            if ( mapping.clusters[cluster_id].procs ):
[318]60
[502]61                mapping.addVseg( vspace, 'sort_code', code_base , code_size,
62                                 'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
[610]63                                 binpath = 'bin/sort/appli.elf',
[502]64                                 local = True )
65
[416]66    # stacks vsegs : local (one stack per task)
67    for x in xrange (x_size):
68        for y in xrange (y_size):
[502]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)
[407]75
[502]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 tasks can access all heap vsegs)
82    for x in xrange (x_size):
83        for y in xrange (y_size):
[416]84            cluster_id = (x * y_size) + y
[502]85            if ( mapping.clusters[cluster_id].procs ):
86                size       = heap_size
87                base       = heap_base + (cluster_id * size)
[407]88
[502]89                mapping.addVseg( vspace, 'sort_heap_%d_%d' % (x,y), base, size,
90                                 'C_WU', vtype = 'BUFFER', x = x, y = y, pseg = 'RAM',
91                                 local = False, big = True )
92
[318]93    # distributed tasks / one task per processor
[416]94    for x in xrange (x_size):
95        for y in xrange (y_size):
[502]96            cluster_id = (x * y_size) + y
97            if ( mapping.clusters[cluster_id].procs ):
98                for p in xrange( nprocs ):
99                    trdid = (((x * y_size) + y) * nprocs) + p
[318]100
[502]101                    mapping.addTask( vspace, 'sort_%d_%d_%d' % (x,y,p),
102                                     trdid, x, y, p,
103                                     'sort_stack_%d_%d_%d' % (x,y,p),
104                                     'sort_heap_%d_%d' % (x,y), 0 )
105
[318]106    # extend mapping name
107    mapping.name += '_sort'
108
109    return vspace  # useful for test
110
[407]111################################ test ###################################################
[318]112
113if __name__ == '__main__':
[407]114
[589]115    vspace = extend( Mapping( 'test', 2, 2, 4 ) )
[318]116    print vspace.xml()
117
118
119# Local Variables:
120# tab-width: 4;
121# c-basic-offset: 4;
122# c-file-offsets:((innamespace . 0)(inline-open . 0));
123# indent-tabs-mode: nil;
124# End:
125#
126# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
127
Note: See TracBrowser for help on using the repository browser.