Changeset 709 for soft/giet_vm/giet_python
- Timestamp:
- Oct 1, 2015, 4:20:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_python/mapping.py
r642 r709 10 10 # This file contains the classes required to define a mapping for the GIET_VM. 11 11 # - A 'Mapping' contains a set of 'Cluster' (hardware architecture) 12 # a set of 'Vseg' (kernel glo galsvirtual segments)12 # a set of 'Vseg' (kernel global virtual segments) 13 13 # a set of 'Vspace' (one or several user applications) 14 14 # - A 'Cluster' contains a set of 'Pseg' (physical segments in cluster) … … 16 16 # a set of 'Periph' (peripherals in cluster) 17 17 # - A 'Vspace' contains a set of 'Vseg' (user virtual segments) 18 # a set of 'T ask' (user parallel tasks)18 # a set of 'Thread' (POSIX thread) 19 19 # - A 'Periph' contains a set of 'Irq' (only for XCU and PIC types ) 20 20 ################################################################################### … … 22 22 # The objects used to describe a mapping are distributed in the PYTHON structure: 23 23 # For example the psegs set is split in several subsets (one subset per cluster), 24 # or the t asks set is split in several subsets (one subset per vspace), etc...24 # or the threads set is split in several subsets (one subset per vspace), etc... 25 25 # In the C binary data structure used by the giet_vm, all objects of same type 26 26 # are stored in a linear array (one single array for all psegs for example). … … 192 192 self.total_psegs = 0 193 193 self.total_vsegs = 0 194 self.total_t asks= 0194 self.total_threads = 0 195 195 self.total_procs = 0 196 196 self.total_irqs = 0 … … 406 406 return vseg 407 407 408 ################################ add a task in a vspace 409 def addTask( self, 410 vspace, # vspace containing task 411 name, # task name 412 trdid, # task index in vspace 413 x, # destination x coordinate 414 y, # destination y coordinate 415 lpid, # destination processor local index 416 stackname, # name of vseg containing stack 417 heapname, # name of vseg containing heap 418 startid ): # index in start_vector 419 420 assert (x < self.x_size) and (y < self.y_size) 421 assert lpid < self.nprocs 422 423 # add one task into mapping 424 task = Task( name, trdid, x, y, lpid, stackname, heapname, startid ) 425 vspace.tasks.append( task ) 426 task.index = self.total_tasks 427 self.total_tasks += 1 428 429 return task 408 ################################ add a thread in a vspace 409 def addThread( self, 410 vspace, # vspace containing thread 411 name, # thread name 412 is_main, # Boolean (one thread per vspace) 413 x, # destination x coordinate 414 y, # destination y coordinate 415 p, # destination processor local index 416 stackname, # name of vseg containing stack 417 heapname, # name of vseg containing heap 418 startid ): # index in start_vector 419 420 assert x < self.x_size 421 assert y < self.y_size 422 assert p < self.nprocs 423 424 # add one thread into mapping 425 thread = Thread( name, is_main, x, y, p, stackname, heapname, startid ) 426 vspace.threads.append( thread ) 427 thread.index = self.total_threads 428 self.total_threads += 1 429 430 return thread 430 431 431 432 ################################# … … 497 498 498 499 # header 499 byte_stream += self.int2bytes(4, self.signature)500 byte_stream += self.int2bytes(4, self.x_size)501 byte_stream += self.int2bytes(4, self.y_size)502 byte_stream += self.int2bytes(4, self.x_width)503 byte_stream += self.int2bytes(4, self.y_width)504 byte_stream += self.int2bytes(4, self.x_io)505 byte_stream += self.int2bytes(4, self.y_io)506 byte_stream += self.int2bytes(4, self.irq_per_proc)507 byte_stream += self.int2bytes(4, self.use_ramdisk)508 byte_stream += self.int2bytes(4, self.total_globals)509 byte_stream += self.int2bytes(4, self.total_vspaces)510 byte_stream += self.int2bytes(4, self.total_psegs)511 byte_stream += self.int2bytes(4, self.total_vsegs)512 byte_stream += self.int2bytes(4, self.total_tasks)513 byte_stream += self.int2bytes(4, self.total_procs)514 byte_stream += self.int2bytes(4, self.total_irqs)515 byte_stream += self.int2bytes(4, self.total_periphs)516 byte_stream += self.str2bytes( 64, self.name)500 byte_stream += self.int2bytes(4, self.signature) 501 byte_stream += self.int2bytes(4, self.x_size) 502 byte_stream += self.int2bytes(4, self.y_size) 503 byte_stream += self.int2bytes(4, self.x_width) 504 byte_stream += self.int2bytes(4, self.y_width) 505 byte_stream += self.int2bytes(4, self.x_io) 506 byte_stream += self.int2bytes(4, self.y_io) 507 byte_stream += self.int2bytes(4, self.irq_per_proc) 508 byte_stream += self.int2bytes(4, self.use_ramdisk) 509 byte_stream += self.int2bytes(4, self.total_globals) 510 byte_stream += self.int2bytes(4, self.total_vspaces) 511 byte_stream += self.int2bytes(4, self.total_psegs) 512 byte_stream += self.int2bytes(4, self.total_vsegs) 513 byte_stream += self.int2bytes(4, self.total_threads) 514 byte_stream += self.int2bytes(4, self.total_procs) 515 byte_stream += self.int2bytes(4, self.total_irqs) 516 byte_stream += self.int2bytes(4, self.total_periphs) 517 byte_stream += self.str2bytes(256, self.name) 517 518 518 519 if ( verbose ): … … 531 532 print 'total_psegs = %d' % self.total_psegs 532 533 print 'total_vsegs = %d' % self.total_vsegs 533 print 'total_t asks = %d' % self.total_tasks534 print 'total_threads = %d' % self.total_threads 534 535 print 'total_procs = %d' % self.total_procs 535 536 print 'total_irqs = %d' % self.total_irqs … … 574 575 if ( verbose ): print '\n' 575 576 576 # t asks array577 # threads array 577 578 index = 0 578 579 for vspace in self.vspaces: 579 for t ask in vspace.tasks:580 byte_stream += t ask.cbin( self, verbose, index, vspace )580 for thread in vspace.threads: 581 byte_stream += thread.cbin( self, verbose, index, vspace ) 581 582 index += 1 582 583 … … 985 986 if ( (boot_stack_found == False) or (boot_stack_identity == False) ): 986 987 print '[genmap error] in giet_vsegs()' 987 print ' seg_boot_sta sk missing or not identity mapping'988 print ' seg_boot_stack missing or not identity mapping' 988 989 sys.exit() 989 990 … … 1926 1927 self.active = active # active at boot if true 1927 1928 self.vsegs = [] 1928 self.t asks= []1929 self.threads = [] 1929 1930 1930 1931 return … … 1936 1937 %(self.name , self.startname , self.active) 1937 1938 for vseg in self.vsegs: s += vseg.xml() 1938 for t ask in self.tasks: s += task.xml()1939 for thread in self.threads: s += thread.xml() 1939 1940 s += ' </vspace>\n' 1940 1941 … … 1965 1966 sys.exit(1) 1966 1967 1967 # compute first vseg and first t askglobal index1968 # compute first vseg and first thread global index 1968 1969 first_vseg_id = self.vsegs[0].index 1969 first_t ask_id = self.tasks[0].index1970 1971 # compute number of t asks and number of vsegs1970 first_thread_id = self.threads[0].index 1971 1972 # compute number of threads and number of vsegs 1972 1973 nb_vsegs = len( self.vsegs ) 1973 nb_t asks = len( self.tasks )1974 nb_threads = len( self.threads ) 1974 1975 1975 1976 byte_stream = bytearray() … … 1977 1978 byte_stream += mapping.int2bytes(4, vseg_start_id) # vseg start_vector 1978 1979 byte_stream += mapping.int2bytes(4, nb_vsegs) # number of vsegs 1979 byte_stream += mapping.int2bytes(4, nb_t asks) # number of tasks1980 byte_stream += mapping.int2bytes(4, nb_threads) # number of threads 1980 1981 byte_stream += mapping.int2bytes(4, first_vseg_id) # global index 1981 byte_stream += mapping.int2bytes(4, first_t ask_id) # global index1982 byte_stream += mapping.int2bytes(4, first_thread_id) # global index 1982 1983 byte_stream += mapping.int2bytes(4, self.active) # always active if non zero 1983 1984 … … 1985 1986 print 'start_id = %d' % vseg_start_id 1986 1987 print 'nb_vsegs = %d' % nb_vsegs 1987 print 'nb_t asks = %d' % nb_tasks1988 print 'nb_threads = %d' % nb_threads 1988 1989 print 'vseg_id = %d' % first_vseg_id 1989 print 't ask_id = %d' % first_task_id1990 print 'thread_id = %d' % first_thread_id 1990 1991 print 'active = %d' % self.active 1991 1992 … … 1993 1994 1994 1995 ################################################################################## 1995 class T ask( object ):1996 class Thread( object ): 1996 1997 ################################################################################## 1997 1998 def __init__( self, 1998 1999 name, 1999 trdid,2000 is_main, 2000 2001 x, 2001 2002 y, … … 2005 2006 startid ): 2006 2007 2007 self.index = 0 # global index value set by addT ask()2008 self.name = name # t skname2009 self. trdid = trdid # task index (unique invspace)2008 self.index = 0 # global index value set by addThread() 2009 self.name = name # thread name 2010 self.is_main = is_main # Boolean (one main per vspace) 2010 2011 self.x = x # cluster x coordinate 2011 2012 self.y = y # cluster y coordinate … … 2016 2017 return 2017 2018 2018 ###################################### 2019 def xml( self ): # xml for one t ask2020 2021 s = ' <t askname="%s"' % self.name2022 s += ' trdid="%d"' % self.trdid2019 ######################################## 2020 def xml( self ): # xml for one thread 2021 2022 s = ' <thread name="%s"' % self.name 2023 s += ' is_main="%d"' % self.is_main 2023 2024 s += ' x="%d"' % self.x 2024 2025 s += ' y="%d"' % self.y … … 2032 2033 return s 2033 2034 2034 ########################################################################## 2035 def cbin( self, mapping, verbose, expected, vspace ): # C binary for T ask2035 ############################################################################ 2036 def cbin( self, mapping, verbose, expected, vspace ): # C binary for Thread 2036 2037 2037 2038 if ( verbose ): 2038 print '*** cbin for t ask%s in vspace %s' \2039 print '*** cbin for thread %s in vspace %s' \ 2039 2040 % (self.name, vspace.name) 2040 2041 2041 2042 # check index 2042 2043 if (self.index != expected): 2043 print '[genmap error] in T ask.cbin()'2044 print ' t askglobal index = %d / expected = %d' \2044 print '[genmap error] in Thread.cbin()' 2045 print ' thread global index = %d / expected = %d' \ 2045 2046 %(self.index,expected) 2046 2047 sys.exit(1) … … 2055 2056 2056 2057 if ( vseg_stack_id == 0xFFFFFFFF ): 2057 print '[genmap error] in T ask.cbin()'2058 print ' stackname %s not found for t ask%s in vspace %s' \2058 print '[genmap error] in Thread.cbin()' 2059 print ' stackname %s not found for thread %s in vspace %s' \ 2059 2060 % ( self.stackname, self.name, vspace.name ) 2060 2061 sys.exit(1) … … 2069 2070 2070 2071 if ( vseg_heap_id == 0xFFFFFFFF ): 2071 print '[genmap error] in T ask.cbin()'2072 print ' heapname %s not found for t ask%s in vspace %s' \2072 print '[genmap error] in Thread.cbin()' 2073 print ' heapname %s not found for thread %s in vspace %s' \ 2073 2074 % ( self.heapname, self.name, vspace.name ) 2074 2075 sys.exit(1) 2075 2076 2076 2077 byte_stream = bytearray() 2077 byte_stream += mapping.str2bytes(32,self.name) # t askname in vspace2078 byte_stream += mapping.str2bytes(32,self.name) # thread name in vspace 2078 2079 byte_stream += mapping.int2bytes(4, cluster_id) # cluster global index 2079 2080 byte_stream += mapping.int2bytes(4, self.p) # processor local index 2080 byte_stream += mapping.int2bytes(4, self. trdid) # thread index in vspace2081 byte_stream += mapping.int2bytes(4, self.is_main) # main if non zero 2081 2082 byte_stream += mapping.int2bytes(4, vseg_stack_id) # stack vseg local index 2082 2083 byte_stream += mapping.int2bytes(4, vseg_heap_id) # heap vseg local index … … 2087 2088 print 'clusterid = %d' % cluster_id 2088 2089 print 'lpid = %d' % self.p 2089 print ' trdid = %d' % self.trdid2090 print 'is_main = %d' % self.is_main 2090 2091 print 'stackid = %d' % vseg_stack_id 2091 2092 print 'heapid = %d' % vseg_heap_id
Note: See TracChangeset
for help on using the changeset viewer.