source: soft/giet_vm/transpose/transpose.py @ 347

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

Cosmetic

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1#!/usr/bin/env python
2
3from mapping import *
4
5######################################################################################
6#   file   : transpose.py  (for the transpose application)
7#   date   : may 2014
8#   author : Alain Greiner
9#######################################################################################
10#  This file describes the mapping of the multi-threaded "transpose"
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 transpose( 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    # define vsegs base & size
32    code_base  = 0x10000000
33    code_size  = 0x00010000     # 64 Kbytes
34   
35    data_base  = 0x20000000
36    data_size  = 0x00010000     # 64 Kbytes
37
38    ptab_base  = 0x30000000
39    ptab_size  = 0x00040000     # 256 Kbytes
40
41    stack_base = 0x40000000 
42    stack_size = 0x00010000     # 64 Kbytes
43
44    heap_base  = 0x50000000 
45    heap_size  = 0x00010000     # 64 Kbytes
46
47    # create Vspace
48    vspace = mapping.addVspace( name = 'transpose', startname = 'trsp_data' )
49   
50    # non replicated vsegs in cluster[0,0]
51    mapping.addVseg( vspace, 'trsp_code', code_base , code_size, 'CXWU', vtype = 'ELF', 
52                     x = 0, y = 0, pseg = 'RAM', binpath = 'build/transpose/transpose.elf' )
53
54    mapping.addVseg( vspace, 'trsp_data', data_base , data_size, 'C_WU', vtype = 'ELF',
55                     x = 0, y = 0, pseg = 'RAM', binpath = 'build/transpose/transpose.elf' )
56
57    mapping.addVseg( vspace, 'trsp_ptab', ptab_base , ptab_size, 'C_WU', vtype = 'PTAB',
58                     x = 0, y = 0, pseg = 'RAM', align = 13 )
59
60    # distributed vsegs: one stack per processor/task, one heap per cluster
61    for x_rep in xrange (x_size):
62        for y_rep in xrange (y_size):
63            cluster_offset = ((x_rep << y_width) + y_rep) << 20  # 1 Mbytes per cluster
64            mapping.addVseg( vspace, 'trsp_heap_%d_%d' % (x_rep, y_rep), 
65                             heap_base + cluster_offset, heap_size, 'C_WU', 
66                             vtype = 'BUFFER', x = x_rep, y = y_rep, pseg = 'RAM' )
67           
68            for p in xrange( procs_max ):
69                proc_offset = cluster_offset + (p << 18)         # 256 Kbytes per proc
70                mapping.addVseg( vspace, 'trsp_stack_%d_%d_%d' % (x_rep, y_rep, p),
71                                 stack_base + proc_offset, stack_size, 'C_WU',
72                                 vtype = 'BUFFER', x = x_rep, y = y_rep, pseg = 'RAM' )
73           
74    # distributed tasks / one task per processor
75    for x in xrange (x_size):
76        for y in xrange (y_size):
77            for p in xrange( procs_max ):
78
79                trdid = (((x * y_size) + y) * procs_max) + p
80                mapping.addTask( vspace, 'sort_%d_%d_%d' % (x,y,p), trdid, x, y, p,
81                                 'trsp_stack_%d_%d_%d' % (x,y,p),
82                                 'trsp_heap_%d_%d' % (x,y), 0 )
83
84    # extend mapping name
85    mapping.name += '_transpose'
86
87    return vspace  # useful for test
88           
89################################ test ######################################################
90
91if __name__ == '__main__':
92
93    vspace = transpose( Mapping( 'test', 2, 2, 4 ) )
94    print vspace.xml()
95
96
97# Local Variables:
98# tab-width: 4;
99# c-basic-offset: 4;
100# c-file-offsets:((innamespace . 0)(inline-open . 0));
101# indent-tabs-mode: nil;
102# End:
103#
104# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
105
Note: See TracBrowser for help on using the repository browser.