source: soft/giet_vm/giet_python/genmap

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