source: soft/giet_vm/applications/coremark/coremark.py @ 756

Last change on this file since 756 was 756, checked in by cfuguet, 8 years ago

Improving the configuration infrastructure of the coremark application

File size: 4.7 KB
Line 
1#!/usr/bin/env python
2
3from mapping import *
4
5###################################################################################
6#   file   : coremark.py
7#   date   : january 2016
8#   author : Cesar FUGUET TORTOLERO
9###################################################################################
10
11######################
12def extend( mapping ):
13
14    x_size    = mapping.x_size
15    y_size    = mapping.y_size
16    nprocs    = mapping.nprocs
17    x_width   = mapping.x_width
18    y_width   = mapping.y_width
19
20    # define vsegs base & size
21    code_base  = 0x10000000
22    code_size  = 0x00010000     # 64 Kbytes (per cluster)
23
24    data_base  = 0x20000000
25    data_size  = 0x00010000     # 64 Kbytes (non replicated)
26
27    heap_base  = 0x30000000
28    heap_size  = 0x00200000     # 2M bytes (per cluster)
29
30    stack_base = 0x40000000
31    stack_size = 0x00010000     # 64 Kbytes (per thread)
32
33    # create vspace
34    vspace = mapping.addVspace( name = 'coremark',
35                                startname = 'coremark_data',
36                                active = True )
37
38    # data vseg : shared / cluster[0][0]
39    mapping.addVseg( vspace, 'coremark_data', data_base , data_size,
40                     'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
41                     binpath = 'bin/coremark/appli.elf',
42                     local = False )
43
44    # heap vsegs : shared (one per cluster)
45    for x in xrange (x_size):
46        for y in xrange (y_size):
47            cluster_id = (x * y_size) + y
48            if ( mapping.clusters[cluster_id].procs ):
49                size  = heap_size
50                base  = heap_base + (cluster_id * size)
51                mapping.addVseg( vspace, 'coremark_heap_%d_%d' %(x,y), base , size,
52                                 'C_WU', vtype = 'HEAP', x = x, y = y, pseg = 'RAM',
53                                 local = False, big = True )
54
55    # code vsegs : local (one copy per cluster)
56    for x in xrange (x_size):
57        for y in xrange (y_size):
58            cluster_id = (x * y_size) + y
59            if ( mapping.clusters[cluster_id].procs ):
60                mapping.addVseg( vspace, 'coremark_code_%d_%d' %(x,y),
61                                 code_base , code_size,
62                                 'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
63                                 binpath = 'bin/coremark/appli.elf',
64                                 local = True )
65
66    # stacks vsegs: local (one stack per thread => nprocs stacks per cluster)
67    # Define also the main_stack in cluster[0][0]. The main_stack cannot be
68    # local as the main thread passes to workers a local parameter.
69    mapping.addVseg( vspace, 'main_stack',
70                     stack_base, stack_size, 'C_WU', vtype = 'BUFFER',
71                     x = 0 , y = 0 , pseg = 'RAM',
72                     local = False )
73
74    for x in xrange (x_size):
75        for y in xrange (y_size):
76            cluster_id = (x * y_size) + y
77            if ( mapping.clusters[cluster_id].procs ):
78                for p in xrange( nprocs ):
79                    proc_id = (((x * y_size) + y) * nprocs) + p
80                    base    = stack_base + (proc_id * stack_size) + stack_size
81                    mapping.addVseg( vspace, 'coremark_stack_%d_%d_%d' % (x,y,p),
82                                     base, stack_size, 'C_WU', vtype = 'BUFFER',
83                                     x = x , y = y , pseg = 'RAM',
84                                     local = True )
85
86    # distributed threads / one thread per processor
87    # ... plus main on P[0][0][0]
88    IS_MAIN = True
89    mapping.addThread( vspace, 'main', IS_MAIN, 0, 0, 0,
90                       'main_stack',
91                       'coremark_heap_0_0',
92                       2 )                      # index in start_vector
93
94    for x in xrange (x_size):
95        for y in xrange (y_size):
96            cluster_id = (x * y_size) + y
97            if ( mapping.clusters[cluster_id].procs ):
98                for p in xrange( nprocs ):
99                    thread_name = 'iterate_%d_%d_%d' % (x,y,p)
100                    mapping.addThread( vspace, thread_name, not IS_MAIN, x, y, p,
101                                       'coremark_stack_%d_%d_%d' % (x,y,p),
102                                       'coremark_heap_%d_%d' % (x,y),
103                                       1 )
104
105    # extend mapping name
106    mapping.name += '_coremark'
107
108    return vspace  # useful for test
109
110################################ test ############################################
111
112if __name__ == '__main__':
113    vspace = extend( Mapping( 'test', 2, 2, 4 ) )
114    print vspace.xml()
115
116
117# Local Variables:
118# tab-width: 4;
119# c-basic-offset: 4;
120# c-file-offsets:((innamespace . 0)(inline-open . 0));
121# indent-tabs-mode: nil;
122# End:
123#
124# vim: filetype=python:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
125
Note: See TracBrowser for help on using the repository browser.