source: soft/giet_vm/giet_python/genmap @ 603

Last change on this file since 603 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
Line 
1#!/usr/bin/env python
2
3###################################################################################
4#   file   : genmap
5#   date   : april 2014
6#   author : Alain Greiner
7###################################################################################
8# This generic script maps one or several applications on a specific
9# instance of the multi-processors/multi-clusters TSAR architecture.
10# It generates the files required for hardware and software compilation:
11# 1) The "hard_config.h" file is used to generate the top.cpp file (hardware),
12#    and to compile the tsar_preloader.elf, GietVM boot.elf and kernel.elf files.
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.
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.
18###################################################################################
19# The hardware parameters  are:
20#  - x_size    : number of clusters in a row
21#  - y_size    : number of clusters in a column
22#  - nb_procs  : number of processors per cluster
23#  - nb_ttys   : number of TTY channels
24#  - fbf_size  : frame buffer width & heigth
25###################################################################################
26# The supported platforms are:
27# - tsar_generic_iob
28# - tsar_generic_leti
29# - tsar_geberic_mwmr
30###################################################################################
31# The supported applications are:
32# - classif
33# - convol
34# - coproc
35# - dhrystone
36# - display
37# - gameoflife
38# - ocean
39# - router
40# - sort
41# - shell
42# - transpose
43###################################################################################
44
45from optparse import OptionParser
46from mapping import *
47
48import sys
49
50###################################################################################
51#   define command line arguments   
52###################################################################################
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
67parser.add_option( '--p', type = 'int', dest = 'nb_procs', 
68                   default = 2,
69                   help = 'define number of processors per cluster' )
70
71parser.add_option( '--tty', type = 'int', dest = 'nb_ttys', 
72                   default = 1,
73                   help = 'define number of tty channels' )
74
75parser.add_option( '--fbf', type = 'int', dest = 'fbf_size', 
76                   default = 128,
77                   help = 'define frame buffer width and heigth' )
78
79parser.add_option( '--ioc', type = 'string', dest = 'ioc_type',
80                   default = 'BDV',
81                   help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
82
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
90parser.add_option( '--linux', type = 'string', dest = 'linux_path', 
91                   help = 'define pathname for the linux.dts file' )
92
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
99parser.add_option( '--hard', type = 'string', dest = 'hard_path',
100                   help = 'define pathname for the hard_config.h file ' )
101
102parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
103                   help = 'define pathname for the map.xml file' )
104
105############  supported applications   ############################################
106
107parser.add_option( '--classif', action = 'store_true', dest = 'classif',     
108                   default = False,
109                   help = 'map the "classif" application for the GietVM' )
110
111parser.add_option( '--convol', action = 'store_true', dest = 'convol',     
112                   default = False,
113                   help = 'map the "convol" application for the GietVM' )
114
115parser.add_option( '--coproc', action = 'store_true', dest = 'coproc',     
116                   default = False,
117                   help = 'map the "coproc" application for the GietVM' )
118
119parser.add_option( '--dhrystone', action = 'store_true', dest = 'dhrystone',     
120                   default = False,
121                   help = 'map the "dhrystone" application for the GietVM' )
122
123parser.add_option( '--display', action = 'store_true', dest = 'display',     
124                   default = False,
125                   help = 'map the "display" application for the GietVM' )
126
127parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife',     
128                   default = False,
129                   help = 'map the "gameoflife" application for the GietVM' )
130
131parser.add_option( '--ocean', action = 'store_true', dest = 'ocean',     
132                   default = False,
133                   help = 'map the "ocean" application for the GietVM' )
134
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
151###################################################################################
152#   Get command line arguments
153###################################################################################
154
155(options,args) = parser.parse_args()
156
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
162ioc_type       = options.ioc_type    # ioc controller type
163
164verbose        = options.verbose     # report on map.bin generation if True
165
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
171
172arch_path      = options.arch_path   # path to selected architecture
173
174xml_path       = options.xml_path    # path for map.xml file     
175
176map_classif    = options.classif     # map "classif" application if True
177map_convol     = options.convol      # map "convol" application if True
178map_coproc     = options.coproc      # map "coproc" application if True
179map_dhrystone  = options.dhrystone   # map "dhrystone" application if True
180map_display    = options.display     # map "display" application if True
181map_gameoflife = options.gameoflife  # map "gameoflife" application if True
182map_ocean      = options.ocean       # map "ocean" application if True
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
187
188###################################################################################
189#   build empty platform (no applications yet)
190###################################################################################
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)
200select = __import__( 'arch' )
201
202# build mapping calling the function (function name)
203mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type )
204print '[genmap] platform %s build' % mapping.name
205
206###################################################################################
207#   extend mapping with application(s) as required
208###################################################################################
209
210if ( map_classif ):     
211    appli = __import__( 'classif' )
212    appli.extend( mapping )
213    print '[genmap] application "classif" will be loaded'
214
215if ( map_convol ):   
216    appli = __import__( 'convol' )
217    appli.extend( mapping )
218    print '[genmap] application "convol" will be loaded'
219
220if ( map_coproc ):
221    appli = __import__( 'coproc' )
222    appli.extend( mapping )
223    print '[genmap] application "coproc" will be loaded'
224
225if ( map_dhrystone ):     
226    appli = __import__( 'dhrystone' )
227    appli.extend( mapping )
228    print '[genmap] application "dhrystone" will be loaded'
229
230if ( map_display ):     
231    appli = __import__( 'display' )
232    appli.extend( mapping )
233    print '[genmap] application "display" will be loaded'
234
235if ( map_gameoflife ):
236    appli = __import__( 'gameoflife' )
237    appli.extend( mapping )
238    print '[genmap] application "gameoflife" will be loaded'
239
240if ( map_ocean ):
241    appli = __import__( 'ocean' )
242    appli.extend( mapping )
243    print '[genmap] application "ocean" will be loaded'
244
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
265###################################################################################
266#   Generate xml file if required.
267#   It can be used for debug.
268###################################################################################
269
270if ( xml_path != None ):
271    pathname = xml_path + '/map.xml'
272    f = open ( pathname, 'w' )
273    f.write( mapping.xml() )
274    print '[genmap] %s generated for debug' % pathname
275
276###################################################################################
277#   Generate netbsd.dts file if required.
278#   It is used for NetBSD configuration.
279###################################################################################
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() )
285    print '[genmap] %s generated' % pathname
286
287###################################################################################
288#   Generate linux.dts file if required.
289#   It is used for LINUX configuration.
290###################################################################################
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
298###################################################################################
299#   Generate arch.bib file if required.
300#   It is used for ALMOS configuration.
301###################################################################################
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() )
307    print '[genmap] %s generated for almos' % pathname
308
309###################################################################################
310#   Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
311#   They are used for GietVM compilation and configuration.
312###################################################################################
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 ) ) )
319    print '[genmap] %s generated for giet_vm' % pathname
320
321    pathname = giet_path + '/hard_config.h'
322    f = open ( pathname, 'w' )
323    f.write( mapping.hard_config() )
324    print '[genmap] %s generated for giet_vm' % pathname
325
326    pathname = giet_path + '/giet_vsegs.ld'
327    f = open ( pathname, 'w' )
328    f.write( mapping.giet_vsegs() )
329    print '[genmap] %s generated for giet_vm' % pathname
330
331###################################################################################
332#   Generate hard_config.h file if required.
333###################################################################################
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.