source: soft/giet_vm/sort/sort.py @ 318

Last change on this file since 318 was 318, checked in by alain, 10 years ago

Introducing the sort.py file: mapping for the sort application.

  • Property svn:executable set to *
File size: 4.2 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 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#  - procs_max : 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    procs_max = mapping.procs_max
28    x_width   = mapping.x_width
29    y_width   = mapping.y_width
30
31    ntasks    = x_size * y_size * procs_max
32
33    # define vsegs base & size
34    code_base  = 0x10000000
35    code_size  = 0x00010000     # 64 Kbytes
36   
37    data_base  = 0x20000000
38    data_size  = 0x00010000     # 64 Kbytes
39
40    ptab_base  = 0x30000000
41    ptab_size  = 0x00040000     # 256 Kbytes
42
43    stack_base = 0x40000000 
44    stack_size = 0x00010000     # 64 Kbytes
45
46    heap_base  = 0x50000000 
47    heap_size  = 0x00010000     # 64 Kbytes
48
49    args_base  = 0x60000000 
50    args_size  = 0x00000004     # 4 bytes
51
52    # create Vspace
53    vspace = mapping.addVspace( name = 'sort', startname = 'sort_data' )
54   
55    # non replicated vsegs in cluster[0,0]
56    mapping.addVseg( vspace, 'sort_code', code_base , code_size, 'CXWU', vtype = 'ELF', 
57                     x = 0, y = 0, pseg = 'RAM', binpath = 'build/sort/sort.elf' )
58
59    mapping.addVseg( vspace, 'sort_data', data_base , data_size, 'C_WU', vtype = 'ELF',
60                     x = 0, y = 0, pseg = 'RAM', binpath = 'build/sort/sort.elf' )
61
62    mapping.addVseg( vspace, 'sort_ptab', ptab_base , ptab_size, 'C_WU', vtype = 'PTAB',
63                     x = 0, y = 0, pseg = 'RAM', align = 13 )
64
65    mapping.addVseg( vspace, 'sort_args', args_base , args_size, 'C_WU', vtype = 'CONST',
66                     x = 0, y = 0, pseg = 'RAM', init = ntasks )
67
68    # distributed vsegs: one stack per processor/task, one heap per cluster
69    for x_rep in xrange (x_size):
70        for y_rep in xrange (y_size):
71            cluster_offset = ((x_rep << y_width) + y_rep) << 20  # 1 Mbytes per cluster
72            mapping.addVseg( vspace, 'sort_heap_%d_%d' % (x_rep, y_rep), 
73                             heap_base + cluster_offset, heap_size, 'C_WU', 
74                             vtype = 'BUFFER', x = x_rep, y = y_rep, pseg = 'RAM' )
75           
76            for p in xrange( procs_max ):
77                proc_offset = cluster_offset + (p << 18)         # 256 Kbytes per proc
78                mapping.addVseg( vspace, 'sort_stack_%d_%d_%d' % (x_rep, y_rep, p),
79                                 stack_base + proc_offset, stack_size, 'C_WU',
80                                 vtype = 'BUFFER', x = x_rep, y = y_rep, pseg = 'RAM' )
81           
82    # distributed tasks / one task per processor
83    for x in xrange (x_size):
84        for y in xrange (y_size):
85            for p in xrange( procs_max ):
86
87                trdid = (((x * y_size) + y) * procs_max) + p
88                mapping.addTask( vspace, 'sort_%d_%d_%d' % (x,y,p), trdid, x, y, p,
89                                 'sort_stack_%d_%d_%d' % (x,y,p),
90                                 'sort_heap_%d_%d' % (x,y), 0 )
91
92    # extend mapping name
93    mapping.name += '_sort'
94
95    return vspace  # useful for test
96
97################################ test ######################################################
98
99if __name__ == '__main__':
100   
101    vspace = sort( Mapping( 'test', 2, 2, 4 ) )
102    print vspace.xml()
103
104
105# Local Variables:
106# tab-width: 4;
107# c-basic-offset: 4;
108# c-file-offsets:((innamespace . 0)(inline-open . 0));
109# indent-tabs-mode: nil;
110# End:
111#
112# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
113
Note: See TracBrowser for help on using the repository browser.