Ignore:
Timestamp:
Jun 25, 2014, 2:19:37 PM (10 years ago)
Author:
cfuguet
Message:

giet_vm optimizations:

  • Several modifications in GIET_VM in order to support compilation with GCC optimizations (-O2) activated.
  • Adding missing volatile in some global variables.
  • Using ioread and iowrite utility functions in peripheral drivers which prevent GCC to remove writes or reads in hardware memory mapped registers.
  • Code refactoring of stdio printf functions. Now, shr_printf and tty_printf function reuse the same function body. The only difference is that shr_printf wraps printf function call with TTY get lock and release lock.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_libs/barrier.c

    r295 r345  
    2020                   unsigned int    value )
    2121{
    22     barrier->init  = value;
    23     barrier->count = value;
     22    barrier->init  = (volatile unsigned int)value;
     23    barrier->count = (volatile unsigned int)value;
     24    asm volatile ("sync" ::: "memory");
    2425}
    2526
     
    3132void barrier_wait( giet_barrier_t* barrier )
    3233{
    33     unsigned int * pcount = (unsigned int *) &barrier->count;
    34     unsigned int maxcount = barrier->init;
    35     unsigned int count;
     34    volatile unsigned int * pcount = (unsigned int *) &barrier->count;
     35    volatile unsigned int maxcount = barrier->init;
     36    volatile unsigned int count;
    3637
    3738    // parallel decrement barrier counter using atomic instructions LL/SC
    3839    // - input : pointer on the barrier counter
    3940    // - output : counter value
    40     asm volatile ("_barrier_decrement:    \n"
    41             "ll   %0, 0(%1)               \n"
    42             "addi $3, %0,     -1          \n"
    43             "sc   $3, 0(%1)               \n"
    44             "beqz $3, _barrier_decrement  \n"
    45             : "=&r"(count)
     41    asm volatile (
     42            "_barrier_decrement:                \n"
     43            "ll     %0,   0(%1)                 \n"
     44            "addi   $3,   %0,     -1            \n"
     45            "sc     $3,   0(%1)                 \n"
     46            "beqz   $3,   _barrier_decrement    \n"
     47            : "+r"(count)
    4648            : "r"(pcount)
    47             : "$2", "$3");
     49            : "$3", "memory");
    4850
    4951    // the last task re-initializes the barrier counter to the max value,
     
    5759    else {
    5860        // other tasks busy-wait
    59         while (*pcount != maxcount) asm volatile ("nop");
     61        while (*pcount != maxcount);
    6062    }
     63
     64    asm volatile ("sync" ::: "memory");
    6165}
    6266
Note: See TracChangeset for help on using the changeset viewer.