source: soft/giet_vm/giet_python/genmap @ 471

Last change on this file since 471 was 462, checked in by alain, 10 years ago

Cosmetic.

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