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

Last change on this file since 434 was 434, checked in by cfuguet, 10 years ago

sort: using big pages for code and data

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1#!/usr/bin/env python
2
3from mapping import *
4
5####################################################################################
6#   file   : sort.py  (for the sort application)
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 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
19#  - nprocs    : number of processors per cluster
20####################################################################################
21
22####################
23def sort( 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    ntasks    = x_size * y_size * nprocs
32
33    # define vsegs base & size
34    code_base  = 0x10000000
35    code_size  = 0x00200000     # 2 Mbytes (replicated in each cluster)
36
37    data_base  = 0x20000000
38    data_size  = 0x00100000     # 1 Mbyte (non replicated)
39
40    args_base  = 0x20100000
41    args_size  = 0x00000004     # 4 bytes (non replicated)
42
43    stack_base = 0x40000000
44    stack_size = 0x00200000     # 2 Mbytes (per cluster)
45
46    heap_base  = 0x60000000
47    heap_size  = 0x00200000     # 2 Mbytes (per cluster)
48
49    # create Vspace
50    vspace = mapping.addVspace( name = 'sort', startname = 'sort_data' )
51
52    # data vseg : non local (only in cluster[0,0])
53    mapping.addVseg( vspace, 'sort_data', data_base , data_size,
54                     'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
55                     binpath = 'build/sort/sort.elf',
56                     local = False, big = True )
57
58    # args vseg : non local (only in cluster[0,0])
59    mapping.addVseg( vspace, 'sort_args', args_base , args_size,
60                     'C_WU', vtype = 'CONST', x = 0, y = 0, pseg = 'RAM',
61                     init = ntasks,
62                     local = False, big = True )
63
64    # code vsegs : local (one copy per cluster)
65    for x in xrange (x_size):
66        for y in xrange (y_size):
67            mapping.addVseg( vspace, 'sort_code', code_base , code_size,
68                             'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
69                             binpath = 'build/sort/sort.elf',
70                             local = True, big = True )
71
72    # stacks vsegs : local (one stack per task)
73    for x in xrange (x_size):
74        for y in xrange (y_size):
75            for p in xrange (nprocs):
76                proc_id = (((x * y_size) + y) * nprocs) + p
77                size    = stack_size / nprocs
78                base    = stack_base + (proc_id * size)
79                mapping.addVseg( vspace, 'sort_stack_%d_%d_%d' % (x,y,p), base, size,
80                                 'C_WU', vtype = 'BUFFER', x = x, y = y, pseg = 'RAM',
81                                 local = True, big = True )
82
83            # heap vsegs : distributed but non local (all tasks can access all heap vsegs)
84            cluster_id = (x * y_size) + y
85            size       = heap_size
86            base       = heap_base + (cluster_id * size)
87            mapping.addVseg( vspace, 'sort_heap_%d_%d' % (x,y), base, size,
88                             'C_WU', vtype = 'BUFFER', x = x, y = y, pseg = 'RAM',
89                             local = False, big = True )
90
91    # distributed tasks / one task per processor
92    for x in xrange (x_size):
93        for y in xrange (y_size):
94            for p in xrange( nprocs ):
95                trdid = (((x * y_size) + y) * nprocs) + p
96                mapping.addTask( vspace, 'sort_%d_%d_%d' % (x,y,p), trdid, x, y, p,
97                                 'sort_stack_%d_%d_%d' % (x,y,p),
98                                 'sort_heap_%d_%d' % (x,y), 0 )
99
100    # extend mapping name
101    mapping.name += '_sort'
102
103    return vspace  # useful for test
104
105################################ test ###################################################
106
107if __name__ == '__main__':
108
109    vspace = sort( Mapping( 'test', 2, 2, 4 ) )
110    print vspace.xml()
111
112
113# Local Variables:
114# tab-width: 4;
115# c-basic-offset: 4;
116# c-file-offsets:((innamespace . 0)(inline-open . 0));
117# indent-tabs-mode: nil;
118# End:
119#
120# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
121
Note: See TracBrowser for help on using the repository browser.