source: soft/giet_vm/giet_python/genmap @ 437

Last change on this file since 437 was 432, checked in by alain, 10 years ago

1) Introduce the "applications" directory.
2) Introduce the fixed format (X_WIDTH / Y_WIDTH / P_WIDTH) for processor index in all applications.

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