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