source: soft/giet_vm/giet_python/genmap @ 509

Last change on this file since 509 was 500, checked in by alain, 10 years ago

Introduce support for application Gameoflife in genmap.

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