Changeset 709 for soft/giet_vm/giet_xml/xml_parser.c
- Timestamp:
- Oct 1, 2015, 4:20:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_xml/xml_parser.c
r645 r709 11 11 // 1) the multi-cluster/multi-processors hardware architecture description 12 12 // 2) the various multi-threaded software applications 13 // 3) the mapping directives bor both the t asks and the virtual segments.13 // 3) the mapping directives bor both the threads and the virtual segments. 14 14 // The corresponding C structures are defined in the "mapping_info.h" file. 15 15 /////////////////////////////////////////////////////////////////////////////////////// … … 31 31 #define MAX_PSEGS 4096 32 32 #define MAX_VSPACES 1024 33 #define MAX_T ASKS 409633 #define MAX_THREADS 4096 34 34 #define MAX_VSEGS 4096 35 35 #define MAX_PROCS 1024 … … 48 48 mapping_vspace_t * vspace[MAX_VSPACES]; // vspace array 49 49 mapping_vseg_t * vseg[MAX_VSEGS]; // vseg array 50 mapping_t ask_t * task[MAX_TASKS]; // taskarray50 mapping_thread_t * thread[MAX_THREADS]; // thread array 51 51 mapping_proc_t * proc[MAX_PROCS]; // proc array 52 52 mapping_irq_t * irq[MAX_IRQS]; // irq array … … 72 72 unsigned int vseg_loc_index = 0; 73 73 74 unsigned int t ask_index = 0;75 unsigned int t ask_loc_index = 0;74 unsigned int thread_index = 0; 75 unsigned int thread_loc_index = 0; 76 76 77 77 … … 275 275 276 276 277 ////////////////////////////////////// 278 void t askNode(xmlTextReaderPtr reader)277 //////////////////////////////////////// 278 void threadNode(xmlTextReaderPtr reader) 279 279 { 280 280 unsigned int ok; … … 285 285 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return; 286 286 287 if (t ask_index >= MAX_TASKS)288 { 289 printf("[XML ERROR] The number of t asks is larger than %d\n", MAX_TASKS);290 exit(1); 291 } 292 293 #if XML_PARSER_DEBUG 294 printf(" t ask %d\n", task_loc_index);295 #endif 296 297 t ask[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 294 printf(" thread %d\n", thread_loc_index); 295 #endif 296 297 thread[thread_index] = (mapping_thread_t *) malloc(sizeof(mapping_thread_t)); 298 298 299 299 ////////// get name attribute … … 304 304 printf(" name = %s\n", str); 305 305 #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 320 printf(" 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 } 322 329 323 330 ///////// get x coordinate … … 328 335 if ( !(ok && (x < header->x_size)) ) 329 336 { 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); 332 339 exit(1); 333 340 } … … 340 347 if ( !(ok && (y < header->y_size)) ) 341 348 { 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); 344 351 exit(1); 345 352 } … … 352 359 if( index >= 0 ) 353 360 { 354 t ask[task_index]->clusterid = index;361 thread[thread_index]->clusterid = index; 355 362 } 356 363 else 357 364 { 358 printf("[XML ERROR] <clusterid> not found for t ask (%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); 360 367 exit(1); 361 368 } … … 368 375 printf(" proclocid = %x\n", value); 369 376 #endif 370 if (value >= cluster[t ask[task_index]->clusterid]->procs)371 { 372 printf("[XML ERROR] <proclocid> too large for t ask (%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); 374 381 exit(1); 375 382 } 376 t ask[task_index]->proclocid = value;383 thread[thread_index]->proclocid = value; 377 384 } 378 385 else 379 386 { 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); 382 389 exit(1); 383 390 } … … 396 403 printf(" stack_id = %d\n", index); 397 404 #endif 398 t ask[task_index]->stack_vseg_id = index;405 thread[thread_index]->stack_vseg_id = index; 399 406 } 400 407 else 401 408 { 402 printf("[XML ERROR] illegal or missing <stackname> for t ask (%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); 404 411 exit(1); 405 412 } … … 407 414 else 408 415 { 409 printf("[XML ERROR] illegal or missing <stackname> for t ask (%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); 411 418 exit(1); 412 419 } … … 425 432 printf(" heap_id = %d\n", index ); 426 433 #endif 427 t ask[task_index]->heap_vseg_id = index;434 thread[thread_index]->heap_vseg_id = index; 428 435 } 429 436 else 430 437 { 431 printf("[XML ERROR] illegal or missing <heapname> for t ask (%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); 433 440 exit(1); 434 441 } … … 436 443 else 437 444 { 438 t ask[task_index]->heap_vseg_id = -1;445 thread[thread_index]->heap_vseg_id = -1; 439 446 } 440 447 … … 446 453 printf(" startid = %x\n", value); 447 454 #endif 448 t ask[task_index]->startid = value;455 thread[thread_index]->startid = value; 449 456 } 450 457 else 451 458 { 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 t ask_index++;458 t ask_loc_index++;459 } // end t askNode()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() 460 467 461 468 … … 698 705 unsigned int ok; 699 706 700 vseg_loc_index = 0;701 t ask_loc_index = 0;707 vseg_loc_index = 0; 708 thread_loc_index = 0; 702 709 703 710 if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT) return; … … 727 734 else vspace[vspace_index]->active = 0; 728 735 729 ////////// set vseg_offset and t ask_offset attributes736 ////////// set vseg_offset and thread_offset attributes 730 737 vspace[vspace_index]->vseg_offset = vseg_index; 731 vspace[vspace_index]->t ask_offset = task_index;732 733 ////////// initialise vsegs and t asks attributes738 vspace[vspace_index]->thread_offset = thread_index; 739 740 ////////// initialise vsegs and threads attributes 734 741 vspace[vspace_index]->vsegs = 0; 735 vspace[vspace_index]->t asks = 0;742 vspace[vspace_index]->threads = 0; 736 743 737 744 ////////// get startname attribute … … 754 761 vspace[vspace_index]->vsegs += 1; 755 762 } 756 else if (strcmp(tag, "t ask") == 0)757 { 758 t askNode(reader);759 vspace[vspace_index]->t asks += 1;763 else if (strcmp(tag, "thread") == 0) 764 { 765 threadNode(reader); 766 vspace[vspace_index]->threads += 1; 760 767 } 761 768 else if (strcmp(tag, "#text") == 0) { } … … 777 784 778 785 #if XML_PARSER_DEBUG 779 printf(" vsegs = %d\n", vspace[vspace_index]->vsegs );780 printf(" t asks = %d\n", vspace[vspace_index]->tasks );781 printf(" vseg_offset = %d\n", vspace[vspace_index]->vseg_offset );782 printf(" t ask_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 );786 printf(" vsegs = %d\n", vspace[vspace_index]->vsegs ); 787 printf(" threads = %d\n", vspace[vspace_index]->threads ); 788 printf(" vseg_offset = %d\n", vspace[vspace_index]->vseg_offset ); 789 printf(" thread_offset = %d\n", vspace[vspace_index]->thread_offset ); 790 printf(" start_id = %d\n", vspace[vspace_index]->start_vseg_id ); 791 printf(" active = %x\n", vspace[vspace_index]->active ); 785 792 printf(" end vspace %d\n\n", vspace_index); 786 793 #endif … … 1488 1495 { 1489 1496 header->vsegs = vseg_index; 1490 header->t asks = task_index;1497 header->threads = thread_index; 1491 1498 return; 1492 1499 } … … 1668 1675 header->psegs = 0; 1669 1676 header->vsegs = 0; 1670 header->t asks= 0;1677 header->threads = 0; 1671 1678 header->procs = 0; 1672 1679 header->irqs = 0; … … 1765 1772 printf("psegs = %d\n", header->psegs); 1766 1773 printf("vsegs = %d\n", header->vsegs); 1767 printf("t asks = %d\n", header->tasks);1774 printf("threads = %d\n", header->threads); 1768 1775 printf("procs = %d\n", header->procs); 1769 1776 printf("irqs = %d\n", header->irqs); … … 1787 1794 // write vsegs 1788 1795 BuildTable(fdout, "vseg", vseg_index, sizeof(mapping_vseg_t), (char **) vseg); 1789 // write t asks array1790 BuildTable(fdout, "t ask", task_index, sizeof(mapping_task_t), (char **) task);1796 // write threads array 1797 BuildTable(fdout, "thread", thread_index, sizeof(mapping_thread_t), (char **) thread); 1791 1798 //building procs array 1792 1799 BuildTable(fdout, "proc", proc_index, sizeof(mapping_proc_t), (char **) proc);
Note: See TracChangeset
for help on using the changeset viewer.