[425] | 1 | #!/usr/bin/env python |
---|
[319] | 2 | |
---|
[539] | 3 | ################################################################################### |
---|
[328] | 4 | # file : genmap |
---|
[319] | 5 | # date : april 2014 |
---|
| 6 | # author : Alain Greiner |
---|
[539] | 7 | ################################################################################### |
---|
[520] | 8 | # This generic script maps one or several applications on a specific |
---|
[319] | 9 | # instance of the multi-processors/multi-clusters TSAR architecture. |
---|
| 10 | # It generates the files required for hardware and software compilation: |
---|
[520] | 11 | # 1) The "hard_config.h" file is used to generate the top.cpp file (hardware), |
---|
[539] | 12 | # and to compile the tsar_preloader.elf, GietVM boot.elf and kernel.elf files. |
---|
[319] | 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. |
---|
[411] | 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. |
---|
[539] | 18 | ################################################################################### |
---|
[319] | 19 | # The hardware parameters are: |
---|
| 20 | # - x_size : number of clusters in a row |
---|
| 21 | # - y_size : number of clusters in a column |
---|
[453] | 22 | # - nb_procs : number of processors per cluster |
---|
| 23 | # - nb_ttys : number of TTY channels |
---|
| 24 | # - fbf_size : frame buffer width & heigth |
---|
[539] | 25 | ################################################################################### |
---|
[319] | 26 | # The supported platforms are: |
---|
| 27 | # - tsar_generic_iob |
---|
| 28 | # - tsar_generic_leti |
---|
[520] | 29 | # - tsar_geberic_mwmr |
---|
[539] | 30 | ################################################################################### |
---|
[462] | 31 | # The supported applications are: |
---|
[591] | 32 | # - classif |
---|
[462] | 33 | # - convol |
---|
[591] | 34 | # - coproc |
---|
| 35 | # - dhrystone |
---|
[462] | 36 | # - display |
---|
[500] | 37 | # - gameoflife |
---|
[729] | 38 | # - mjpeg |
---|
[591] | 39 | # - ocean |
---|
[673] | 40 | # - raycast |
---|
[591] | 41 | # - router |
---|
| 42 | # - sort |
---|
| 43 | # - shell |
---|
| 44 | # - transpose |
---|
[753] | 45 | # - coremark |
---|
[539] | 46 | ################################################################################### |
---|
[319] | 47 | |
---|
| 48 | from optparse import OptionParser |
---|
| 49 | from mapping import * |
---|
| 50 | |
---|
| 51 | import sys |
---|
| 52 | |
---|
[539] | 53 | ################################################################################### |
---|
[319] | 54 | # define command line arguments |
---|
[539] | 55 | ################################################################################### |
---|
[319] | 56 | |
---|
| 57 | parser = OptionParser() |
---|
| 58 | |
---|
| 59 | parser.add_option( '--arch', type = 'string', dest = 'arch_path', |
---|
| 60 | help = 'define pathname to architecture' ) |
---|
| 61 | |
---|
| 62 | parser.add_option( '--x', type = 'int', dest = 'x_size', |
---|
| 63 | default = 2, |
---|
| 64 | help = 'define number of clusters in a row' ) |
---|
| 65 | |
---|
| 66 | parser.add_option( '--y', type = 'int', dest = 'y_size', |
---|
| 67 | default = 2, |
---|
| 68 | help = 'define number of clusters in a column' ) |
---|
| 69 | |
---|
[453] | 70 | parser.add_option( '--p', type = 'int', dest = 'nb_procs', |
---|
[319] | 71 | default = 2, |
---|
| 72 | help = 'define number of processors per cluster' ) |
---|
| 73 | |
---|
[453] | 74 | parser.add_option( '--tty', type = 'int', dest = 'nb_ttys', |
---|
| 75 | default = 1, |
---|
| 76 | help = 'define number of tty channels' ) |
---|
| 77 | |
---|
[411] | 78 | parser.add_option( '--fbf', type = 'int', dest = 'fbf_size', |
---|
| 79 | default = 128, |
---|
| 80 | help = 'define frame buffer width and heigth' ) |
---|
| 81 | |
---|
[546] | 82 | parser.add_option( '--ioc', type = 'string', dest = 'ioc_type', |
---|
| 83 | default = 'BDV', |
---|
[565] | 84 | help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' ) |
---|
[546] | 85 | |
---|
[737] | 86 | parser.add_option( '--mwr', type = 'string', dest = 'mwr_type', |
---|
| 87 | default = 'CPY', |
---|
| 88 | help = 'define type of COPROC: CPY / DCT / GCD' ) |
---|
| 89 | |
---|
[319] | 90 | parser.add_option( '--v', action = 'store_true', dest = 'verbose', |
---|
| 91 | default = False, |
---|
| 92 | help = 'display detailed report on map.bin file generation' ) |
---|
| 93 | |
---|
| 94 | parser.add_option( '--netbsd', type = 'string', dest = 'netbsd_path', |
---|
| 95 | help = 'define pathname for the netbsd.dts file' ) |
---|
| 96 | |
---|
[411] | 97 | parser.add_option( '--linux', type = 'string', dest = 'linux_path', |
---|
| 98 | help = 'define pathname for the linux.dts file' ) |
---|
| 99 | |
---|
[319] | 100 | parser.add_option( '--almos', type = 'string', dest = 'almos_path', |
---|
| 101 | help = 'define pathname for the arch.bib file' ) |
---|
| 102 | |
---|
| 103 | parser.add_option( '--giet', type = 'string', dest = 'giet_path', |
---|
| 104 | help = 'define pathname for the map.bin & vsegs.ld file ' ) |
---|
| 105 | |
---|
[401] | 106 | parser.add_option( '--hard', type = 'string', dest = 'hard_path', |
---|
| 107 | help = 'define pathname for the hard_config.h file ' ) |
---|
| 108 | |
---|
[319] | 109 | parser.add_option( '--xml', type = 'string', dest = 'xml_path', |
---|
| 110 | help = 'define pathname for the map.xml file' ) |
---|
| 111 | |
---|
[539] | 112 | ############ supported applications ############################################ |
---|
[319] | 113 | |
---|
[591] | 114 | parser.add_option( '--classif', action = 'store_true', dest = 'classif', |
---|
[319] | 115 | default = False, |
---|
[591] | 116 | help = 'map the "classif" application for the GietVM' ) |
---|
[319] | 117 | |
---|
[338] | 118 | parser.add_option( '--convol', action = 'store_true', dest = 'convol', |
---|
[328] | 119 | default = False, |
---|
| 120 | help = 'map the "convol" application for the GietVM' ) |
---|
| 121 | |
---|
[591] | 122 | parser.add_option( '--coproc', action = 'store_true', dest = 'coproc', |
---|
[421] | 123 | default = False, |
---|
[591] | 124 | help = 'map the "coproc" application for the GietVM' ) |
---|
[421] | 125 | |
---|
[591] | 126 | parser.add_option( '--dhrystone', action = 'store_true', dest = 'dhrystone', |
---|
| 127 | default = False, |
---|
| 128 | help = 'map the "dhrystone" application for the GietVM' ) |
---|
| 129 | |
---|
[441] | 130 | parser.add_option( '--display', action = 'store_true', dest = 'display', |
---|
| 131 | default = False, |
---|
| 132 | help = 'map the "display" application for the GietVM' ) |
---|
| 133 | |
---|
[500] | 134 | parser.add_option( '--gameoflife', action = 'store_true', dest = 'gameoflife', |
---|
| 135 | default = False, |
---|
| 136 | help = 'map the "gameoflife" application for the GietVM' ) |
---|
| 137 | |
---|
[729] | 138 | parser.add_option( '--mjpeg', action = 'store_true', dest = 'mjpeg', |
---|
| 139 | default = False, |
---|
| 140 | help = 'map the "mjpeg" application for the GietVM' ) |
---|
| 141 | |
---|
[580] | 142 | parser.add_option( '--ocean', action = 'store_true', dest = 'ocean', |
---|
| 143 | default = False, |
---|
| 144 | help = 'map the "ocean" application for the GietVM' ) |
---|
| 145 | |
---|
[673] | 146 | parser.add_option( '--raycast', action = 'store_true', dest = 'raycast', |
---|
| 147 | default = False, |
---|
| 148 | help = 'map the "raycast" application for the GietVM' ) |
---|
| 149 | |
---|
[591] | 150 | parser.add_option( '--router', action = 'store_true', dest = 'router', |
---|
| 151 | default = False, |
---|
| 152 | help = 'map the "router" application for the GietVM' ) |
---|
| 153 | |
---|
| 154 | parser.add_option( '--shell', action = 'store_true', dest = 'shell', |
---|
| 155 | default = False, |
---|
| 156 | help = 'map the "shell" application for the GietVM' ) |
---|
| 157 | |
---|
| 158 | parser.add_option( '--sort', action = 'store_true', dest = 'sort', |
---|
| 159 | default = False, |
---|
| 160 | help = 'map the "sort" application for the GietVM' ) |
---|
| 161 | |
---|
| 162 | parser.add_option( '--transpose', action = 'store_true', dest = 'transpose', |
---|
| 163 | default = False, |
---|
| 164 | help = 'map the "transpose" application for the GietVM' ) |
---|
| 165 | |
---|
[753] | 166 | parser.add_option( '--coremark', action = 'store_true', dest = 'coremark', |
---|
| 167 | default = False, |
---|
| 168 | help = 'map the "coremark" application for the GietVM' ) |
---|
| 169 | |
---|
[539] | 170 | ################################################################################### |
---|
[319] | 171 | # Get command line arguments |
---|
[539] | 172 | ################################################################################### |
---|
[319] | 173 | |
---|
| 174 | (options,args) = parser.parse_args() |
---|
| 175 | |
---|
[500] | 176 | x_size = options.x_size # number of clusters in a row |
---|
| 177 | y_size = options.y_size # number of clusters in a column |
---|
| 178 | nb_procs = options.nb_procs # number of processors in a cluster |
---|
| 179 | nb_ttys = options.nb_ttys # number of TTY channels |
---|
| 180 | fbf_size = options.fbf_size # frame buffer width & heigth |
---|
[546] | 181 | ioc_type = options.ioc_type # ioc controller type |
---|
[737] | 182 | mwr_type = options.mwr_type # hardware coprocessor type |
---|
[319] | 183 | |
---|
[500] | 184 | verbose = options.verbose # report on map.bin generation if True |
---|
[319] | 185 | |
---|
[500] | 186 | netbsd_path = options.netbsd_path # path for netbsd.dts file |
---|
| 187 | linux_path = options.linux_path # path for linux.dts file |
---|
| 188 | almos_path = options.almos_path # path for arch.bib file |
---|
| 189 | giet_path = options.giet_path # path for map.bin & vsegs.ld files |
---|
| 190 | hard_path = options.hard_path # path for the hard_config.h file |
---|
[319] | 191 | |
---|
[500] | 192 | arch_path = options.arch_path # path to selected architecture |
---|
[319] | 193 | |
---|
[500] | 194 | xml_path = options.xml_path # path for map.xml file |
---|
[319] | 195 | |
---|
[591] | 196 | map_classif = options.classif # map "classif" application if True |
---|
[500] | 197 | map_convol = options.convol # map "convol" application if True |
---|
[591] | 198 | map_coproc = options.coproc # map "coproc" application if True |
---|
| 199 | map_dhrystone = options.dhrystone # map "dhrystone" application if True |
---|
[500] | 200 | map_display = options.display # map "display" application if True |
---|
| 201 | map_gameoflife = options.gameoflife # map "gameoflife" application if True |
---|
[729] | 202 | map_mjpeg = options.mjpeg # map "mjpeg" application if True |
---|
[580] | 203 | map_ocean = options.ocean # map "ocean" application if True |
---|
[673] | 204 | map_raycast = options.raycast # map "raycast" application if True |
---|
[591] | 205 | map_router = options.router # map "router" application if True |
---|
| 206 | map_shell = options.shell # map "shell" application if True |
---|
| 207 | map_sort = options.sort # map "sort" application if True |
---|
| 208 | map_transpose = options.transpose # map "transpose" application if True |
---|
[753] | 209 | map_coremark = options.coremark # map "coremark" application if True |
---|
[319] | 210 | |
---|
[539] | 211 | ################################################################################### |
---|
[319] | 212 | # build empty platform (no applications yet) |
---|
[539] | 213 | ################################################################################### |
---|
[319] | 214 | |
---|
| 215 | if ( 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) |
---|
| 220 | sys.path.append( arch_path ) |
---|
| 221 | |
---|
| 222 | # dynamically import the PYTHON mapping generator module (file name) |
---|
[338] | 223 | select = __import__( 'arch' ) |
---|
[319] | 224 | |
---|
| 225 | # build mapping calling the function (function name) |
---|
[737] | 226 | mapping = select.arch( x_size, y_size, nb_procs, nb_ttys, fbf_size, ioc_type, mwr_type ) |
---|
[328] | 227 | print '[genmap] platform %s build' % mapping.name |
---|
[319] | 228 | |
---|
[539] | 229 | ################################################################################### |
---|
[591] | 230 | # extend mapping with application(s) as required |
---|
[539] | 231 | ################################################################################### |
---|
[319] | 232 | |
---|
[591] | 233 | if ( map_classif ): |
---|
| 234 | appli = __import__( 'classif' ) |
---|
| 235 | appli.extend( mapping ) |
---|
| 236 | print '[genmap] application "classif" will be loaded' |
---|
[319] | 237 | |
---|
[591] | 238 | if ( map_convol ): |
---|
| 239 | appli = __import__( 'convol' ) |
---|
| 240 | appli.extend( mapping ) |
---|
[441] | 241 | print '[genmap] application "convol" will be loaded' |
---|
[328] | 242 | |
---|
[591] | 243 | if ( map_coproc ): |
---|
| 244 | appli = __import__( 'coproc' ) |
---|
| 245 | appli.extend( mapping ) |
---|
| 246 | print '[genmap] application "coproc" will be loaded' |
---|
[432] | 247 | |
---|
[591] | 248 | if ( map_dhrystone ): |
---|
| 249 | appli = __import__( 'dhrystone' ) |
---|
| 250 | appli.extend( mapping ) |
---|
| 251 | print '[genmap] application "dhrystone" will be loaded' |
---|
| 252 | |
---|
[441] | 253 | if ( map_display ): |
---|
[591] | 254 | appli = __import__( 'display' ) |
---|
| 255 | appli.extend( mapping ) |
---|
[441] | 256 | print '[genmap] application "display" will be loaded' |
---|
| 257 | |
---|
[500] | 258 | if ( map_gameoflife ): |
---|
[591] | 259 | appli = __import__( 'gameoflife' ) |
---|
| 260 | appli.extend( mapping ) |
---|
[500] | 261 | print '[genmap] application "gameoflife" will be loaded' |
---|
| 262 | |
---|
[729] | 263 | if ( map_mjpeg ): |
---|
| 264 | appli = __import__( 'mjpeg' ) |
---|
| 265 | appli.extend( mapping ) |
---|
| 266 | print '[genmap] application "mjpeg" will be loaded' |
---|
| 267 | |
---|
[580] | 268 | if ( map_ocean ): |
---|
[591] | 269 | appli = __import__( 'ocean' ) |
---|
| 270 | appli.extend( mapping ) |
---|
[580] | 271 | print '[genmap] application "ocean" will be loaded' |
---|
| 272 | |
---|
[673] | 273 | if ( map_raycast ): |
---|
| 274 | appli = __import__( 'raycast' ) |
---|
| 275 | appli.extend( mapping ) |
---|
| 276 | print '[genmap] application "raycast" will be loaded' |
---|
| 277 | |
---|
[591] | 278 | if ( map_router ): |
---|
| 279 | appli = __import__( 'router' ) |
---|
| 280 | appli.extend( mapping ) |
---|
| 281 | print '[genmap] application "router" will be loaded' |
---|
| 282 | |
---|
| 283 | if ( map_shell ): |
---|
| 284 | appli = __import__( 'shell' ) |
---|
| 285 | appli.extend( mapping ) |
---|
| 286 | print '[geneap] application "shell" will be loaded' |
---|
| 287 | |
---|
| 288 | if ( map_sort ): |
---|
| 289 | appli = __import__( 'sort' ) |
---|
| 290 | appli.extend( mapping ) |
---|
| 291 | print '[genmap] application "sort" will be loaded' |
---|
| 292 | |
---|
| 293 | if ( map_transpose ): |
---|
| 294 | appli = __import__( 'transpose' ) |
---|
| 295 | appli.extend( mapping ) |
---|
| 296 | print '[genmap] application "transpose" will be loaded' |
---|
| 297 | |
---|
[753] | 298 | if ( map_coremark ): |
---|
| 299 | appli = __import__( 'coremark' ) |
---|
| 300 | appli.extend( mapping ) |
---|
| 301 | print '[genmap] application "coremark" will be loaded' |
---|
| 302 | |
---|
[539] | 303 | ################################################################################### |
---|
[319] | 304 | # Generate xml file if required. |
---|
| 305 | # It can be used for debug. |
---|
[539] | 306 | ################################################################################### |
---|
[319] | 307 | |
---|
| 308 | if ( xml_path != None ): |
---|
| 309 | pathname = xml_path + '/map.xml' |
---|
| 310 | f = open ( pathname, 'w' ) |
---|
| 311 | f.write( mapping.xml() ) |
---|
[328] | 312 | print '[genmap] %s generated for debug' % pathname |
---|
[319] | 313 | |
---|
[539] | 314 | ################################################################################### |
---|
[319] | 315 | # Generate netbsd.dts file if required. |
---|
| 316 | # It is used for NetBSD configuration. |
---|
[539] | 317 | ################################################################################### |
---|
[319] | 318 | |
---|
| 319 | if ( (netbsd_path != None) and (arch_path != None) ): |
---|
| 320 | pathname = netbsd_path + '/netbsd.dts' |
---|
| 321 | f = open ( pathname, 'w' ) |
---|
| 322 | f.write( mapping.netbsd_dts() ) |
---|
[411] | 323 | print '[genmap] %s generated' % pathname |
---|
[319] | 324 | |
---|
[539] | 325 | ################################################################################### |
---|
[411] | 326 | # Generate linux.dts file if required. |
---|
| 327 | # It is used for LINUX configuration. |
---|
[539] | 328 | ################################################################################### |
---|
[411] | 329 | |
---|
| 330 | if ( (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 | |
---|
[539] | 336 | ################################################################################### |
---|
[319] | 337 | # Generate arch.bib file if required. |
---|
| 338 | # It is used for ALMOS configuration. |
---|
[539] | 339 | ################################################################################### |
---|
[319] | 340 | |
---|
| 341 | if ( (almos_path != None) and (arch_path != None) ): |
---|
| 342 | pathname = almos_path + '/arch.info' |
---|
| 343 | f = open ( pathname, 'w' ) |
---|
| 344 | f.write( mapping.almos_arch() ) |
---|
[328] | 345 | print '[genmap] %s generated for almos' % pathname |
---|
[319] | 346 | |
---|
[539] | 347 | ################################################################################### |
---|
[319] | 348 | # Generate map.bin, giet_vsegs.ld, and hard_config.h files if required. |
---|
| 349 | # They are used for GietVM compilation and configuration. |
---|
[539] | 350 | ################################################################################### |
---|
[319] | 351 | |
---|
| 352 | if ( (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 ) ) ) |
---|
[328] | 357 | print '[genmap] %s generated for giet_vm' % pathname |
---|
[319] | 358 | |
---|
| 359 | pathname = giet_path + '/hard_config.h' |
---|
| 360 | f = open ( pathname, 'w' ) |
---|
| 361 | f.write( mapping.hard_config() ) |
---|
[328] | 362 | print '[genmap] %s generated for giet_vm' % pathname |
---|
[319] | 363 | |
---|
| 364 | pathname = giet_path + '/giet_vsegs.ld' |
---|
| 365 | f = open ( pathname, 'w' ) |
---|
| 366 | f.write( mapping.giet_vsegs() ) |
---|
[328] | 367 | print '[genmap] %s generated for giet_vm' % pathname |
---|
[319] | 368 | |
---|
[539] | 369 | ################################################################################### |
---|
[401] | 370 | # Generate hard_config.h file if required. |
---|
[539] | 371 | ################################################################################### |
---|
[401] | 372 | |
---|
| 373 | if ( 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 | |
---|