Ignore:
Timestamp:
Oct 1, 2015, 4:09:25 PM (9 years ago)
Author:
alain
Message:

Adapt the following application to the POSIX threads API

  • convol
  • classif
  • raycast
  • coproc
  • display
  • gameoflife
  • transpose
  • shell
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/classif/classif.py

    r610 r708  
    1010#  This file describes the mapping of the multi-threaded "classif"
    1111#  application on a multi-clusters, multi-processors architecture.
    12 #  The mapping of tasks on processors is the following:
    13 #    - one "load" task per cluster containing processors,
    14 #    - one "store" task per cluster containing processors,
    15 #    - (nprocs-2) "analyse" task per cluster containing processors.
     12#  The mapping of threads on processors is the following:
     13#    - the "main" on cluster[0][0] 
     14#    - one "load" thread per cluster containing processors,
     15#    - one "store" thread per cluster containing processors,
     16#    - (nprocs-2) "analyse" thread per cluster containing processors.
    1617#  The mapping of virtual segments is the following:
    1718#    - There is one shared data vseg in cluster[0][0]
     
    3940    y_width   = mapping.y_width
    4041
    41     assert (nprocs >= 3)
     42    assert (nprocs >= 3) and (nprocs <= 8)
    4243
    4344    # define vsegs base & size
    44     code_base  = 0x10000000
    45     code_size  = 0x00010000     # 64 Kbytes (replicated in each cluster)
     45    code_base  = 0x10000000     
     46    code_size  = 0x00010000     # 64 Kbytes (per cluster)
    4647   
    4748    data_base  = 0x20000000
    48     data_size  = 0x00010000     # 64 Kbytes
     49    data_size  = 0x00010000     # 64 Kbytes (non replicated)
    4950
    5051    heap_base  = 0x30000000
    51     heap_size  = 0x00040000     # 256 Kbytes (per cluster)     
     52    heap_size  = 0x00200000     # 2M bytes (per cluster)     
    5253
    5354    stack_base = 0x40000000
    54     stack_size = 0x00200000     # 2 Mbytes (per cluster)
     55    stack_size = 0x00010000     # 64 Kbytes (per thread)
    5556
    5657    # create vspace
    57     vspace = mapping.addVspace( name = 'classif', startname = 'classif_data' )
     58    vspace = mapping.addVspace( name = 'classif', startname = 'classif_data', active = False )
    5859   
    5960    # data vseg : shared / cluster[0][0]
     
    7374                mapping.addVseg( vspace, 'classif_heap_%d_%d' %(x,y), base , size,
    7475                                 'C_WU', vtype = 'HEAP', x = x, y = y, pseg = 'RAM',
    75                                  local = False )
     76                                 local = False, big = True )
    7677
    77     # code vsegs : local (one copy in each cluster)
     78    # code vsegs : local (one copy per cluster)
    7879    for x in xrange (x_size):
    7980        for y in xrange (y_size):
     
    8889
    8990    # stacks vsegs: local (one stack per processor => nprocs stacks per cluster)
     91    # ... plus main_stack in cluster[0][0]
     92    mapping.addVseg( vspace, 'main_stack',
     93                     stack_base, stack_size, 'C_WU', vtype = 'BUFFER',
     94                     x = 0 , y = 0 , pseg = 'RAM',
     95                     local = True )
     96
    9097    for x in xrange (x_size):
    9198        for y in xrange (y_size):
     
    94101                for p in xrange( nprocs ):
    95102                    proc_id = (((x * y_size) + y) * nprocs) + p
    96                     size    = (stack_size / nprocs) & 0xFFFFF000
    97                     base    = stack_base + (proc_id * size)
     103                    base    = stack_base + (proc_id * stack_size) + stack_size
    98104
    99105                    mapping.addVseg( vspace, 'classif_stack_%d_%d_%d' % (x,y,p),
    100                                      base, size, 'C_WU', vtype = 'BUFFER',
     106                                     base, stack_size, 'C_WU', vtype = 'BUFFER',
    101107                                     x = x , y = y , pseg = 'RAM',
    102                                      local = True, big = True )
     108                                     local = True )
    103109
    104     # distributed tasks / one task per processor
     110    # distributed threads / one thread per processor
     111    # ... plus main on P[0][0][0]
     112    mapping.addThread( vspace, 'main', True, 0, 0, 1,
     113                       'main_stack',
     114                       'classif_heap_0_0',
     115                       0 )                      # index in start_vector
     116
    105117    for x in xrange (x_size):
    106118        for y in xrange (y_size):
     
    108120            if ( mapping.clusters[cluster_id].procs ):
    109121                for p in xrange( nprocs ):
    110                     trdid = (((x * y_size) + y) * nprocs) + p
    111                     if  ( p== 0 ):                              # task load
    112                         task_index = 2
    113                         task_name  = 'load_%d_%d_%d' %(x,y,p)           
    114                     elif  ( p== 1 ):                            # task store
    115                         task_index = 1
    116                         task_name  = 'store_%d_%d_%d' %(x,y,p)           
    117                     else :                                      # task analyse
    118                         task_index = 0
    119                         task_name  = 'analyse_%d_%d_%d' % (x,y,p)
     122                    if  ( p== 0 ):                              # thread load
     123                        start_index = 3
     124                        thread_name = 'load_%d_%d_%d' %(x,y,p)           
     125                    elif  ( p== 1 ):                            # thread store
     126                        start_index = 2
     127                        thread_name = 'store_%d_%d_%d' %(x,y,p)           
     128                    else :                                      # thread analyse
     129                        start_index = 1
     130                        thread_name = 'analyse_%d_%d_%d' % (x,y,p)
    120131
    121                     mapping.addTask( vspace, task_name, trdid, x, y, p,
    122                                      'classif_stack_%d_%d_%d' % (x,y,p),
    123                                      'classif_heap_%d_%d' % (x,y),
    124                                      task_index )
     132                    mapping.addThread( vspace, thread_name, False , x, y, p,
     133                                       'classif_stack_%d_%d_%d' % (x,y,p),
     134                                       'classif_heap_%d_%d' % (x,y),
     135                                       start_index )   # index in start_vector
    125136
    126137    # extend mapping name
Note: See TracChangeset for help on using the changeset viewer.