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

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

sort: using big pages for code segment

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