source: soft/giet_vm/giet_python/genmap @ 340

Last change on this file since 340 was 338, checked in by alain, 11 years ago

Cosmetic

  • Property svn:executable set to *
File size: 8.6 KB
RevLine 
[319]1#!/usr/bin/env python
2
3#######################################################################################
[328]4#   file   : genmap
[319]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 "arch.bib" file can be used to configure ALMOS.
16# 5) An optional "map.xml" file can be generated for debug.
17#######################################################################################
18# The hardware parameters  are:
19#  - x_size    : number of clusters in a row
20#  - y_size    : number of clusters in a column
21#  - nprocs    : number of processors per cluster
22#######################################################################################
23# The supported platforms are:
24# - tsar_generic_iob
25# - tsar_generic_leti
26#######################################################################################
27# The supported parallel applications are:
28# - sort (one thread per processor)
29# - transpose (one thread per processor)
[328]30# - convol (one thread per processor)
[319]31#######################################################################################
32
33from optparse import OptionParser
34
35from mapping import *
36
37from transpose import *
38from sort import *
[328]39from convol import *
[319]40
41import sys
42
43######################################################################################
44#   define command line arguments   
45######################################################################################
46
47parser = OptionParser()
48
49parser.add_option( '--arch', type = 'string', dest = 'arch_path',
50                   help = 'define pathname to architecture' )
51
52parser.add_option( '--x', type = 'int', dest = 'x_size', 
53                   default = 2,
54                   help = 'define number of clusters in a row' )
55
56parser.add_option( '--y', type = 'int', dest = 'y_size', 
57                   default = 2,
58                   help = 'define number of clusters in a column' )
59
60parser.add_option( '--p', type = 'int', dest = 'nprocs', 
61                   default = 2,
62                   help = 'define number of processors per cluster' )
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( '--almos', type = 'string', dest = 'almos_path', 
72                   help = 'define pathname for the arch.bib file' )
73
74parser.add_option( '--giet', type = 'string', dest = 'giet_path', 
75                   help = 'define pathname for the map.bin & vsegs.ld file ' )
76
77parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
78                   help = 'define pathname for the map.xml file' )
79
80############  supported applications   ###############################################
81
82parser.add_option( '--transpose', action = 'store_true', dest = 'transpose',
83                   default = False,
[328]84                   help = 'map the "transpose" application for the GietVM' )
[319]85
86parser.add_option( '--sort', action = 'store_true', dest = 'sort',     
87                   default = False,
[328]88                   help = 'map the "sort" application for the GietVM' )
[319]89
[338]90parser.add_option( '--convol', action = 'store_true', dest = 'convol',     
[328]91                   default = False,
92                   help = 'map the "convol" application for the GietVM' )
93
[319]94######################################################################################
95#   Get command line arguments
96######################################################################################
97
98(options,args) = parser.parse_args()
99
100x_size        = options.x_size      # number of clusters in a row
101y_size        = options.y_size      # number of clusters in a column
102nprocs        = options.nprocs      # number of processors in a cluster
103
104verbose       = options.verbose     # report on map.bin generation if True
105
106netbsd_path   = options.netbsd_path # path for netbsd.dts file
107almos_path    = options.almos_path  # path for arch.bib file
108giet_path     = options.giet_path   # path for map.bin & vsegs.ld files
109
110arch_path     = options.arch_path   # path to selected architecture
111
112xml_path      = options.xml_path    # path for map.xml file     
113
[328]114map_transpose = options.transpose   # map "transpose" application if True
115map_sort      = options.sort        # map "sort" application if True
[338]116map_convol    = options.convol      # map "convol" application if True
[319]117
118######################################################################################
119#   build empty platform (no applications yet)
120######################################################################################
121
122if   ( arch_path == None  ): 
123    print 'You must select a generic architecture on the command line' 
124    sys.exit(1)
125
126# dynamically append the architecture to PYTHON path (directory pathname)
127sys.path.append( arch_path )
128
129# dynamically import the PYTHON mapping generator module (file name)
[338]130select = __import__( 'arch' )
[319]131
132# build mapping calling the function (function name)
[338]133mapping = select.arch( x_size, y_size, nprocs )
[328]134print '[genmap] platform %s build' % mapping.name
[319]135
136# generate the hard_confi.h file for top.cpp compilation
137pathname = arch_path + '/hard_config.h'
138f = open ( pathname, 'w' )
139f.write( mapping.hard_config() )
[328]140print '[genmap] %s generated' % pathname
[319]141
142######################################################################################
143#   complete mapping with application(s) as required
144######################################################################################
145
146if ( map_transpose ): 
147    transpose( mapping )
[328]148    print '[genmap] application "transpose" loaded'
[319]149
150if ( map_sort ):     
151    sort( mapping )
[328]152    print '[genmap] application "sort" loaded'
[319]153
[328]154if ( map_convol ):     
155    convol( mapping )
156    print '[genmap] application "convol" loaded'
157
[319]158######################################################################################
159#   Generate xml file if required.
160#   It can be used for debug.
161######################################################################################
162
163if ( xml_path != None ):
164    pathname = xml_path + '/map.xml'
165    f = open ( pathname, 'w' )
166    f.write( mapping.xml() )
[328]167    print '[genmap] %s generated for debug' % pathname
[319]168
169######################################################################################
170#   Generate netbsd.dts file if required.
171#   It is used for NetBSD configuration.
172######################################################################################
173
174if ( (netbsd_path != None) and (arch_path != None) ):
175    pathname = netbsd_path + '/netbsd.dts'
176    f = open ( pathname, 'w' )
177    f.write( mapping.netbsd_dts() )
[328]178    print '[genmap] %s generated for netbsd' % pathname
[319]179
180######################################################################################
181#   Generate arch.bib file if required.
182#   It is used for ALMOS configuration.
183######################################################################################
184
185if ( (almos_path != None) and (arch_path != None) ):
186    pathname = almos_path + '/arch.info'
187    f = open ( pathname, 'w' )
188    f.write( mapping.almos_arch() )
[328]189    print '[genmap] %s generated for almos' % pathname
[319]190
191######################################################################################
192#   Generate map.bin, giet_vsegs.ld, and hard_config.h files if required.
193#   They are used for GietVM compilation and configuration.
194######################################################################################
195
196if ( (giet_path != None) and (arch_path != None) ):
197
198    pathname = giet_path + '/map.bin'
199    f = open ( pathname, 'w' )
200    f.write( str( mapping.cbin( verbose ) ) )
[328]201    print '[genmap] %s generated for giet_vm' % pathname
[319]202
203    pathname = giet_path + '/hard_config.h'
204    f = open ( pathname, 'w' )
205    f.write( mapping.hard_config() )
[328]206    print '[genmap] %s generated for giet_vm' % pathname
[319]207
208    pathname = giet_path + '/giet_vsegs.ld'
209    f = open ( pathname, 'w' )
210    f.write( mapping.giet_vsegs() )
[328]211    print '[genmap] %s generated for giet_vm' % pathname
[319]212
Note: See TracBrowser for help on using the repository browser.