Changeset 292 for soft/giet_vm/sort


Ignore:
Timestamp:
Feb 14, 2014, 2:38:53 PM (10 years ago)
Author:
cfuguet
Message:
  • Introducing XML description file for the tsar_generic_leti platform.
  • Modification in the sort application: Introducing VOBJ CONST for sort application containing the number of threads.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/sort/main.c

    r271 r292  
    3434
    3535#include "stdio.h"
     36#include "mapping_info.h"
    3637#include "hard_config.h"
    3738#include "barrier.h"
    3839
    39 //////////////////////////////////////////////////////////////////////////
    40 // The NTHREADS constant must be modified depending on the desired number of
    41 // threads
    42 
    43 #define NTHREADS        8
    44 #define ARRAY_LENGTH    (NTHREADS * 128)
    45 #define IPT             (ARRAY_LENGTH / NTHREADS) // ITEMS PER THREAD
     40#define ARRAY_LENGTH    2048
     41#define IPT             (ARRAY_LENGTH / *nb_thread) // ITEMS PER THREAD
    4642
    4743////////////////////////////////////////////////////////////////////////////////
     
    7268int array1[ARRAY_LENGTH];
    7369
    74 volatile int init_ok = 0;
     70int init_ok = 0;
    7571
    7672void bubbleSort(
     
    8985///////////////////////////////////////////////////
    9086// This application support at most 256 processors
    91 // Number of barriers = log2(NTHREADS)
     87// Number of barriers = log2(nb_thread)
    9288
    9389giet_barrier_t barrier[8];
     
    9692{
    9793    int thread_id = giet_thread_id();
    98 
     94    unsigned int* nb_thread;
    9995    int * src_array;
    10096    int * dst_array;
    10197    int i;
    102 
    103     printf("[ Thread %d ] Initializing vector and barriers...\n\r", thread_id);
     98   
     99    unsigned int time_start = giet_proctime();
     100    unsigned int time_end;   
     101
     102    if( giet_vobj_get_vbase( "sort" ,
     103                             "nb_thread",
     104                             VOBJ_TYPE_CONST,
     105                             (unsigned int*)&nb_thread ) )
     106    {
     107        printf( "\n[ERROR] in sort task :\n");
     108        printf( "          undefined <nb_thread> constant: %d\n", nb_thread);
     109        exit();
     110    }   
     111   
     112    task0_printf("[Thread 0 ] Starting sort application with %d threads "
     113                 "at cycle %d\n", *nb_thread, time_start);
    104114
    105115    ///////////////////////////
    106116    // Barriers Initialization
    107117
    108     for (i = 0; i < __builtin_ctz(NTHREADS); i++)
    109     {
    110         barrier_init(&barrier[i], NTHREADS >> i);
     118    if (thread_id == 0)
     119    {
     120        for (i = 0; i < __builtin_ctz(*nb_thread); i++)
     121        {
     122            barrier_init(&barrier[i], *nb_thread >> i);
     123        }
     124
     125        init_ok = 1;
     126    }
     127    else
     128    {
     129        while(!init_ok);
    111130    }
    112131
     
    128147    printf("[ Thread %d ] Finishing Stage 0\n\r", thread_id);
    129148
    130     for (i = 0; i < __builtin_ctz(NTHREADS); i++)
     149    for (i = 0; i < __builtin_ctz(*nb_thread); i++)
    131150    {
    132151        asm volatile ("sync");
     
    183202        }
    184203
     204        time_end = giet_proctime();
     205        printf("[ Thread 0 ] Finishing sort application at cycle %d\n"
     206               "[ Thread 0 ] Time elapsed = %d\n",
     207                time_end, (time_end - time_start) );
     208
    185209        if (success)
    186210        {
     211
    187212            printf("[ Thread 0 ] Success!!\n\r");
    188213        }
Note: See TracChangeset for help on using the changeset viewer.