Changeset 271


Ignore:
Timestamp:
Jan 17, 2014, 11:49:27 PM (10 years ago)
Author:
cfuguet
Message:
  • Bugfix: The ISR_SWITCH index should be NB_PROCS_MAX + local_pid. This is because the first NB_PROCS_MAX indexes on the XICU in each cluster are used for the WAKEUP software interrupts.
  • Relocating the memcpy and memset functions into the giet_libs/stdlib.* files.
  • Modification of the sort application to used 8 threads instead of
    1. Modifying the mapping files to distribute the 8 threads on the available processors. (Ex. When using 4 processors, each one executes 2 threads)
Location:
soft/giet_vm
Files:
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/dhrystone/dhry.h

    r258 r271  
    363363#include <string.h>
    364364#include <malloc.h>
     365#include <stdlib.h>
    365366
    366367typedef int     One_Thirty;
  • soft/giet_vm/giet_drivers/xcu_driver.c

    r263 r271  
    170170////////////////////////////////////////////////////////////////////////////////
    171171unsigned int _xcu_timer_start( unsigned int cluster_xy,
    172                                unsigned int proc_id,
     172                               unsigned int pti_index,
    173173                               unsigned int period )
    174174{
     
    178178    if (x >= X_SIZE)             return 1;
    179179    if (y >= Y_SIZE)             return 1;
    180     if (proc_id >= NB_PROCS_MAX) return 1;
    181180
    182181#if USE_XICU
    183182    unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
    184183                                (cluster_xy * (unsigned int)&vseg_cluster_increment));
    185     xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period;
     184    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = period;
    186185    return 0;
    187186#else
     
    200199//////////////////////////////////////////////////////////////////////////////
    201200unsigned int _xcu_timer_stop( unsigned int cluster_xy,
    202                               unsigned int proc_id)
    203 {
    204     // parameters checking
    205     unsigned int x = cluster_xy >> Y_WIDTH;
    206     unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    207     if (x >= X_SIZE)             return 1;
    208     if (y >= Y_SIZE)             return 1;
    209     if (proc_id >= NB_PROCS_MAX) return 1;
     201                              unsigned int pti_index)
     202{
     203    // parameters checking
     204    unsigned int x = cluster_xy >> Y_WIDTH;
     205    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     206    if (x >= X_SIZE)             return 1;
     207    if (y >= Y_SIZE)             return 1;
    210208
    211209#if USE_XICU
    212210    unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
    213211                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
    214     xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0;
     212    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = 0;
    215213    return 0;
    216214#else
     
    231229//////////////////////////////////////////////////////////////////////////////
    232230unsigned int _xcu_timer_reset_irq( unsigned int cluster_xy,
    233                                    unsigned int proc_id )
    234 {
    235     // parameters checking
    236     unsigned int x = cluster_xy >> Y_WIDTH;
    237     unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    238     if (x >= X_SIZE)             return 1;
    239     if (y >= Y_SIZE)             return 1;
    240     if (proc_id >= NB_PROCS_MAX) return 1;
    241 
    242 #if USE_XICU
    243     unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base +
    244                                  (cluster_xy * (unsigned int)&vseg_cluster_increment));
    245 
    246     unsigned int bloup = xcu_address[XICU_REG(XICU_PTI_ACK, proc_id)];
    247     bloup++; // to avoid a warning
     231                                   unsigned int pti_index )
     232{
     233    // parameters checking
     234    unsigned int x = cluster_xy >> Y_WIDTH;
     235    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     236    if (x >= X_SIZE)             return 1;
     237    if (y >= Y_SIZE)             return 1;
     238
     239#if USE_XICU
     240    volatile unsigned int * xcu_address =
     241        (unsigned int *) ((unsigned int)&seg_xcu_base +
     242        (cluster_xy * (unsigned int)&vseg_cluster_increment));
     243
     244    xcu_address[XICU_REG(XICU_PTI_ACK, pti_index)];
    248245    return 0;
    249246#else
     
    265262/////////////////////////////////////////////////////////////////////////////
    266263unsigned int _xcu_timer_reset_cpt( unsigned int cluster_xy,
    267                                    unsigned int proc_id )
    268 {
    269     // parameters checking
    270     unsigned int x = cluster_xy >> Y_WIDTH;
    271     unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
    272     if (x >= X_SIZE)             return 1;
    273     if (y >= Y_SIZE)             return 1;
    274     if (proc_id >= NB_PROCS_MAX) return 1;
     264                                   unsigned int pti_index )
     265{
     266    // parameters checking
     267    unsigned int x = cluster_xy >> Y_WIDTH;
     268    unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1);
     269    if (x >= X_SIZE)             return 1;
     270    if (y >= Y_SIZE)             return 1;
    275271
    276272#if USE_XICU
     
    278274                                 (cluster_xy * (unsigned int)&vseg_cluster_increment));
    279275
    280     unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, proc_id)];
     276    unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, pti_index)];
    281277
    282278    // we write 0 first because if the timer is currently running,
    283279    // the corresponding timer counter is not reset
    284     xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0;
    285     xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period;
     280    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = 0;
     281    xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = period;
    286282    return 0;
    287283#else
  • soft/giet_vm/giet_kernel/ctx_handler.c

    r267 r271  
    119119        // reset timer counter
    120120#if USE_XICU
    121         _xcu_timer_reset_cpt(cluster_id, local_id);
     121        _xcu_timer_reset_cpt(cluster_id, NB_PROCS_MAX + local_id);
    122122#else
    123         _timer_reset_cpt(cluster_id, local_id);
     123        _timer_reset_cpt(cluster_id, NB_PROCS_MAX + local_id);
    124124#endif
    125125
  • soft/giet_vm/giet_kernel/kernel_init.c

    r263 r271  
    290290        }
    291291
     292        // the ISR_SWITCH irq index must be NB_PROCS_MAX + local_pid because
     293        // the first NB_PROCS_MAX irqs are used by the WAKEUP ones
     294        if (isr_switch_index != (NB_PROCS_MAX + local_pid))
     295        {
     296            _tty_get_lock( 0 );
     297            _puts("\n[GIET ERROR] ISR_SWITCH wrong index for processor ");
     298            _putx(global_pid);
     299            _puts("\n. It should be NB_PROCS_MAX + local_pid =");
     300            _putd(NB_PROCS_MAX + local_pid);
     301            _puts("\n");
     302            _tty_release_lock( 0 );
     303            _exit();
     304        }
     305
    292306        // start system timer
    293307        unsigned int ko;
    294308#if USE_XICU
    295         ko = _xcu_timer_start( cluster_xy, local_pid, GIET_TICK_VALUE );
     309        ko = _xcu_timer_start( cluster_xy, isr_switch_index, GIET_TICK_VALUE );
    296310#else
    297         ko = _timer_start( cluster_xy, local_pid, GIET_TICK_VALUE );
     311        ko = _timer_start( cluster_xy, isr_switch_index, GIET_TICK_VALUE );
    298312#endif
    299313        if ( ko )
  • soft/giet_vm/giet_libs/srl.h

    r258 r271  
    1010#include "mapping_info.h"
    1111#include "stdio.h"
    12 #include "utils.h"
     12#include "stdlib.h"
    1313
    1414#include "libsrl/srl_public_types.h"
  • soft/giet_vm/giet_libs/stdio.c

    r267 r271  
    1313#include <stdio.h>
    1414#include <giet_config.h>
    15 
    1615
    1716////////////////////////////////////////////////////////////////////////////////////
     
    823822    }
    824823}
    825 ///////////////////////////////////////////////////////////////////////////////////
    826 // memcpy()
    827 ///////////////////////////////////////////////////////////////////////////////////
    828 inline void* memcpy( void*        dest,
    829                      const void*  source,
    830                      unsigned int size )
    831 {
    832     unsigned int*       dst = dest;
    833     const unsigned int* src = source;
    834 
    835     // word-by-word copy
    836     if (!((unsigned int) dst & 3) && !((unsigned int) src & 3))
    837     {
    838         while (size > 3)
    839         {
    840             *dst++ = *src++;
    841             size -= 4;
    842         }
    843     }
    844 
    845     unsigned char * cdst = (unsigned char *) dst;
    846     unsigned char * csrc = (unsigned char *) src;
    847 
    848     /* byte-by-byte copy */
    849     while (size--)
    850     {
    851         *cdst++ = *csrc++;
    852     }
    853     return dest;
    854 }
    855824
    856825// Local Variables:
  • soft/giet_vm/giet_libs/stdlib.c

    r259 r271  
    55// Copyright (c) UPMC-LIP6
    66///////////////////////////////////////////////////////////////////////////////////
     7
     8#include <stdlib.h>
    79
    810///////////////////////////////////////////////////////////////////////////////////
     
    3133}
    3234       
     35////////////////////////////////////////////////////////////////////////////////////////
     36//  mempcy()
     37// GCC requires this function. Taken from MutekH.
     38////////////////////////////////////////////////////////////////////////////////////////
     39void * memcpy(void *_dst, const void * _src, unsigned int size) {
     40    unsigned int * dst = _dst;
     41    const unsigned int * src = _src;
     42    if (!((unsigned int) dst & 3) && !((unsigned int) src & 3) )
     43        while (size > 3) {
     44            *dst++ = *src++;
     45            size -= 4;
     46        }
     47
     48    unsigned char *cdst = (unsigned char*)dst;
     49    unsigned char *csrc = (unsigned char*)src;
     50
     51    while (size--) {
     52        *cdst++ = *csrc++;
     53    }
     54    return _dst;
     55}
     56
     57
     58////////////////////////////////////////////////////////////////////////////////////////
     59//  mempcy()
     60// GCC requires this function. Taken from MutekH.
     61////////////////////////////////////////////////////////////////////////////////////////
     62inline void * memset(void * dst, int s, unsigned int count) {
     63    char * a = (char *) dst;
     64    while (count--){
     65        *a++ = (char)s;
     66    }
     67    return dst;
     68}
     69
    3370// Local Variables:
    3471// tab-width: 4
  • soft/giet_vm/giet_libs/stdlib.h

    r259 r271  
    1010
    1111int atoi (char * str);
     12
     13////////////////////////////////////////////////////////////////////////////////////////
     14//  mempcy()
     15// GCC requires this function. Taken from MutekH.
     16////////////////////////////////////////////////////////////////////////////////////////
     17void * memcpy(void *_dst, const void * _src, unsigned int size);
     18
     19////////////////////////////////////////////////////////////////////////////////////////
     20//  mempcy()
     21// GCC requires this function. Taken from MutekH.
     22////////////////////////////////////////////////////////////////////////////////////////
     23inline void * memset(void * dst, int s, unsigned int count);
    1224#endif
    1325
  • soft/giet_vm/mappings/4c_1p_iob_sort.xml

    r265 r271  
    281281            <vseg name = "seg_sort_stack0" vbase = "0x00800000" mode = "C_WU" x = "0" y = "0" psegname = "PSEG_RAM" >
    282282                <vobj name = "sort_stack0" type  = "BUFFER" length = "0x00010000" />
     283                <vobj name = "sort_stack1" type  = "BUFFER" length = "0x00010000" />
    283284                <vobj name = "sort_heap0"  type  = "BUFFER" length = "0x00010000" />
    284285            </vseg>
    285286            <vseg name = "seg_sort_stack1" vbase = "0x00A00000" mode = "C_WU" x = "0" y = "1" psegname = "PSEG_RAM" >
    286                 <vobj name = "sort_stack1" type  = "BUFFER" length = "0x00010000" />
     287                <vobj name = "sort_stack2" type  = "BUFFER" length = "0x00010000" />
     288                <vobj name = "sort_stack3" type  = "BUFFER" length = "0x00010000" />
    287289                <vobj name = "sort_heap1"  type  = "BUFFER" length = "0x00010000" />
    288290            </vseg>
    289291            <vseg name = "seg_sort_stack2" vbase = "0x00C00000" mode = "C_WU" x = "1" y = "0" psegname = "PSEG_RAM" >
    290                 <vobj name = "sort_stack2" type  = "BUFFER" length = "0x00010000" />
     292                <vobj name = "sort_stack4" type  = "BUFFER" length = "0x00010000" />
     293                <vobj name = "sort_stack5" type  = "BUFFER" length = "0x00010000" />
    291294                <vobj name = "sort_heap2"  type  = "BUFFER" length = "0x00010000" />
    292295            </vseg>
    293296            <vseg name = "seg_sort_stack3" vbase = "0x00E00000" mode = "C_WU" x = "1" y = "1" psegname = "PSEG_RAM" >
    294                 <vobj name = "sort_stack3" type  = "BUFFER" length = "0x00010000" />
     297                <vobj name = "sort_stack6" type  = "BUFFER" length = "0x00010000" />
     298                <vobj name = "sort_stack7" type  = "BUFFER" length = "0x00010000" />
    295299                <vobj name = "sort_heap3"  type  = "BUFFER" length = "0x00010000" />
    296300            </vseg>
    297301
    298             <task name = "sort_0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap3" startid = "0" usetty = "1" />
    299             <task name = "sort_1" x = "0" y = "1" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap3" startid = "0" usetty = "1" />
    300             <task name = "sort_2" x = "1" y = "0" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap3" startid = "0" usetty = "1" />
    301             <task name = "sort_3" x = "1" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap3" startid = "0" usetty = "1" />
     302            <task name = "sort_0" trdid = "0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap0" startid = "0" usetty = "1" />
     303            <task name = "sort_1" trdid = "1" x = "0" y = "0" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap0" startid = "0" usetty = "1" />
     304            <task name = "sort_2" trdid = "2" x = "0" y = "1" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap1" startid = "0" usetty = "1" />
     305            <task name = "sort_3" trdid = "3" x = "0" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap1" startid = "0" usetty = "1" />
     306            <task name = "sort_4" trdid = "4" x = "1" y = "0" proclocid = "0" stackname = "sort_stack4" heapname = "sort_heap2" startid = "0" usetty = "1" />
     307            <task name = "sort_5" trdid = "5" x = "1" y = "0" proclocid = "0" stackname = "sort_stack5" heapname = "sort_heap2" startid = "0" usetty = "1" />
     308            <task name = "sort_6" trdid = "6" x = "1" y = "1" proclocid = "0" stackname = "sort_stack6" heapname = "sort_heap3" startid = "0" usetty = "1" />
     309            <task name = "sort_7" trdid = "7" x = "1" y = "1" proclocid = "0" stackname = "sort_stack7" heapname = "sort_heap3" startid = "0" usetty = "1" />
    302310        </vspace>
    303311    </vspaceset>
  • soft/giet_vm/mappings/4c_1p_sort.xml

    r270 r271  
    5959
    6060        <cluster x = "0" y = "1" >
     61            <pseg name = "PSEG_RAM"  type = "RAM"  base = "0x0100000000" length = "0x0001000000" />
     62            <pseg name = "PSEG_XCU"  type = "PERI" base = "0x01B0000000" length = "0x0000002000" />
     63            <pseg name = "PSEG_DMA"  type = "PERI" base = "0x01B1000000" length = "0x0000008000" />
     64            <pseg name = "PSEG_MMC"  type = "PERI" base = "0x01B8000000" length = "0x0000001000" />
     65
     66            <proc index = "0" >
     67                <irq type = "SOFT" icuid = "0" isr = "ISR_WAKUP" />
     68                <irq type = "TIME" icuid = "1" isr = "ISR_SWITCH" />
     69            </proc>
     70
     71            <periph type = "DMA"  psegname = "PSEG_DMA"  channels = "1" />
     72            <periph type = "XCU"  psegname = "PSEG_XCU"  channels = "1" />
     73            <periph type = "MMC"  psegname = "PSEG_MMC"  channels = "1" />
     74        </cluster>
     75
     76        <cluster x = "1" y = "0" >
    6177            <pseg name = "PSEG_RAM"  type = "RAM"  base = "0x1000000000" length = "0x0001000000" />
    6278            <pseg name = "PSEG_XCU"  type = "PERI" base = "0x10B0000000" length = "0x0000002000" />
    6379            <pseg name = "PSEG_DMA"  type = "PERI" base = "0x10B1000000" length = "0x0000008000" />
    6480            <pseg name = "PSEG_MMC"  type = "PERI" base = "0x10B8000000" length = "0x0000001000" />
    65 
    66             <proc index = "0" >
    67                 <irq type = "SOFT" icuid = "0" isr = "ISR_WAKUP" />
    68                 <irq type = "TIME" icuid = "1" isr = "ISR_SWITCH" />
    69             </proc>
    70 
    71             <periph type = "DMA"  psegname = "PSEG_DMA"  channels = "1" />
    72             <periph type = "XCU"  psegname = "PSEG_XCU"  channels = "1" />
    73             <periph type = "MMC"  psegname = "PSEG_MMC"  channels = "1" />
    74         </cluster>
    75 
    76         <cluster x = "1" y = "0" >
    77             <pseg name = "PSEG_RAM"  type = "RAM"  base = "0x0100000000" length = "0x0001000000" />
    78             <pseg name = "PSEG_XCU"  type = "PERI" base = "0x01B0000000" length = "0x0000002000" />
    79             <pseg name = "PSEG_DMA"  type = "PERI" base = "0x01B1000000" length = "0x0000008000" />
    80             <pseg name = "PSEG_MMC"  type = "PERI" base = "0x01B8000000" length = "0x0000001000" />
    8181
    8282            <proc index = "0" >
     
    255255            <vseg name = "seg_sort_stack0" vbase = "0x00800000" mode = "C_WU" x = "0" y = "0" psegname = "PSEG_RAM" >
    256256                <vobj name = "sort_stack0" type  = "BUFFER" length = "0x00010000" />
     257                <vobj name = "sort_stack1" type  = "BUFFER" length = "0x00010000" />
    257258                <vobj name = "sort_heap0"  type  = "BUFFER" length = "0x00010000" />
    258259            </vseg>
    259260            <vseg name = "seg_sort_stack1" vbase = "0x00A00000" mode = "C_WU" x = "0" y = "1" psegname = "PSEG_RAM" >
    260                 <vobj name = "sort_stack1" type  = "BUFFER" length = "0x00010000" />
     261                <vobj name = "sort_stack2" type  = "BUFFER" length = "0x00010000" />
     262                <vobj name = "sort_stack3" type  = "BUFFER" length = "0x00010000" />
    261263                <vobj name = "sort_heap1"  type  = "BUFFER" length = "0x00010000" />
    262264            </vseg>
    263265            <vseg name = "seg_sort_stack2" vbase = "0x00C00000" mode = "C_WU" x = "1" y = "0" psegname = "PSEG_RAM" >
    264                 <vobj name = "sort_stack2" type  = "BUFFER" length = "0x00010000" />
     266                <vobj name = "sort_stack4" type  = "BUFFER" length = "0x00010000" />
     267                <vobj name = "sort_stack5" type  = "BUFFER" length = "0x00010000" />
    265268                <vobj name = "sort_heap2"  type  = "BUFFER" length = "0x00010000" />
    266269            </vseg>
    267270            <vseg name = "seg_sort_stack3" vbase = "0x00E00000" mode = "C_WU" x = "1" y = "1" psegname = "PSEG_RAM" >
    268                 <vobj name = "sort_stack3" type  = "BUFFER" length = "0x00010000" />
     271                <vobj name = "sort_stack6" type  = "BUFFER" length = "0x00010000" />
     272                <vobj name = "sort_stack7" type  = "BUFFER" length = "0x00010000" />
    269273                <vobj name = "sort_heap3"  type  = "BUFFER" length = "0x00010000" />
    270274            </vseg>
    271275
    272             <task name = "sort_0" trdid = "0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap3" startid = "0" usetty = "1" />
    273             <task name = "sort_1" trdid = "1" x = "0" y = "1" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap3" startid = "0" usetty = "1" />
    274             <task name = "sort_2" trdid = "2" x = "1" y = "0" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap3" startid = "0" usetty = "1" />
    275             <task name = "sort_3" trdid = "3" x = "1" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap3" startid = "0" usetty = "1" />
     276            <task name = "sort_0" trdid = "0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap0" startid = "0" usetty = "1" />
     277            <task name = "sort_1" trdid = "1" x = "0" y = "0" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap0" startid = "0" usetty = "1" />
     278            <task name = "sort_2" trdid = "2" x = "0" y = "1" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap1" startid = "0" usetty = "1" />
     279            <task name = "sort_3" trdid = "3" x = "0" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap1" startid = "0" usetty = "1" />
     280            <task name = "sort_4" trdid = "4" x = "1" y = "0" proclocid = "0" stackname = "sort_stack4" heapname = "sort_heap2" startid = "0" usetty = "1" />
     281            <task name = "sort_5" trdid = "5" x = "1" y = "0" proclocid = "0" stackname = "sort_stack5" heapname = "sort_heap2" startid = "0" usetty = "1" />
     282            <task name = "sort_6" trdid = "6" x = "1" y = "1" proclocid = "0" stackname = "sort_stack6" heapname = "sort_heap3" startid = "0" usetty = "1" />
     283            <task name = "sort_7" trdid = "7" x = "1" y = "1" proclocid = "0" stackname = "sort_stack7" heapname = "sort_heap3" startid = "0" usetty = "1" />
    276284        </vspace>
    277285    </vspaceset>
  • soft/giet_vm/mappings/4c_1p_sort_chiplet.xml

    r270 r271  
    3232                <irq type = "SOFT" icuid = "0"  isr = "ISR_WAKUP" />
    3333                <irq type = "TIME" icuid = "1"  isr = "ISR_SWITCH" />
    34                 <irq type = "HARD" icuid = "2" isr = "ISR_IOC" />
     34                <irq type = "HARD" icuid = "31" isr = "ISR_IOC" />
    3535            </proc>
    3636
     
    208208            <vseg name = "seg_sort_stack0" vbase = "0x00800000" mode = "C_WU" x = "0" y = "0" psegname = "PSEG_RAM" >
    209209                <vobj name = "sort_stack0" type  = "BUFFER" length = "0x00010000" />
     210                <vobj name = "sort_stack1" type  = "BUFFER" length = "0x00010000" />
    210211                <vobj name = "sort_heap0"  type  = "BUFFER" length = "0x00010000" />
    211212            </vseg>
    212213            <vseg name = "seg_sort_stack1" vbase = "0x00A00000" mode = "C_WU" x = "0" y = "1" psegname = "PSEG_RAM" >
    213                 <vobj name = "sort_stack1" type  = "BUFFER" length = "0x00010000" />
     214                <vobj name = "sort_stack2" type  = "BUFFER" length = "0x00010000" />
     215                <vobj name = "sort_stack3" type  = "BUFFER" length = "0x00010000" />
    214216                <vobj name = "sort_heap1"  type  = "BUFFER" length = "0x00010000" />
    215217            </vseg>
    216218            <vseg name = "seg_sort_stack2" vbase = "0x00C00000" mode = "C_WU" x = "1" y = "0" psegname = "PSEG_RAM" >
    217                 <vobj name = "sort_stack2" type  = "BUFFER" length = "0x00010000" />
     219                <vobj name = "sort_stack4" type  = "BUFFER" length = "0x00010000" />
     220                <vobj name = "sort_stack5" type  = "BUFFER" length = "0x00010000" />
    218221                <vobj name = "sort_heap2"  type  = "BUFFER" length = "0x00010000" />
    219222            </vseg>
    220223            <vseg name = "seg_sort_stack3" vbase = "0x00E00000" mode = "C_WU" x = "1" y = "1" psegname = "PSEG_RAM" >
    221                 <vobj name = "sort_stack3" type  = "BUFFER" length = "0x00010000" />
     224                <vobj name = "sort_stack6" type  = "BUFFER" length = "0x00010000" />
     225                <vobj name = "sort_stack7" type  = "BUFFER" length = "0x00010000" />
    222226                <vobj name = "sort_heap3"  type  = "BUFFER" length = "0x00010000" />
    223227            </vseg>
    224228
    225             <task name = "sort_0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap3" startid = "0" usetty = "1" />
    226             <task name = "sort_1" x = "0" y = "1" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap3" startid = "0" usetty = "1" />
    227             <task name = "sort_2" x = "1" y = "0" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap3" startid = "0" usetty = "1" />
    228             <task name = "sort_3" x = "1" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap3" startid = "0" usetty = "1" />
     229            <task name = "sort_0" trdid = "0" x = "0" y = "0" proclocid = "0" stackname = "sort_stack0" heapname = "sort_heap0" startid = "0" usetty = "1" />
     230            <task name = "sort_1" trdid = "1" x = "0" y = "0" proclocid = "0" stackname = "sort_stack1" heapname = "sort_heap0" startid = "0" usetty = "1" />
     231            <task name = "sort_2" trdid = "2" x = "0" y = "1" proclocid = "0" stackname = "sort_stack2" heapname = "sort_heap1" startid = "0" usetty = "1" />
     232            <task name = "sort_3" trdid = "3" x = "0" y = "1" proclocid = "0" stackname = "sort_stack3" heapname = "sort_heap1" startid = "0" usetty = "1" />
     233            <task name = "sort_4" trdid = "4" x = "1" y = "0" proclocid = "0" stackname = "sort_stack4" heapname = "sort_heap2" startid = "0" usetty = "1" />
     234            <task name = "sort_5" trdid = "5" x = "1" y = "0" proclocid = "0" stackname = "sort_stack5" heapname = "sort_heap2" startid = "0" usetty = "1" />
     235            <task name = "sort_6" trdid = "6" x = "1" y = "1" proclocid = "0" stackname = "sort_stack6" heapname = "sort_heap3" startid = "0" usetty = "1" />
     236            <task name = "sort_7" trdid = "7" x = "1" y = "1" proclocid = "0" stackname = "sort_stack7" heapname = "sort_heap3" startid = "0" usetty = "1" />
    229237        </vspace>
    230238    </vspaceset>
  • soft/giet_vm/sort/main.c

    r269 r271  
    3838
    3939//////////////////////////////////////////////////////////////////////////
    40 // The NPROCS constant must be modified depending on the desired number of
     40// The NTHREADS constant must be modified depending on the desired number of
    4141// threads
    4242
    43 #define NPROCS          4
    44 #define ARRAY_LENGTH    (NPROCS * 128)
    45 #define IPP             (ARRAY_LENGTH / NPROCS) // ITEMS PER PROCESSOR
     43#define NTHREADS        8
     44#define ARRAY_LENGTH    (NTHREADS * 128)
     45#define IPT             (ARRAY_LENGTH / NTHREADS) // ITEMS PER THREAD
    4646
    4747////////////////////////////////////////////////////////////////////////////////
     
    8989///////////////////////////////////////////////////
    9090// This application support at most 256 processors
    91 // Number of barriers = log2(NPROCS)
     91// Number of barriers = log2(NTHREADS)
    9292
    9393giet_barrier_t barrier[8];
     
    101101    int i;
    102102
    103     task0_printf("[ Thread 0 ] Starting SORT application\n");
     103    printf("[ Thread %d ] Initializing vector and barriers...\n\r", thread_id);
    104104
    105105    ///////////////////////////
    106106    // Barriers Initialization
    107107
    108     for (i = 0; i < __builtin_ctz(NPROCS); i++)
    109     {
    110         barrier_init(&barrier[i], NPROCS >> i);
     108    for (i = 0; i < __builtin_ctz(NTHREADS); i++)
     109    {
     110        barrier_init(&barrier[i], NTHREADS >> i);
    111111    }
    112112
     
    114114    // Array Initialization
    115115
    116     for (i = IPP * thread_id; i < IPP * (thread_id + 1); i++)
     116    for (i = IPT * thread_id; i < IPT * (thread_id + 1); i++)
    117117    {
    118118        array0[i] = rand();
     
    124124    printf("[ Thread %d ] Stage 0: Processor Sorting...\n\r", thread_id);
    125125
    126     bubbleSort(array0, IPP, IPP * thread_id);
     126    bubbleSort(array0, IPT, IPT * thread_id);
    127127
    128128    printf("[ Thread %d ] Finishing Stage 0\n\r", thread_id);
    129129
    130     for (i = 0; i < __builtin_ctz(NPROCS); i++)
     130    for (i = 0; i < __builtin_ctz(NTHREADS); i++)
    131131    {
    132132        asm volatile ("sync");
     
    153153
    154154        merge(src_array, dst_array
    155                 , IPP << i
    156                 , IPP * thread_id
    157                 , IPP * (thread_id + (1 << i))
    158                 , IPP * thread_id
     155                , IPT << i
     156                , IPT * thread_id
     157                , IPT * (thread_id + (1 << i))
     158                , IPT * thread_id
    159159                );
    160160
Note: See TracChangeset for help on using the changeset viewer.