source: soft/giet_vm/giet_python/genmap @ 768

Last change on this file since 768 was 753, checked in by cfuguet, 9 years ago

Introducing the coremark benchmark

  • Property svn:executable set to *
File size: 15.2 KB
RevLine 
[425]1#!/usr/bin/env python
[319]2
[539]3###################################################################################
[328]4#   file   : genmap
[319]5#   date   : april 2014
6#   author : Alain Greiner
[539]7###################################################################################
[520]8# This generic script maps one or several applications on a specific
[319]9# instance of the multi-processors/multi-clusters TSAR architecture.
10# It generates the files required for hardware and software compilation:
[520]11# 1) The "hard_config.h" file is used to generate the top.cpp file (hardware),
[539]12#    and to compile the tsar_preloader.elf, GietVM boot.elf and kernel.elf files.
[319]13# 2) The optionals "map.bin" and vsegs.ld" files are used to configure the GietVM.
14# 3) The optional "netbsd.dts" file can be used to configure NetBSD.
[411]15# 4) The optional "netbsd.dts" file can be used to configure NetBSD.
16# 5) The optional "arch.bib" file can be used to configure ALMOS.
17# 6) An optional "map.xml" file can be generated for debug.
[539]18###################################################################################
[319]19# The hardware parameters  are:
20#  - x_size    : number of clusters in a row
21#  - y_size    : number of clusters in a column
[453]22#  - nb_procs  : number of processors per cluster
23#  - nb_ttys   : number of TTY channels
24#  - fbf_size  : frame buffer width & heigth
[539]25###################################################################################
[319]26# The supported platforms are:
27# - tsar_generic_iob
28# - tsar_generic_leti
[520]29# - tsar_geberic_mwmr
[539]30###################################################################################
[462]31# The supported applications are:
[591]32# - classif
[462]33# - convol
[591]34# - coproc
35# - dhrystone
[462]36# - display
[500]37# - gameoflife
[729]38# - mjpeg
[591]39# - ocean
[673]40# - raycast
[591]41# - router
42# - sort
43# - shell
44# - transpose
[753]45# - coremark
[539]46###################################################################################
[319]47
48from optparse import OptionParser
49from mapping import *
50
51import sys
52
[539]53###################################################################################
[319]54#   define command line arguments   
[539]55###################################################################################
[319]56
57parser = OptionParser()
58
59parser.add_option( '--arch', type = 'string', dest = 'arch_path',
60                   help = 'define pathname to architecture' )
61
62parser.add_option( '--x', type = 'int', dest = 'x_size', 
63                   default = 2,
64                   help = 'define number of clusters in a row' )
65
66parser.add_option( '--y', type = 'int', dest = 'y_size', 
67                   default = 2,
68                   help = 'define number of clusters in a column' )
69
[453]70parser.add_option( '--p', type = 'int', dest = 'nb_procs', 
[319]71                   default = 2,
72                   help = 'define number of processors per cluster' )
73
[453]74parser.add_option( '--tty', type = 'int', dest = 'nb_ttys', 
75                   default = 1,
76                   help = 'define number of tty channels' )
77
[411]78parser.add_option( '--fbf', type = 'int', dest = 'fbf_size', 
79                   default = 128,
80                   help = 'define frame buffer width and heigth' )
81
[546]82parser.add_option( '--ioc', type = 'string', dest = 'ioc_type',
83                   default = 'BDV',
[565]84                   help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
[546]85
[737]86parser.add_option( '--mwr', type = 'string', dest = 'mwr_type',
87                   default = 'CPY',
88                   help = 'define type of COPROC: CPY / DCT / GCD' )
89
[319]90parser.add_option( '--v', action = 'store_true', dest = 'verbose',
91                   default = False,
92                   help = 'display detailed report on map.bin file generation' )
93
94parser.add_option( '--netbsd', type = 'string', dest = 'netbsd_path', 
95                   help = 'define pathname for the netbsd.dts file' )
96
[411]97parser.add_option( '--linux', type = 'string', dest = 'linux_path', 
98                   help = 'define pathname for the linux.dts file' )
99
[319]100parser.add_option( '--almos', type = 'string', dest = 'almos_path', 
101                   help = 'define pathname for the arch.bib file' )
102
103parser.add_option( '--giet', type = 'string', dest = 'giet_path', 
104                   help = 'define pathname for the map.bin & vsegs.ld file ' )
105
[401]106parser.add_option( '--hard', type = 'string', dest = 'hard_path',
107                   help = 'define pathname for the hard_config.h file ' )
108
[319]109parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
110                   help = 'define pathname for the map.xml file' )
111
[539]112############  supported applications   ############################################
[319]113
[591]114parser.add_option( '--classif', action = 'store_true', dest = 'classif',     
[319]115                   default = False,
[591]116                   help = 'map the "classif" application for the GietVM' )
[319]117
[338]118parser.add_option( '--convol', action = 'store_true', dest = 'convol',     
[328]119                   default = False,
120                   help = 'map the "convol" application for the GietVM' )
121
[591]122parser.add_option( '--coproc', action = 'store_true', dest = 'coproc',     
[421]123                   default = False,
[591]124                   help = 'map the "coproc" application for the GietVM' )
[421]125
[591]126parser.add_option( '--dhrystone', action = 'store_true', dest = 'dhrystone',     
127                   default = False,
128                   help = 'map the "dhrystone" application for the GietVM' )
129
[441]130parser.add_option( '--display', action = 'store_true', dest = 'display',     
131                   default = False,
132                   help = 'map the "display" application for the GietVM' )
133
[500]134parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife',     
135                   default = False,
136                   help = 'map the "gameoflife" application for the GietVM' )
137
[729]138parser.add_option( '--mjpeg', action = 'store_true', dest = 'mjpeg',
139                   default = False,
140                   help = 'map the "mjpeg" application for the GietVM' )
141
[580]142parser.add_option( '--ocean', action = 'store_true', dest = 'ocean',     
143                   default = False,
144                   help = 'map the "ocean" application for the GietVM' )
145
[673]146parser.add_option( '--raycast', action = 'store_true', dest = 'raycast',     
147                   default = False,
148                   help = 'map the "raycast" application for the GietVM' )
149
[591]150parser.add_option( '--router', action = 'store_true', dest = 'router',     
151                   default = False,
152                   help = 'map the "router" application for the GietVM' )
153
154parser.add_option( '--shell', action = 'store_true', dest = 'shell',     
155                   default = False,
156                   help = 'map the "shell" application for the GietVM' )
157
158parser.add_option( '--sort', action = 'store_true', dest = 'sort',     
159                   default = False,
160                   help = 'map the "sort" application for the GietVM' )
161
162parser.add_option( '--transpose', action = 'store_true', dest = 'transpose',
163                   default = False,
164                   help = 'map the "transpose" application for the GietVM' )
165
[753]166parser.add_option( '--coremark', action = 'store_true', dest = 'coremark',     
167                   default = False,
168                   help = 'map the "coremark" application for the GietVM' )
169
[539]170###################################################################################
[319]171#   Get command line arguments
[539]172###################################################################################
[319]173
174(options,args) = parser.parse_args()
175
[500]176x_size         = options.x_size      # number of clusters in a row
177y_size         = options.y_size      # number of clusters in a column
178nb_procs       = options.nb_procs    # number of processors in a cluster
179nb_ttys        = options.nb_ttys     # number of TTY channels           
180fbf_size       = options.fbf_size    # frame buffer width & heigth
[546]181ioc_type       = options.ioc_type    # ioc controller type
[737]182mwr_type       = options.mwr_type    # hardware coprocessor type
[319]183
[500]184verbose        = options.verbose     # report on map.bin generation if True
[319]185
[500]186netbsd_path    = options.netbsd_path # path for netbsd.dts file
187linux_path     = options.linux_path  # path for linux.dts file
188almos_path     = options.almos_path  # path for arch.bib file
189giet_path      = options.giet_path   # path for map.bin & vsegs.ld files
190hard_path      = options.hard_path   # path for the hard_config.h file
[319]191
[500]192arch_path      = options.arch_path   # path to selected architecture
[319]193
[500]194xml_path       = options.xml_path    # path for map.xml file     
[319]195
[591]196map_classif    = options.classif     # map "classif" application if True
[500]197map_convol     = options.convol      # map "convol" application if True
[591]198map_coproc     = options.coproc      # map "coproc" application if True
199map_dhrystone  = options.dhrystone   # map "dhrystone" application if True
[500]200map_display    = options.display     # map "display" application if True
201map_gameoflife = options.gameoflife  # map "gameoflife" application if True
[729]202map_mjpeg      = options.mjpeg       # map "mjpeg" application if True
[580]203map_ocean      = options.ocean       # map "ocean" application if True
[673]204map_raycast    = options.raycast     # map "raycast" application if True
[591]205map_router     = options.router      # map "router" application if True
206map_shell      = options.shell       # map "shell" application if True
207map_sort       = options.sort        # map "sort" application if True
208map_transpose  = options.transpose   # map "transpose" application if True
[753]209map_coremark   = options.coremark    # map "coremark" application if True
[319]210
[539]211###################################################################################
[319]212#   build empty platform (no applications yet)
[539]213###################################################################################
[319]214
215if   ( arch_path == None  ): 
216    print 'You must select a generic architecture on the command line' 
217    sys.exit(1)
218
219# dynamically append the architecture to PYTHON path (directory pathname)
220sys.path.append( arch_path )
221
222# dynamically import the PYTHON mapping generator module (file name)
[338]223select = __import__( 'arch' )
[319]224
225# build mapping calling the function (function name)
[737]226mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type, mwr_type )
[328]227print '[genmap] platform %s build' % mapping.name
[319]228
[539]229###################################################################################
[591]230#   extend mapping with application(s) as required
[539]231###################################################################################
[319]232
[591]233if ( map_classif ):     
234    appli = __import__( 'classif' )
235    appli.extend( mapping )
236    print '[genmap] application "classif" will be loaded'
[319]237
[591]238if ( map_convol ):   
239    appli = __import__( 'convol' )
240    appli.extend( mapping )
[441]241    print '[genmap] application "convol" will be loaded'
[328]242
[591]243if ( map_coproc ):
244    appli = __import__( 'coproc' )
245    appli.extend( mapping )
246    print '[genmap] application "coproc" will be loaded'
[432]247
[591]248if ( map_dhrystone ):     
249    appli = __import__( 'dhrystone' )
250    appli.extend( mapping )
251    print '[genmap] application "dhrystone" will be loaded'
252
[441]253if ( map_display ):     
[591]254    appli = __import__( 'display' )
255    appli.extend( mapping )
[441]256    print '[genmap] application "display" will be loaded'
257
[500]258if ( map_gameoflife ):
[591]259    appli = __import__( 'gameoflife' )
260    appli.extend( mapping )
[500]261    print '[genmap] application "gameoflife" will be loaded'
262
[729]263if ( map_mjpeg ):
264    appli = __import__( 'mjpeg' )
265    appli.extend( mapping )
266    print '[genmap] application "mjpeg" will be loaded'
267
[580]268if ( map_ocean ):
[591]269    appli = __import__( 'ocean' )
270    appli.extend( mapping )
[580]271    print '[genmap] application "ocean" will be loaded'
272
[673]273if ( map_raycast ):     
274    appli = __import__( 'raycast' )
275    appli.extend( mapping )
276    print '[genmap] application "raycast" will be loaded'
277
[591]278if ( map_router ):     
279    appli = __import__( 'router' )
280    appli.extend( mapping )
281    print '[genmap] application "router" will be loaded'
282
283if ( map_shell ):
284    appli = __import__( 'shell' )
285    appli.extend( mapping )
286    print '[geneap] application "shell" will be loaded'
287
288if ( map_sort ):     
289    appli = __import__( 'sort' )
290    appli.extend( mapping )
291    print '[genmap] application "sort" will be loaded'
292
293if ( map_transpose ):
294    appli = __import__( 'transpose' )
295    appli.extend( mapping )
296    print '[genmap] application "transpose" will be loaded'
297
[753]298if ( map_coremark ):
299    appli = __import__( 'coremark' )
300    appli.extend( mapping )
301    print '[genmap] application "coremark" will be loaded'
302
[539]303###################################################################################
[319]304#   Generate xml file if required.
305#   It can be used for debug.
[539]306###################################################################################
[319]307
308if ( xml_path != None ):
309    pathname = xml_path + '/map.xml'
310    f = open ( pathname, 'w' )
311    f.write( mapping.xml() )
[328]312    print '[genmap] %s generated for debug' % pathname
[319]313
[539]314###################################################################################
[319]315#   Generate netbsd.dts file if required.
316#   It is used for NetBSD configuration.
[539]317###################################################################################
[319]318
319if ( (netbsd_path != None) and (arch_path != None) ):
320    pathname = netbsd_path + '/netbsd.dts'
321    f = open ( pathname, 'w' )
322    f.write( mapping.netbsd_dts() )
[411]323    print '[genmap] %s generated' % pathname
[319]324
[539]325###################################################################################
[411]326#   Generate linux.dts file if required.
327#   It is used for LINUX configuration.
[539]328###################################################################################
[411]329
330if ( (linux_path != None) and (arch_path != None) ):
331    pathname = linux_path + '/linux.dts'
332    f = open ( pathname, 'w' )
333    f.write( mapping.linux_dts() )
334    print '[genmap] %s generated' % pathname
335
[539]336###################################################################################
[319]337#   Generate arch.bib file if required.
338#   It is used for ALMOS configuration.
[539]339###################################################################################
[319]340
341if ( (almos_path != None) and (arch_path != None) ):
342    pathname = almos_path + '/arch.info'
343    f = open ( pathname, 'w' )
344    f.write( mapping.almos_arch() )
[328]345    print '[genmap] %s generated for almos' % pathname
[319]346
[539]347###################################################################################
[319]348#   Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
349#   They are used for GietVM compilation and configuration.
[539]350###################################################################################
[319]351
352if ( (giet_path != None) and (arch_path != None) ):
353
354    pathname = giet_path + '/map.bin'
355    f = open ( pathname, 'w' )
356    f.write( str( mapping.cbin( verbose ) ) )
[328]357    print '[genmap] %s generated for giet_vm' % pathname
[319]358
359    pathname = giet_path + '/hard_config.h'
360    f = open ( pathname, 'w' )
361    f.write( mapping.hard_config() )
[328]362    print '[genmap] %s generated for giet_vm' % pathname
[319]363
364    pathname = giet_path + '/giet_vsegs.ld'
365    f = open ( pathname, 'w' )
366    f.write( mapping.giet_vsegs() )
[328]367    print '[genmap] %s generated for giet_vm' % pathname
[319]368
[539]369###################################################################################
[401]370#   Generate hard_config.h file if required.
[539]371###################################################################################
[401]372
373if ( hard_path != None ):
374
375    pathname = hard_path + '/hard_config.h'
376    f = open ( pathname, 'w' )
377    f.write( mapping.hard_config() )
378    print '[genmap] %s generated for %s' % (pathname, arch_path)
379
Note: See TracBrowser for help on using the repository browser.