source: soft/giet_vm/giet_python/genmap@ 753

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

Introducing the coremark benchmark

  • Property svn:executable set to *
File size: 15.2 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# - sort
43# - shell
44# - transpose
45# - coremark
46###################################################################################
47
48from optparse import OptionParser
49from mapping import *
50
51import sys
52
53###################################################################################
54# define command line arguments
55###################################################################################
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
70parser.add_option( '--p', type = 'int', dest = 'nb_procs',
71 default = 2,
72 help = 'define number of processors per cluster' )
73
74parser.add_option( '--tty', type = 'int', dest = 'nb_ttys',
75 default = 1,
76 help = 'define number of tty channels' )
77
78parser.add_option( '--fbf', type = 'int', dest = 'fbf_size',
79 default = 128,
80 help = 'define frame buffer width and heigth' )
81
82parser.add_option( '--ioc', type = 'string', dest = 'ioc_type',
83 default = 'BDV',
84 help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
85
86parser.add_option( '--mwr', type = 'string', dest = 'mwr_type',
87 default = 'CPY',
88 help = 'define type of COPROC: CPY / DCT / GCD' )
89
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
97parser.add_option( '--linux', type = 'string', dest = 'linux_path',
98 help = 'define pathname for the linux.dts file' )
99
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
106parser.add_option( '--hard', type = 'string', dest = 'hard_path',
107 help = 'define pathname for the hard_config.h file ' )
108
109parser.add_option( '--xml', type = 'string', dest = 'xml_path',
110 help = 'define pathname for the map.xml file' )
111
112############ supported applications ############################################
113
114parser.add_option( '--classif', action = 'store_true', dest = 'classif',
115 default = False,
116 help = 'map the "classif" application for the GietVM' )
117
118parser.add_option( '--convol', action = 'store_true', dest = 'convol',
119 default = False,
120 help = 'map the "convol" application for the GietVM' )
121
122parser.add_option( '--coproc', action = 'store_true', dest = 'coproc',
123 default = False,
124 help = 'map the "coproc" application for the GietVM' )
125
126parser.add_option( '--dhrystone', action = 'store_true', dest = 'dhrystone',
127 default = False,
128 help = 'map the "dhrystone" application for the GietVM' )
129
130parser.add_option( '--display', action = 'store_true', dest = 'display',
131 default = False,
132 help = 'map the "display" application for the GietVM' )
133
134parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife',
135 default = False,
136 help = 'map the "gameoflife" application for the GietVM' )
137
138parser.add_option( '--mjpeg', action = 'store_true', dest = 'mjpeg',
139 default = False,
140 help = 'map the "mjpeg" application for the GietVM' )
141
142parser.add_option( '--ocean', action = 'store_true', dest = 'ocean',
143 default = False,
144 help = 'map the "ocean" application for the GietVM' )
145
146parser.add_option( '--raycast', action = 'store_true', dest = 'raycast',
147 default = False,
148 help = 'map the "raycast" application for the GietVM' )
149
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
166parser.add_option( '--coremark', action = 'store_true', dest = 'coremark',
167 default = False,
168 help = 'map the "coremark" application for the GietVM' )
169
170###################################################################################
171# Get command line arguments
172###################################################################################
173
174(options,args) = parser.parse_args()
175
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
181ioc_type = options.ioc_type # ioc controller type
182mwr_type = options.mwr_type # hardware coprocessor type
183
184verbose = options.verbose # report on map.bin generation if True
185
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
191
192arch_path = options.arch_path # path to selected architecture
193
194xml_path = options.xml_path # path for map.xml file
195
196map_classif = options.classif # map "classif" application if True
197map_convol = options.convol # map "convol" application if True
198map_coproc = options.coproc # map "coproc" application if True
199map_dhrystone = options.dhrystone # map "dhrystone" application if True
200map_display = options.display # map "display" application if True
201map_gameoflife = options.gameoflife # map "gameoflife" application if True
202map_mjpeg = options.mjpeg # map "mjpeg" application if True
203map_ocean = options.ocean # map "ocean" application if True
204map_raycast = options.raycast # map "raycast" application if True
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
209map_coremark = options.coremark # map "coremark" application if True
210
211###################################################################################
212# build empty platform (no applications yet)
213###################################################################################
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)
223select = __import__( 'arch' )
224
225# build mapping calling the function (function name)
226mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type, mwr_type )
227print '[genmap] platform %s build' % mapping.name
228
229###################################################################################
230# extend mapping with application(s) as required
231###################################################################################
232
233if ( map_classif ):
234 appli = __import__( 'classif' )
235 appli.extend( mapping )
236 print '[genmap] application "classif" will be loaded'
237
238if ( map_convol ):
239 appli = __import__( 'convol' )
240 appli.extend( mapping )
241 print '[genmap] application "convol" will be loaded'
242
243if ( map_coproc ):
244 appli = __import__( 'coproc' )
245 appli.extend( mapping )
246 print '[genmap] application "coproc" will be loaded'
247
248if ( map_dhrystone ):
249 appli = __import__( 'dhrystone' )
250 appli.extend( mapping )
251 print '[genmap] application "dhrystone" will be loaded'
252
253if ( map_display ):
254 appli = __import__( 'display' )
255 appli.extend( mapping )
256 print '[genmap] application "display" will be loaded'
257
258if ( map_gameoflife ):
259 appli = __import__( 'gameoflife' )
260 appli.extend( mapping )
261 print '[genmap] application "gameoflife" will be loaded'
262
263if ( map_mjpeg ):
264 appli = __import__( 'mjpeg' )
265 appli.extend( mapping )
266 print '[genmap] application "mjpeg" will be loaded'
267
268if ( map_ocean ):
269 appli = __import__( 'ocean' )
270 appli.extend( mapping )
271 print '[genmap] application "ocean" will be loaded'
272
273if ( map_raycast ):
274 appli = __import__( 'raycast' )
275 appli.extend( mapping )
276 print '[genmap] application "raycast" will be loaded'
277
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
298if ( map_coremark ):
299 appli = __import__( 'coremark' )
300 appli.extend( mapping )
301 print '[genmap] application "coremark" will be loaded'
302
303###################################################################################
304# Generate xml file if required.
305# It can be used for debug.
306###################################################################################
307
308if ( xml_path != None ):
309 pathname = xml_path + '/map.xml'
310 f = open ( pathname, 'w' )
311 f.write( mapping.xml() )
312 print '[genmap] %s generated for debug' % pathname
313
314###################################################################################
315# Generate netbsd.dts file if required.
316# It is used for NetBSD configuration.
317###################################################################################
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() )
323 print '[genmap] %s generated' % pathname
324
325###################################################################################
326# Generate linux.dts file if required.
327# It is used for LINUX configuration.
328###################################################################################
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
336###################################################################################
337# Generate arch.bib file if required.
338# It is used for ALMOS configuration.
339###################################################################################
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() )
345 print '[genmap] %s generated for almos' % pathname
346
347###################################################################################
348# Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
349# They are used for GietVM compilation and configuration.
350###################################################################################
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 ) ) )
357 print '[genmap] %s generated for giet_vm' % pathname
358
359 pathname = giet_path + '/hard_config.h'
360 f = open ( pathname, 'w' )
361 f.write( mapping.hard_config() )
362 print '[genmap] %s generated for giet_vm' % pathname
363
364 pathname = giet_path + '/giet_vsegs.ld'
365 f = open ( pathname, 'w' )
366 f.write( mapping.giet_vsegs() )
367 print '[genmap] %s generated for giet_vm' % pathname
368
369###################################################################################
370# Generate hard_config.h file if required.
371###################################################################################
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.