Changeset 709 for soft/giet_vm/giet_xml


Ignore:
Timestamp:
Oct 1, 2015, 4:20:46 PM (9 years ago)
Author:
alain
Message:

Major release: Change the task model to implement the POSIX threads API.

  • The shell "exec" and "kill" commands can be used to activate/de-activate the applications.
  • The "pause", "resume", and "context" commands can be used to stop, restart, a single thtead or to display the thread context.

This version has been tested on the following multi-threaded applications,
that have been modified to use the POSIX threads:

  • classif
  • convol
  • transpose
  • gameoflife
  • raycast
Location:
soft/giet_vm/giet_xml
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_xml/mapping_info.h

    r645 r709  
    1414//
    1515// 2/ a description of the applications (called vspaces) to be - statically -
    16 // launched on the platform. The number of parallel tasks per application is
     16// mapped on the platform. The number of parallel threads per application is
    1717// variable (can be one). Each vspace contains a variable number
    1818// of virtual segments (called vsegs).
    1919//
    20 // 3/ the mapping directives: both tasks on processors, and software objects
    21 // (vsegs) on the physical memory banks (psegs).
     20// 3/ the mapping directives: both threads on processors, and software objects
     21// (vsegs) on physical memory banks (psegs).
    2222//
    2323// The mapping_info data structure is organised as the concatenation of
     
    2828// - mapping_vspace_t   vspace[] 
    2929// - mapping_vseg_t     vseg[]     
    30 // - mapping_task_t     task[] 
     30// - mapping_thread_t   thread[] 
    3131// - mapping_proc_t     proc[] 
    3232// - mapping_irq_t      irq[]   
     
    4444#define MAPPING_VSEG_SIZE     sizeof(mapping_vseg_t)
    4545#define MAPPING_PSEG_SIZE     sizeof(mapping_pseg_t)
    46 #define MAPPING_TASK_SIZE     sizeof(mapping_task_t)
     46#define MAPPING_THREAD_SIZE   sizeof(mapping_thread_t)
    4747#define MAPPING_PROC_SIZE     sizeof(mapping_proc_t)
    4848#define MAPPING_IRQ_SIZE      sizeof(mapping_irq_t)
     
    152152    unsigned int    psegs;           // total number of physical segments
    153153    unsigned int    vsegs;           // total number of virtual segments
    154     unsigned int    tasks;           // total number of tasks
     154    unsigned int    threads;         // total number of threads
    155155    unsigned int    procs;           // total number of processors
    156156    unsigned int    irqs;            // total number of irqs
    157157    unsigned int    periphs;         // total number of peripherals
    158     char name[64];                   // mapping name
     158    char name[256];                  // mapping name
    159159} mapping_header_t;
    160160
     
    183183    unsigned int    start_vseg_id;   // vseg containing start vector index
    184184    unsigned int    vsegs;           // number of vsegs in vspace
    185     unsigned int    tasks;           // number of tasks in vspace
     185    unsigned int    threads;         // number of threads in vspace
    186186    unsigned int    vseg_offset;     // global index of first vseg in vspace
    187     unsigned int    task_offset;     // global index of first task in vspace
     187    unsigned int    thread_offset;   // global index of first thread in vspace
    188188    unsigned int    active;          // always active if non zero
    189189} mapping_vspace_t;
     
    220220
    221221
    222 //////////////////////////////////////////////////////
    223 typedef struct __attribute__((packed))  mapping_task_s
    224 {
    225     char            name[32];        // task name (unique in vspace)
     222////////////////////////////////////////////////////////
     223typedef struct __attribute__((packed))  mapping_thread_s
     224{
     225    char            name[32];        // thread name (unique in vspace)
    226226    unsigned int    clusterid;       // global index in clusters set
    227227    unsigned int    proclocid;       // processor local index (inside cluster)
    228     unsigned int    trdid;           // thread index in vspace
     228    unsigned int    is_main;         // this thread is the application entry point
    229229    unsigned int    stack_vseg_id;   // global index for vseg containing stack
    230230    unsigned int    heap_vseg_id;    // global index for vseg containing heap
    231231    unsigned int    startid;         // index in start_vector
    232     unsigned int    ltid;            // task index in scheduler (dynamically defined)
    233 } mapping_task_t;
     232    unsigned int    ltid;            // thread index in scheduler (dynamically defined)
     233} mapping_thread_t;
    234234
    235235
  • soft/giet_vm/giet_xml/xml_driver.c

    r645 r709  
    126126    unsigned int pseg_id;
    127127    unsigned int vseg_id;
    128     unsigned int task_id;
     128    unsigned int thread_id;
    129129    unsigned int proc_id;
    130130    unsigned int irq_id;
     
    135135    mapping_vspace_t * vspace;
    136136    mapping_vseg_t * vseg;
    137     mapping_task_t * task;
     137    mapping_thread_t * thread;
    138138    mapping_irq_t * irq;   
    139139    mapping_periph_t * periph;
     
    161161            MAPPING_VSPACE_SIZE * header->vspaces);
    162162
    163     // computes the base address for tasks array
    164     task = (mapping_task_t *) ((char *) header +
     163    // computes the base address for threads array
     164    thread = (mapping_thread_t *) ((char *) header +
    165165            MAPPING_HEADER_SIZE +
    166166            MAPPING_CLUSTER_SIZE * header->x_size * header->y_size +
     
    176176            MAPPING_VSPACE_SIZE * header->vspaces +
    177177            MAPPING_VSEG_SIZE * header->vsegs +
    178             MAPPING_TASK_SIZE * header->tasks +
     178            MAPPING_THREAD_SIZE * header->threads +
    179179            MAPPING_PROC_SIZE * header->procs);
    180180
     
    186186            MAPPING_VSPACE_SIZE * header->vspaces +
    187187            MAPPING_VSEG_SIZE * header->vsegs +
    188             MAPPING_TASK_SIZE * header->tasks +
     188            MAPPING_THREAD_SIZE * header->threads +
    189189            MAPPING_PROC_SIZE * header->procs +
    190190            MAPPING_IRQ_SIZE * header->irqs);
     
    342342        }
    343343
    344         //////////////////// tasks //////////////////////////////////////////////
    345 
    346         for (task_id = vspace[vspace_id].task_offset;
    347              task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks);
    348              task_id++)
     344        //////////////////// threads //////////////////////////////////////////////
     345
     346        for (thread_id = vspace[vspace_id].thread_offset;
     347             thread_id < (vspace[vspace_id].thread_offset + vspace[vspace_id].threads);
     348             thread_id++)
    349349        {
    350             unsigned int stack_vseg_id = task[task_id].stack_vseg_id;
    351             unsigned int heap_vseg_id  = task[task_id].heap_vseg_id;
    352             unsigned int cluster_id    = task[task_id].clusterid;
    353 
    354             fprintf(fpout, "            <task name=\"%s\"", task[task_id].name);
    355             fprintf(fpout, " trdid=\"%d\"", task[task_id].trdid);
     350            unsigned int stack_vseg_id = thread[thread_id].stack_vseg_id;
     351            unsigned int heap_vseg_id  = thread[thread_id].heap_vseg_id;
     352            unsigned int cluster_id    = thread[thread_id].clusterid;
     353
     354            fprintf(fpout, "            <thread name=\"%s\"", thread[thread_id].name);
     355            fprintf(fpout, " trdid=\"%d\"", thread[thread_id].trdid);
    356356            fprintf(fpout, " x=\"%d\"", cluster[cluster_id].x);
    357357            fprintf(fpout, " y=\"%d\"", cluster[cluster_id].y);
    358             fprintf(fpout, " p=\"%d\"", task[task_id].proclocid);
     358            fprintf(fpout, " p=\"%d\"", thread[thread_id].proclocid);
    359359            fprintf(fpout, "\n                 ");     
    360360            fprintf(fpout, " stackname=\"%s\"", vseg[stack_vseg_id].name);
    361361            if (heap_vseg_id != -1)
    362362            fprintf(fpout, " heapname=\"%s\"", vseg[heap_vseg_id].name);
    363             fprintf(fpout, " startid = \"%d\"", task[task_id].startid);
     363            fprintf(fpout, " startid = \"%d\"", thread[thread_id].startid);
    364364            fprintf(fpout, " />\n");
    365365        }
  • soft/giet_vm/giet_xml/xml_parser.c

    r645 r709  
    1111// 1) the multi-cluster/multi-processors hardware architecture description
    1212// 2) the various multi-threaded software applications
    13 // 3) the mapping directives bor both the tasks and the virtual segments.
     13// 3) the mapping directives bor both the threads and the virtual segments.
    1414// The corresponding C structures are defined in the "mapping_info.h" file.
    1515///////////////////////////////////////////////////////////////////////////////////////
     
    3131#define MAX_PSEGS      4096
    3232#define MAX_VSPACES    1024
    33 #define MAX_TASKS      4096
     33#define MAX_THREADS      4096
    3434#define MAX_VSEGS      4096
    3535#define MAX_PROCS      1024
     
    4848mapping_vspace_t *   vspace[MAX_VSPACES];    // vspace array
    4949mapping_vseg_t *     vseg[MAX_VSEGS];        // vseg array
    50 mapping_task_t *     task[MAX_TASKS];        // task array
     50mapping_thread_t *   thread[MAX_THREADS];      // thread array
    5151mapping_proc_t *     proc[MAX_PROCS];        // proc array
    5252mapping_irq_t *      irq[MAX_IRQS];          // irq array
     
    7272unsigned int vseg_loc_index = 0;
    7373
    74 unsigned int task_index = 0;
    75 unsigned int task_loc_index = 0;
     74unsigned int thread_index = 0;
     75unsigned int thread_loc_index = 0;
    7676
    7777
     
    275275
    276276
    277 //////////////////////////////////////
    278 void taskNode(xmlTextReaderPtr reader)
     277////////////////////////////////////////
     278void threadNode(xmlTextReaderPtr reader)
    279279{
    280280    unsigned int ok;
     
    285285    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
    286286
    287     if (task_index >= MAX_TASKS)
    288     {
    289         printf("[XML ERROR] The number of tasks is larger than %d\n", MAX_TASKS);
    290         exit(1);
    291     }
    292 
    293 #if XML_PARSER_DEBUG
    294 printf("   task %d\n", task_loc_index);
    295 #endif
    296 
    297     task[task_index] = (mapping_task_t *) malloc(sizeof(mapping_task_t));
     287    if (thread_index >= MAX_THREADS)
     288    {
     289        printf("[XML ERROR] The number of threads is larger than %d\n", MAX_THREADS);
     290        exit(1);
     291    }
     292
     293#if XML_PARSER_DEBUG
     294printf("   thread %d\n", thread_loc_index);
     295#endif
     296
     297    thread[thread_index] = (mapping_thread_t *) malloc(sizeof(mapping_thread_t));
    298298
    299299    ////////// get name attribute
     
    304304printf("      name      = %s\n", str);
    305305#endif
    306         strncpy( task[task_index]->name, str, 31 );
    307     }
    308     else
    309     {
    310         printf("[XML ERROR] illegal or missing <name> attribute for task (%d,%d)\n",
    311                 vspace_index, task_loc_index);
    312         exit(1);
    313     }
    314 
    315     ///////// get trdid attribute (optional)
    316     value = getIntValue(reader, "trdid", &ok);
    317 #if XML_PARSER_DEBUG
    318 printf("      trdid     = %d\n", value );
    319 #endif
    320     if ( ok ) task[task_index]->trdid = value;
    321     else      task[task_index]->trdid = task_loc_index;
     306        strncpy( thread[thread_index]->name, str, 31 );
     307    }
     308    else
     309    {
     310        printf("[XML ERROR] illegal or missing <name> for thread %d in vspace %d\n",
     311                thread_loc_index, vspace_index);
     312        exit(1);
     313    }
     314
     315    ///////// get is_main attribute
     316    value = getIntValue(reader, "is_main", &ok);
     317    if ( ok )
     318    {
     319#if XML_PARSER_DEBUG
     320printf("      is_main   = %d\n", value );
     321#endif
     322        thread[thread_index]->is_main = value;
     323    }
     324    else
     325    {
     326        printf("[XML ERROR] illegal or missing <is_main> for thread %d in vspace %d\n",
     327                thread_loc_index, vspace_index);
     328    }
    322329
    323330    ///////// get x coordinate
     
    328335    if ( !(ok && (x < header->x_size)) )
    329336    {
    330         printf("[XML ERROR] illegal or missing < x > attribute for task (%d,%d)\n",
    331                 vspace_index, task_loc_index);
     337        printf("[XML ERROR] illegal or missing < x > for thread %d in vspace %d)\n",
     338                thread_loc_index, vspace_index);
    332339        exit(1);
    333340    } 
     
    340347    if ( !(ok && (y < header->y_size)) )
    341348    {
    342         printf("[XML ERROR] illegal or missing < y > attribute for task (%d,%d)\n",
    343                 vspace_index, task_loc_index);
     349        printf("[XML ERROR] illegal or missing < y > for thread %d in vspace %d)\n",
     350                thread_loc_index, vspace_index);
    344351        exit(1);
    345352    } 
     
    352359    if( index >= 0 )
    353360    {
    354         task[task_index]->clusterid = index;
     361        thread[thread_index]->clusterid = index;
    355362    }
    356363    else
    357364    {
    358         printf("[XML ERROR] <clusterid> not found for task (%d,%d)\n",
    359                 vspace_index, task_loc_index);
     365        printf("[XML ERROR] <clusterid> not found for thread %d in vspace %d)\n",
     366                thread_loc_index, vspace_index);
    360367        exit(1);
    361368    }
     
    368375printf("      proclocid = %x\n", value);
    369376#endif
    370         if (value >= cluster[task[task_index]->clusterid]->procs)
    371         {
    372             printf("[XML ERROR] <proclocid> too large for task (%d,%d)\n",
    373                     vspace_index, task_loc_index);
     377        if (value >= cluster[thread[thread_index]->clusterid]->procs)
     378        {
     379            printf("[XML ERROR] <proclocid> too large for thread %d in vspace %d\n",
     380                    thread_loc_index, vspace_index);
    374381            exit(1);
    375382        }
    376         task[task_index]->proclocid = value;
     383        thread[thread_index]->proclocid = value;
    377384    } 
    378385    else
    379386    {
    380         printf("[XML ERROR] illegal or missing <p> attribute for task (%d,%d)\n",
    381                 vspace_index, task_loc_index);
     387        printf("[XML ERROR] illegal or missing < p > for thread %d in vspace %d)\n",
     388                thread_loc_index, vspace_index);
    382389        exit(1);
    383390    }
     
    396403printf("      stack_id  = %d\n", index);
    397404#endif
    398             task[task_index]->stack_vseg_id = index;
     405            thread[thread_index]->stack_vseg_id = index;
    399406        }
    400407        else
    401408        {
    402             printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n",
    403                     vspace_index, task_loc_index);
     409            printf("[XML ERROR] illegal or missing <stackname> for thread %d in vspace %d)\n",
     410                    thread_loc_index, vspace_index);
    404411            exit(1);
    405412        }
     
    407414    else
    408415    {
    409         printf("[XML ERROR] illegal or missing <stackname> for task (%d,%d)\n",
    410                 vspace_index, task_loc_index);
     416        printf("[XML ERROR] illegal or missing <stackname> for thread %d in vspace %d)\n",
     417                thread_loc_index, vspace_index);
    411418        exit(1);
    412419    }
     
    425432printf("      heap_id   = %d\n", index );
    426433#endif
    427             task[task_index]->heap_vseg_id = index;
     434            thread[thread_index]->heap_vseg_id = index;
    428435        }
    429436        else
    430437        {
    431             printf("[XML ERROR] illegal or missing <heapname> for task (%d,%d)\n",
    432                    vspace_index, task_loc_index);
     438            printf("[XML ERROR] illegal or missing <heapname> for thread %d in vspace %d)\n",
     439                   thread_loc_index, vspace_index);
    433440            exit(1);
    434441        }
     
    436443    else
    437444    {
    438         task[task_index]->heap_vseg_id = -1;
     445        thread[thread_index]->heap_vseg_id = -1;
    439446    }
    440447
     
    446453printf("      startid   = %x\n", value);
    447454#endif
    448         task[task_index]->startid = value;
     455        thread[thread_index]->startid = value;
    449456    } 
    450457    else
    451458    {
    452         printf("[XML ERROR] illegal or missing <startid> attribute for task (%d,%d)\n",
    453                 vspace_index, task_loc_index);
    454         exit(1);
    455     }
    456 
    457     task_index++;
    458     task_loc_index++;
    459 } // end taskNode()
     459        printf("[XML ERROR] illegal or missing <startid> for thread %d in vspace %d\n",
     460                thread_loc_index, vspace_index);
     461        exit(1);
     462    }
     463
     464    thread_index++;
     465    thread_loc_index++;
     466} // end threadNode()
    460467
    461468
     
    698705    unsigned int ok;
    699706
    700     vseg_loc_index = 0;
    701     task_loc_index = 0;
     707    vseg_loc_index   = 0;
     708    thread_loc_index = 0;
    702709
    703710    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return;
     
    727734    else    vspace[vspace_index]->active = 0;
    728735   
    729     ////////// set vseg_offset and task_offset attributes
     736    ////////// set vseg_offset and thread_offset attributes
    730737    vspace[vspace_index]->vseg_offset = vseg_index;
    731     vspace[vspace_index]->task_offset = task_index;
    732 
    733     ////////// initialise vsegs and tasks attributes
     738    vspace[vspace_index]->thread_offset = thread_index;
     739
     740    ////////// initialise vsegs and threads attributes
    734741    vspace[vspace_index]->vsegs = 0;
    735     vspace[vspace_index]->tasks = 0;
     742    vspace[vspace_index]->threads = 0;
    736743
    737744    ////////// get startname attribute
     
    754761            vspace[vspace_index]->vsegs += 1;
    755762        }
    756         else if (strcmp(tag, "task") == 0)
    757         {
    758             taskNode(reader);
    759             vspace[vspace_index]->tasks += 1;
     763        else if (strcmp(tag, "thread") == 0)
     764        {
     765            threadNode(reader);
     766            vspace[vspace_index]->threads += 1;
    760767        }
    761768        else if (strcmp(tag, "#text")    == 0) { }
     
    777784
    778785#if XML_PARSER_DEBUG
    779 printf("      vsegs       = %d\n", vspace[vspace_index]->vsegs );
    780 printf("      tasks       = %d\n", vspace[vspace_index]->tasks );
    781 printf("      vseg_offset = %d\n", vspace[vspace_index]->vseg_offset );
    782 printf("      task_offset = %d\n", vspace[vspace_index]->task_offset );
    783 printf("      start_id    = %d\n", vspace[vspace_index]->start_vseg_id );
    784 printf("      active      = %x\n", vspace[vspace_index]->active );
     786printf("      vsegs         = %d\n", vspace[vspace_index]->vsegs );
     787printf("      threads       = %d\n", vspace[vspace_index]->threads );
     788printf("      vseg_offset   = %d\n", vspace[vspace_index]->vseg_offset );
     789printf("      thread_offset = %d\n", vspace[vspace_index]->thread_offset );
     790printf("      start_id      = %d\n", vspace[vspace_index]->start_vseg_id );
     791printf("      active        = %x\n", vspace[vspace_index]->active );
    785792printf("  end vspace %d\n\n", vspace_index);
    786793#endif
     
    14881495        {
    14891496            header->vsegs = vseg_index;
    1490             header->tasks = task_index;
     1497            header->threads = thread_index;
    14911498            return;
    14921499        }
     
    16681675    header->psegs     = 0;
    16691676    header->vsegs     = 0;
    1670     header->tasks     = 0;
     1677    header->threads   = 0;
    16711678    header->procs     = 0;
    16721679    header->irqs      = 0;
     
    17651772printf("psegs     = %d\n", header->psegs);
    17661773printf("vsegs     = %d\n", header->vsegs);
    1767 printf("tasks     = %d\n", header->tasks);
     1774printf("threads   = %d\n", header->threads);
    17681775printf("procs     = %d\n", header->procs);
    17691776printf("irqs      = %d\n", header->irqs);
     
    17871794    // write vsegs
    17881795    BuildTable(fdout, "vseg", vseg_index, sizeof(mapping_vseg_t), (char **) vseg);
    1789     // write tasks array
    1790     BuildTable(fdout, "task", task_index, sizeof(mapping_task_t), (char **) task);
     1796    // write threads array
     1797    BuildTable(fdout, "thread", thread_index, sizeof(mapping_thread_t), (char **) thread);
    17911798    //building procs array
    17921799    BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char **) proc);
Note: See TracChangeset for help on using the changeset viewer.