Changeset 345 for soft/giet_vm/sort


Ignore:
Timestamp:
Jun 25, 2014, 2:19:37 PM (11 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/sort/main.c

    r318 r345  
    5858int array1[ARRAY_LENGTH];
    5959
    60 int init_ok = 0;
     60volatile int init_ok = 0;
    6161
    6262void bubbleSort(
     
    9595                         (unsigned int*)&nb_thread );
    9696   
    97     task0_printf("\n[ Thread 0 ] Starting sort application with %d threads "
    98                  "at cycle %d\n", *nb_thread, time_start);
     97    task0_printf("\n[ Thread 0 ] Starting sort application with %u threads "
     98                 "at cycle %u\n", *nb_thread, time_start);
    9999
    100100    ///////////////////////////
     
    134134    for (i = 0; i < __builtin_ctz(*nb_thread); i++)
    135135    {
    136         asm volatile ("sync");
    137136        barrier_wait(&barrier[i]);
    138137
     
    171170    //////////////////////////////
    172171    // Verify the resulting array
    173 
    174     if(thread_id == 0)
    175     {
    176         success = 1;
    177 
    178         for(i=0; i<(ARRAY_LENGTH-1); i++)
    179         {
    180             if(dst_array[i] > dst_array[i+1])
    181             {
    182 
    183                 success = 0;
    184                 failure_index = i;
    185                 break;
    186             }
    187         }
    188 
    189         time_end = giet_proctime();
    190 
    191         printf("[ Thread 0 ] Finishing sort application at cycle %d\n"
    192                "[ Thread 0 ] Time elapsed = %d\n",
    193                 time_end, (time_end - time_start) );
    194 
    195         if (success)
    196         {
    197             exit("!!! Success !!!");
    198         }
    199         else
    200         {
    201             printf("[ Thread 0 ] Failure!! Incorrect element: %d\n\r",
    202                    failure_index);
    203             for(i=0; i<ARRAY_LENGTH; i++)
    204             {
    205                 printf("array[%d] = %d\n", i, dst_array[i]);
    206             }
    207             exit("!!!  Failure !!!");
    208         }
    209     }
     172   
     173    if(thread_id != 0)
     174    {
     175        exit("error: only thread 0 should get here");
     176    }
     177
     178    success = 1;
     179    for(i=0; i<(ARRAY_LENGTH-1); i++)
     180    {
     181        if(dst_array[i] > dst_array[i+1])
     182        {
     183
     184            success = 0;
     185            failure_index = i;
     186            break;
     187        }
     188    }
     189
     190    time_end = giet_proctime();
     191
     192    printf("[ Thread 0 ] Finishing sort application at cycle %d\n"
     193           "[ Thread 0 ] Time elapsed = %d\n",
     194            time_end, (time_end - time_start) );
     195
     196    if (success)
     197    {
     198        exit("!!! Success !!!");
     199    }
     200    else
     201    {
     202        printf("[ Thread 0 ] Failure!! Incorrect element: %d\n\r",
     203               failure_index);
     204        for(i=0; i<ARRAY_LENGTH; i++)
     205        {
     206            printf("array[%d] = %d\n", i, dst_array[i]);
     207        }
     208        exit("!!!  Failure !!!");
     209    }
     210
    210211    exit("Completed");
    211212}
Note: See TracChangeset for help on using the changeset viewer.