source: soft/giet_vm/giet_python/genmap @ 648

Last change on this file since 648 was 591, checked in by alain, 9 years ago

Introduce support for new applications (11 applications supported).

  • Property svn:executable set to *
File size: 13.7 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
[591]38# - ocean
39# - router
40# - sort
41# - shell
42# - transpose
[539]43###################################################################################
[319]44
45from optparse import OptionParser
46from mapping import *
47
48import sys
49
[539]50###################################################################################
[319]51#   define command line arguments   
[539]52###################################################################################
[319]53
54parser = OptionParser()
55
56parser.add_option( '--arch', type = 'string', dest = 'arch_path',
57                   help = 'define pathname to architecture' )
58
59parser.add_option( '--x', type = 'int', dest = 'x_size', 
60                   default = 2,
61                   help = 'define number of clusters in a row' )
62
63parser.add_option( '--y', type = 'int', dest = 'y_size', 
64                   default = 2,
65                   help = 'define number of clusters in a column' )
66
[453]67parser.add_option( '--p', type = 'int', dest = 'nb_procs', 
[319]68                   default = 2,
69                   help = 'define number of processors per cluster' )
70
[453]71parser.add_option( '--tty', type = 'int', dest = 'nb_ttys', 
72                   default = 1,
73                   help = 'define number of tty channels' )
74
[411]75parser.add_option( '--fbf', type = 'int', dest = 'fbf_size', 
76                   default = 128,
77                   help = 'define frame buffer width and heigth' )
78
[546]79parser.add_option( '--ioc', type = 'string', dest = 'ioc_type',
80                   default = 'BDV',
[565]81                   help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
[546]82
[319]83parser.add_option( '--v', action = 'store_true', dest = 'verbose',
84                   default = False,
85                   help = 'display detailed report on map.bin file generation' )
86
87parser.add_option( '--netbsd', type = 'string', dest = 'netbsd_path', 
88                   help = 'define pathname for the netbsd.dts file' )
89
[411]90parser.add_option( '--linux', type = 'string', dest = 'linux_path', 
91                   help = 'define pathname for the linux.dts file' )
92
[319]93parser.add_option( '--almos', type = 'string', dest = 'almos_path', 
94                   help = 'define pathname for the arch.bib file' )
95
96parser.add_option( '--giet', type = 'string', dest = 'giet_path', 
97                   help = 'define pathname for the map.bin & vsegs.ld file ' )
98
[401]99parser.add_option( '--hard', type = 'string', dest = 'hard_path',
100                   help = 'define pathname for the hard_config.h file ' )
101
[319]102parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
103                   help = 'define pathname for the map.xml file' )
104
[539]105############  supported applications   ############################################
[319]106
[591]107parser.add_option( '--classif', action = 'store_true', dest = 'classif',     
[319]108                   default = False,
[591]109                   help = 'map the "classif" application for the GietVM' )
[319]110
[338]111parser.add_option( '--convol', action = 'store_true', dest = 'convol',     
[328]112                   default = False,
113                   help = 'map the "convol" application for the GietVM' )
114
[591]115parser.add_option( '--coproc', action = 'store_true', dest = 'coproc',     
[421]116                   default = False,
[591]117                   help = 'map the "coproc" application for the GietVM' )
[421]118
[591]119parser.add_option( '--dhrystone', action = 'store_true', dest = 'dhrystone',     
120                   default = False,
121                   help = 'map the "dhrystone" application for the GietVM' )
122
[441]123parser.add_option( '--display', action = 'store_true', dest = 'display',     
124                   default = False,
125                   help = 'map the "display" application for the GietVM' )
126
[500]127parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife',     
128                   default = False,
129                   help = 'map the "gameoflife" application for the GietVM' )
130
[580]131parser.add_option( '--ocean', action = 'store_true', dest = 'ocean',     
132                   default = False,
133                   help = 'map the "ocean" application for the GietVM' )
134
[591]135parser.add_option( '--router', action = 'store_true', dest = 'router',     
136                   default = False,
137                   help = 'map the "router" application for the GietVM' )
138
139parser.add_option( '--shell', action = 'store_true', dest = 'shell',     
140                   default = False,
141                   help = 'map the "shell" application for the GietVM' )
142
143parser.add_option( '--sort', action = 'store_true', dest = 'sort',     
144                   default = False,
145                   help = 'map the "sort" application for the GietVM' )
146
147parser.add_option( '--transpose', action = 'store_true', dest = 'transpose',
148                   default = False,
149                   help = 'map the "transpose" application for the GietVM' )
150
[539]151###################################################################################
[319]152#   Get command line arguments
[539]153###################################################################################
[319]154
155(options,args) = parser.parse_args()
156
[500]157x_size         = options.x_size      # number of clusters in a row
158y_size         = options.y_size      # number of clusters in a column
159nb_procs       = options.nb_procs    # number of processors in a cluster
160nb_ttys        = options.nb_ttys     # number of TTY channels           
161fbf_size       = options.fbf_size    # frame buffer width & heigth
[546]162ioc_type       = options.ioc_type    # ioc controller type
[319]163
[500]164verbose        = options.verbose     # report on map.bin generation if True
[319]165
[500]166netbsd_path    = options.netbsd_path # path for netbsd.dts file
167linux_path     = options.linux_path  # path for linux.dts file
168almos_path     = options.almos_path  # path for arch.bib file
169giet_path      = options.giet_path   # path for map.bin & vsegs.ld files
170hard_path      = options.hard_path   # path for the hard_config.h file
[319]171
[500]172arch_path      = options.arch_path   # path to selected architecture
[319]173
[500]174xml_path       = options.xml_path    # path for map.xml file     
[319]175
[591]176map_classif    = options.classif     # map "classif" application if True
[500]177map_convol     = options.convol      # map "convol" application if True
[591]178map_coproc     = options.coproc      # map "coproc" application if True
179map_dhrystone  = options.dhrystone   # map "dhrystone" application if True
[500]180map_display    = options.display     # map "display" application if True
181map_gameoflife = options.gameoflife  # map "gameoflife" application if True
[580]182map_ocean      = options.ocean       # map "ocean" application if True
[591]183map_router     = options.router      # map "router" application if True
184map_shell      = options.shell       # map "shell" application if True
185map_sort       = options.sort        # map "sort" application if True
186map_transpose  = options.transpose   # map "transpose" application if True
[319]187
[539]188###################################################################################
[319]189#   build empty platform (no applications yet)
[539]190###################################################################################
[319]191
192if   ( arch_path == None  ): 
193    print 'You must select a generic architecture on the command line' 
194    sys.exit(1)
195
196# dynamically append the architecture to PYTHON path (directory pathname)
197sys.path.append( arch_path )
198
199# dynamically import the PYTHON mapping generator module (file name)
[338]200select = __import__( 'arch' )
[319]201
202# build mapping calling the function (function name)
[546]203mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type )
[328]204print '[genmap] platform %s build' % mapping.name
[319]205
[539]206###################################################################################
[591]207#   extend mapping with application(s) as required
[539]208###################################################################################
[319]209
[591]210if ( map_classif ):     
211    appli = __import__( 'classif' )
212    appli.extend( mapping )
213    print '[genmap] application "classif" will be loaded'
[319]214
[591]215if ( map_convol ):   
216    appli = __import__( 'convol' )
217    appli.extend( mapping )
[441]218    print '[genmap] application "convol" will be loaded'
[328]219
[591]220if ( map_coproc ):
221    appli = __import__( 'coproc' )
222    appli.extend( mapping )
223    print '[genmap] application "coproc" will be loaded'
[432]224
[591]225if ( map_dhrystone ):     
226    appli = __import__( 'dhrystone' )
227    appli.extend( mapping )
228    print '[genmap] application "dhrystone" will be loaded'
229
[441]230if ( map_display ):     
[591]231    appli = __import__( 'display' )
232    appli.extend( mapping )
[441]233    print '[genmap] application "display" will be loaded'
234
[500]235if ( map_gameoflife ):
[591]236    appli = __import__( 'gameoflife' )
237    appli.extend( mapping )
[500]238    print '[genmap] application "gameoflife" will be loaded'
239
[580]240if ( map_ocean ):
[591]241    appli = __import__( 'ocean' )
242    appli.extend( mapping )
[580]243    print '[genmap] application "ocean" will be loaded'
244
[591]245if ( map_router ):     
246    appli = __import__( 'router' )
247    appli.extend( mapping )
248    print '[genmap] application "router" will be loaded'
249
250if ( map_shell ):
251    appli = __import__( 'shell' )
252    appli.extend( mapping )
253    print '[geneap] application "shell" will be loaded'
254
255if ( map_sort ):     
256    appli = __import__( 'sort' )
257    appli.extend( mapping )
258    print '[genmap] application "sort" will be loaded'
259
260if ( map_transpose ):
261    appli = __import__( 'transpose' )
262    appli.extend( mapping )
263    print '[genmap] application "transpose" will be loaded'
264
[539]265###################################################################################
[319]266#   Generate xml file if required.
267#   It can be used for debug.
[539]268###################################################################################
[319]269
270if ( xml_path != None ):
271    pathname = xml_path + '/map.xml'
272    f = open ( pathname, 'w' )
273    f.write( mapping.xml() )
[328]274    print '[genmap] %s generated for debug' % pathname
[319]275
[539]276###################################################################################
[319]277#   Generate netbsd.dts file if required.
278#   It is used for NetBSD configuration.
[539]279###################################################################################
[319]280
281if ( (netbsd_path != None) and (arch_path != None) ):
282    pathname = netbsd_path + '/netbsd.dts'
283    f = open ( pathname, 'w' )
284    f.write( mapping.netbsd_dts() )
[411]285    print '[genmap] %s generated' % pathname
[319]286
[539]287###################################################################################
[411]288#   Generate linux.dts file if required.
289#   It is used for LINUX configuration.
[539]290###################################################################################
[411]291
292if ( (linux_path != None) and (arch_path != None) ):
293    pathname = linux_path + '/linux.dts'
294    f = open ( pathname, 'w' )
295    f.write( mapping.linux_dts() )
296    print '[genmap] %s generated' % pathname
297
[539]298###################################################################################
[319]299#   Generate arch.bib file if required.
300#   It is used for ALMOS configuration.
[539]301###################################################################################
[319]302
303if ( (almos_path != None) and (arch_path != None) ):
304    pathname = almos_path + '/arch.info'
305    f = open ( pathname, 'w' )
306    f.write( mapping.almos_arch() )
[328]307    print '[genmap] %s generated for almos' % pathname
[319]308
[539]309###################################################################################
[319]310#   Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
311#   They are used for GietVM compilation and configuration.
[539]312###################################################################################
[319]313
314if ( (giet_path != None) and (arch_path != None) ):
315
316    pathname = giet_path + '/map.bin'
317    f = open ( pathname, 'w' )
318    f.write( str( mapping.cbin( verbose ) ) )
[328]319    print '[genmap] %s generated for giet_vm' % pathname
[319]320
321    pathname = giet_path + '/hard_config.h'
322    f = open ( pathname, 'w' )
323    f.write( mapping.hard_config() )
[328]324    print '[genmap] %s generated for giet_vm' % pathname
[319]325
326    pathname = giet_path + '/giet_vsegs.ld'
327    f = open ( pathname, 'w' )
328    f.write( mapping.giet_vsegs() )
[328]329    print '[genmap] %s generated for giet_vm' % pathname
[319]330
[539]331###################################################################################
[401]332#   Generate hard_config.h file if required.
[539]333###################################################################################
[401]334
335if ( hard_path != None ):
336
337    pathname = hard_path + '/hard_config.h'
338    f = open ( pathname, 'w' )
339    f.write( mapping.hard_config() )
340    print '[genmap] %s generated for %s' % (pathname, arch_path)
341
Note: See TracBrowser for help on using the repository browser.