Ignore:
Timestamp:
Aug 3, 2015, 7:07:02 PM (9 years ago)
Author:
guerin
Message:

raycast: initial distributed implementation

The main task runs on processor (0,0,0). It manages game logic and
initialization, and participates in the rendering process.
The render task runs on all other processors. It tries to render a frame
slice when available, which is raycasting + pixel drawing for a pixel
column of the frame.

File:
1 edited

Legend:

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

    r679 r683  
    88#   author : Alain Greiner
    99#######################################################################################
    10 #  This file describes the mapping of the single thread "raycast" application
    11 #  on processor[0][0][0] of a multi-clusters, multi-processors architecture.
     10#  This file describes the mapping of the multi-threaded "raycast" application
     11#  on a multi-clusters, multi-processors architecture.
     12#  The mapping of tasks on processors is the following:
     13#    - one "main" task on (0,0,0)
     14#    - one "render" task per processor but (0,0,0)
     15#  The mapping of virtual segments is the following:
     16#    - There is one shared data vseg in cluster[0][0]
     17#    - The code vsegs are replicated on all clusters containing processors.
     18#    - There is one heap vseg per cluster containing processors.
     19#    - The stacks vsegs are distibuted on all clusters containing processors.
     20#  This mapping uses 5 platform parameters, (obtained from the "mapping" argument)
     21#    - x_size    : number of clusters in a row
     22#    - y_size    : number of clusters in a column
     23#    - x_width   : number of bits for x field
     24#    - y_width   : number of bits for y field
     25#    - nprocs    : number of processors per cluster
    1226####################################################################################
    1327
     
    1529def extend( mapping ):
    1630
     31    x_size    = mapping.x_size
     32    y_size    = mapping.y_size
    1733    nprocs    = mapping.nprocs
    18     x_width   = mapping.x_width
    19     y_width   = mapping.y_width
    2034
    2135    # define vsegs base & size
     
    3549    vspace = mapping.addVspace( name = 'raycast', startname = 'raycast_data', active = False )
    3650   
    37     # data vseg
     51    # data vseg : shared / cluster[0][0]
    3852    mapping.addVseg( vspace, 'raycast_data', data_base , data_size,
    3953                     'C_WU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
     
    4155                     local = False )
    4256
    43     # code vseg
    44     mapping.addVseg( vspace, 'raycast_code', code_base , code_size,
    45                      'CXWU', vtype = 'ELF', x = 0, y = 0, pseg = 'RAM',
    46                      binpath = 'bin/raycast/appli.elf',
    47                      local = False )
     57    # code vsegs : local (one copy in each cluster)
     58    for x in xrange (x_size):
     59        for y in xrange (y_size):
     60            cluster_id = (x * y_size) + y
     61            if ( mapping.clusters[cluster_id].procs ):
     62                mapping.addVseg( vspace, 'raycast_code_%d_%d' %(x,y),
     63                                 code_base , code_size,
     64                                 'CXWU', vtype = 'ELF', x = x, y = y, pseg = 'RAM',
     65                                 binpath = 'bin/raycast/appli.elf',
     66                                 local = True )
    4867
    49     # stack vseg             
    50     mapping.addVseg( vspace, 'raycast_stack', stack_base, stack_size,
    51                      'C_WU', vtype = 'BUFFER', x = 0 , y = 0 , pseg = 'RAM',
    52                      local = False, big = True )
     68    # stacks vsegs: local (one stack per processor => nprocs stacks per cluster)
     69    for x in xrange (x_size):
     70        for y in xrange (y_size):
     71            cluster_id = (x * y_size) + y
     72            if ( mapping.clusters[cluster_id].procs ):
     73                for p in xrange( nprocs ):
     74                    proc_id = (((x * y_size) + y) * nprocs) + p
     75                    size    = (stack_size / nprocs) & 0xFFFFF000
     76                    base    = stack_base + (proc_id * size)
     77                    mapping.addVseg( vspace, 'raycast_stack_%d_%d_%d' % (x,y,p),
     78                                     base, size, 'C_WU', vtype = 'BUFFER',
     79                                     x = x , y = y , pseg = 'RAM',
     80                                     local = True, big = True )   
    5381
    54     # heap vseg
    55     mapping.addVseg( vspace, 'raycast_heap', heap_base, heap_size,
    56                      'C_WU', vtype = 'BUFFER', x = 0 , y = 0 , pseg = 'RAM',
    57                      local = False )
     82    # heap vsegs : shared (one per cluster)
     83    for x in xrange (x_size):
     84        for y in xrange (y_size):
     85            cluster_id = (x * y_size) + y
     86            if ( mapping.clusters[cluster_id].procs ):
     87                size  = heap_size
     88                base  = heap_base + (cluster_id * size)
     89                mapping.addVseg( vspace, 'raycast_heap_%d_%d' %(x,y), base , size,
     90                                 'C_WU', vtype = 'HEAP', x = x, y = y, pseg = 'RAM',
     91                                 local = False )
    5892
    59     # task
    60     mapping.addTask( vspace, 'raycast', 0, 0, 0, 0, 'raycast_stack', 'raycast_heap', 0 )
     93    # distributed tasks / one task per processor
     94    for x in xrange (x_size):
     95        for y in xrange (y_size):
     96            cluster_id = (x * y_size) + y
     97            if ( mapping.clusters[cluster_id].procs ):
     98                for p in xrange( nprocs ):
     99                    trdid = (((x * y_size) + y) * nprocs) + p
     100                    if  ( x == 0 and y == 0 and p == 0 ):       # main task
     101                        task_index = 1
     102                        task_name  = 'main_%d_%d_%d' %(x,y,p)
     103                    else:                                       # render task
     104                        task_index = 0
     105                        task_name  = 'render_%d_%d_%d' % (x,y,p)
     106
     107                    mapping.addTask( vspace, task_name, trdid, x, y, p,
     108                                     'raycast_stack_%d_%d_%d' % (x,y,p),
     109                                     'raycast_heap_%d_%d' % (x,y),
     110                                     task_index )
    61111
    62112    # extend mapping name
Note: See TracChangeset for help on using the changeset viewer.