Changeset 263 for soft/giet_vm/giet_xml
- Timestamp:
- Dec 19, 2013, 9:36:48 AM (11 years ago)
- Location:
- soft/giet_vm/giet_xml
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_xml/mapping_info.h
r258 r263 132 132 { 133 133 unsigned int signature; // must contain MAPPING_SIGNATURE 134 unsigned int clusters; // number of clusters 135 unsigned int cluster_x; // number of cluster in a row 136 unsigned int cluster_y; // number of cluster in a column 134 unsigned int x_size; // actual number of clusters in a row 135 unsigned int y_size; // actual number of clusters in a column 136 unsigned int x_width; // number of bits to encode x coordinate 137 unsigned int y_width; // number of bits to encode y coordinate 137 138 unsigned int globals; // number of vsegs mapped in all vspaces 138 139 unsigned int vspaces; // number of virtual spaces … … 183 184 typedef struct __attribute__((packed)) mapping_cluster_s 184 185 { 186 unsigned int x; // x coordinate 187 unsigned int y; // y coordinate 188 185 189 unsigned int psegs; // number of psegs in cluster 186 190 unsigned int pseg_offset; // index of first pseg in pseg set … … 237 241 paddr_t length; // size (bytes) 238 242 unsigned int type; // RAM / PERI 239 unsigned int cluster ; // index of cluster containing pseg243 unsigned int clusterid; // linear index in array of clusters 240 244 unsigned int next_vseg; // linked list of vsegs mapped on pseg 241 245 } mapping_pseg_t; … … 246 250 { 247 251 char name[32]; // task name (unique in vspace) 248 unsigned int clusterid; // physical cluster index252 unsigned int clusterid; // linear index in array of clusters 249 253 unsigned int proclocid; // processor local index (inside cluster) 250 254 unsigned int stack_vobjid; // stack vobj index in vspace -
soft/giet_vm/giet_xml/xml_driver.c
r258 r263 133 133 pseg = (mapping_pseg_t *) ((char *) header + 134 134 MAPPING_HEADER_SIZE + 135 MAPPING_CLUSTER_SIZE * header-> clusters);135 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size); 136 136 137 137 // computes the base adresss for vspaces array, 138 138 vspace = (mapping_vspace_t *) ((char *) header + 139 139 MAPPING_HEADER_SIZE + 140 MAPPING_CLUSTER_SIZE * header-> clusters+140 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + 141 141 MAPPING_PSEG_SIZE * header->psegs); 142 142 … … 144 144 vseg = (mapping_vseg_t *) ((char *) header + 145 145 MAPPING_HEADER_SIZE + 146 MAPPING_CLUSTER_SIZE * header-> clusters+146 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + 147 147 MAPPING_PSEG_SIZE * header->psegs + 148 148 MAPPING_VSPACE_SIZE * header->vspaces); … … 151 151 vobj = (mapping_vobj_t *) ((char *) header + 152 152 MAPPING_HEADER_SIZE + 153 MAPPING_CLUSTER_SIZE * header-> clusters+153 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + 154 154 MAPPING_PSEG_SIZE * header->psegs + 155 155 MAPPING_VSPACE_SIZE * header->vspaces + … … 159 159 task = (mapping_task_t *) ((char *) header + 160 160 MAPPING_HEADER_SIZE + 161 MAPPING_CLUSTER_SIZE * header-> clusters+161 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + 162 162 MAPPING_PSEG_SIZE * header->psegs + 163 163 MAPPING_VSPACE_SIZE * header->vspaces + … … 168 168 proc = (mapping_proc_t *) ((char *) header + 169 169 MAPPING_HEADER_SIZE + 170 MAPPING_CLUSTER_SIZE * header-> clusters+170 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + 171 171 MAPPING_PSEG_SIZE * header->psegs + 172 172 MAPPING_VSPACE_SIZE * header->vspaces + … … 178 178 irq = (mapping_irq_t *) ((char *) header + 179 179 MAPPING_HEADER_SIZE + 180 MAPPING_CLUSTER_SIZE * header-> clusters+180 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + 181 181 MAPPING_PSEG_SIZE * header->psegs + 182 182 MAPPING_VSPACE_SIZE * header->vspaces + … … 189 189 coproc = (mapping_coproc_t *) ((char *) header + 190 190 MAPPING_HEADER_SIZE + 191 MAPPING_CLUSTER_SIZE * header-> clusters+191 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + 192 192 MAPPING_PSEG_SIZE * header->psegs + 193 193 MAPPING_VSPACE_SIZE * header->vspaces + … … 201 201 cp_port = (mapping_cp_port_t *) ((char *) header + 202 202 MAPPING_HEADER_SIZE + 203 MAPPING_CLUSTER_SIZE * header-> clusters+203 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + 204 204 MAPPING_PSEG_SIZE * header->psegs + 205 205 MAPPING_VSPACE_SIZE * header->vspaces + … … 214 214 periph = (mapping_periph_t *) ((char *) header + 215 215 MAPPING_HEADER_SIZE + 216 MAPPING_CLUSTER_SIZE * header-> clusters+216 MAPPING_CLUSTER_SIZE * header->x_size * header->y_size + 217 217 MAPPING_PSEG_SIZE * header->psegs + 218 218 MAPPING_VSPACE_SIZE * header->vspaces + … … 229 229 fprintf(fpout, "<?xml version = \"1.0\"?>\n\n"); 230 230 231 fprintf(fpout, "<mapping_info signature = \"0x%x\" ", header->signature); 232 fprintf(fpout, " name = \"%s\" ", header->name); 233 fprintf(fpout, " cluster_x = \"%d\" ", header->cluster_x); 234 fprintf(fpout, " cluster_y = \"%d\" ", header->cluster_y); 235 fprintf(fpout, " vspaces = \"%d\" >\n\n", header->vspaces); 231 fprintf(fpout, "<mapping_info signature = \"0x%x\" \n", header->signature); 232 fprintf(fpout, " name = \"%s\" \n", header->name); 233 fprintf(fpout, " x_size = \"%d\" \n", header->x_size); 234 fprintf(fpout, " y_size = \"%d\" \n", header->y_size); 235 fprintf(fpout, " x_width = \"%d\" \n", header->x_width); 236 fprintf(fpout, " y_width = \"%d\" \n", header->y_width); 237 fprintf(fpout, " vspaces = \"%d\" \n", header->vspaces); 238 fprintf(fpout, " increment = \"%d\" >\n\n", header->vspaces); 236 239 237 240 ///////////////////// clusters /////////////////////////////////////////////// 238 241 239 242 fprintf( fpout, " <clusterset>\n"); 240 for (cluster_id = 0; cluster_id < header->clusters; cluster_id++) 241 { 242 fprintf(fpout, " <cluster index = \"%d\" >\n", cluster_id); 243 for (cluster_id = 0; cluster_id < (header->x_size * header->y_size); cluster_id++) 244 { 245 fprintf(fpout, " <cluster x = \"%d\" y = \"%d\" >\n", 246 cluster[cluster_id].x, cluster[cluster_id].y ); 247 248 ///////////////////// psegs //////////////////////////////////////////////// 249 243 250 for (pseg_id = cluster[cluster_id].pseg_offset; 244 251 pseg_id < cluster[cluster_id].pseg_offset + cluster[cluster_id].psegs; … … 246 253 { 247 254 fprintf(fpout, " <pseg name = \"%s\" ", pseg[pseg_id].name); 248 fprintf(fpout, " 249 fprintf(fpout, " 250 fprintf(fpout, " 255 fprintf(fpout, "type = \"%s\" ", pseg_type[pseg[pseg_id].type]); 256 fprintf(fpout, "base = \"0x%llx\" ", pseg[pseg_id].base); 257 fprintf(fpout, "length = \"0x%llx\" />\n", pseg[pseg_id].length); 251 258 } 252 259 … … 316 323 fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase); 317 324 fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); 318 fprintf(fpout, "clusterid = \"%d\" ", pseg[pseg_id].cluster );325 fprintf(fpout, "clusterid = \"%d\" ", pseg[pseg_id].clusterid); 319 326 fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); 320 327 fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); … … 343 350 fprintf(fpout, " startname = \"%s\" >\n", vobj[func_id].name); 344 351 352 //////////////////// vsegs ////////////////////////////////////////////// 353 345 354 for (vseg_id = vspace[vspace_id].vseg_offset; 346 355 vseg_id < (vspace[vspace_id].vseg_offset + vspace[vspace_id].vsegs); 347 356 vseg_id++) 348 357 { 349 unsigned int pseg_id = vseg[vseg_id].psegid; 358 unsigned int pseg_id = vseg[vseg_id].psegid; 359 unsigned int cluster_id = pseg[pseg_id].clusterid; 360 unsigned int x = cluster_id >> header->y_width; 361 unsigned int y = cluster_id & ((1<<header->y_width)-1); 350 362 351 363 fprintf(fpout, " <vseg name = \"%s\" ", vseg[vseg_id].name); 352 364 fprintf(fpout, "vbase = \"0x%x\" ", vseg[vseg_id].vbase); 353 fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); 354 fprintf(fpout, "clusterid = \"%d\" ", pseg[pseg_id].cluster); 365 fprintf(fpout, "mode = \"%s\" ", mode_str[vseg[vseg_id].mode]); 366 fprintf(fpout, "x = \"%d\" ", x); 367 fprintf(fpout, "y = \"%d\" ", y); 355 368 fprintf(fpout, "psegname = \"%s\" ", pseg[pseg_id].name); 356 369 fprintf(fpout, "ident = \"%d\" >\n", vseg[vseg_id].ident); … … 369 382 fprintf(fpout, " </vseg>\n\n"); 370 383 } 384 385 //////////////////// tasks ////////////////////////////////////////////// 386 371 387 for (task_id = vspace[vspace_id].task_offset; 372 388 task_id < (vspace[vspace_id].task_offset + vspace[vspace_id].tasks); … … 375 391 unsigned int stack_vobj_id = task[task_id].stack_vobjid + vspace[vspace_id].vobj_offset; 376 392 unsigned int heap_vobj_id = task[task_id].heap_vobjid + vspace[vspace_id].vobj_offset; 393 unsigned int cluster_id = task[task_id].clusterid; 394 unsigned int x = cluster_id >> header->y_width; 395 unsigned int y = cluster_id & ((1<<header->y_width)-1); 377 396 378 397 fprintf(fpout, " <task name = \"%s\" ", task[task_id].name); 379 fprintf(fpout, "clusterid = \"%d\" ", task[task_id].clusterid); 398 fprintf(fpout, "x = \"%d\" ", x); 399 fprintf(fpout, "y = \"%d\" ", y); 380 400 fprintf(fpout, "proclocid = \"%d\" ", task[task_id].proclocid); 381 401 fprintf(fpout, "stackname = \"%s\" ", vobj[stack_vobj_id].name); -
soft/giet_vm/giet_xml/xml_parser.c
r262 r263 109 109 //////////////////////////////////////////////////////////////////// 110 110 111 unsigned int cluster_y = 0; // number of clusters in a column112 unsigned int cluster_x = 0; // number of clusters in a row113 111 unsigned int nb_proc_max = 0; // max number of processors per cluster 114 unsigned int nb_tasks_max = 0; // max number of tasks ( forall vspaces)112 unsigned int nb_tasks_max = 0; // max number of tasks (in all vspaces) 115 113 116 114 unsigned int tim_channels = 0; // max number of user timers (per cluster) … … 132 130 133 131 unsigned int periph_vbase_array[PERIPH_TYPE_MAX_VALUE] 134 = { [0 ... (PERIPH_TYPE_MAX_VALUE - 1)] = 0xFFF 00000};132 = { [0 ... (PERIPH_TYPE_MAX_VALUE - 1)] = 0xFFFFFFFF }; 135 133 136 134 ////////////////////////////////////////////////////////////////////// … … 283 281 // This function set the vbase address for all peripheral types. 284 282 // For replicated peripherals with the same type the virtual base address must be: 285 // vbase = seg_type_base & 0XFF F00000 +286 // (cluster_id * vbase_cluster_increment) & 0x00 0FFFFF283 // vbase = seg_type_base & 0XFF000000 + 284 // (cluster_id * vbase_cluster_increment) & 0x00FF0000 287 285 /////////////////////////////////////////////////////////////////////////////////// 288 286 void set_periph_vbase_array() … … 291 289 unsigned int periph_id; // periph global index 292 290 unsigned int pseg_id; // pseg global index 293 unsigned int cluster_id; // cluster global index 291 unsigned int cluster_id; // cluster linear index 292 unsigned int cluster_xy; // cluster topological index 294 293 unsigned int type; // peripheral type 295 294 296 unsigned int msb_mask = 0xFFF00000; 297 unsigned int lsb_mask = 0x000FFFFF; 298 299 // We are looking for any vseg matching a peripheral 300 // (i.e. they are associated to the same pseg) 295 unsigned int type_mask = 0xFF000000; 296 unsigned int cluster_mask = 0x00FF0000; 297 298 // We are analysing all vsegs corresponding to a peripheral 301 299 302 300 // scan all vsegs … … 306 304 if ( vobj[vseg[vseg_id]->vobj_offset]->type == VOBJ_TYPE_PERI ) 307 305 { 308 pseg_id = vseg[vseg_id]->psegid; 309 cluster_id = pseg[pseg_id]->cluster; 310 311 // scan all periphs 306 pseg_id = vseg[vseg_id]->psegid; 307 308 // scan all periphs to retrieve peripheral type (same psegid) 312 309 for ( periph_id = 0 ; periph_id < header->periphs ; periph_id++) 313 310 { … … 315 312 { 316 313 type = periph[periph_id]->type; 317 if ( periph_vbase_array[type] == 0xFFF 00000) // vbase not set314 if ( periph_vbase_array[type] == 0xFFFFFFFF ) // vbase not set 318 315 { 319 periph_vbase_array[type] = vseg[vseg_id]->vbase ;316 periph_vbase_array[type] = vseg[vseg_id]->vbase & type_mask; 320 317 } 321 318 else // vbase already set 322 319 { 323 // checking 12 MSB bits for replicated peripherals324 if( (vseg[vseg_id]->vbase & msb_mask) !=325 (periph_vbase_array[type] & msb_mask) )320 // checking mask bits 321 if( (vseg[vseg_id]->vbase & type_mask) != 322 (periph_vbase_array[type]) ) 326 323 { 327 324 printf("[XML ERROR] All peripherals with same type "); 328 printf(" should share the same 12 MSB for vbase address\n"); 329 printf("periph index = %d / periph type = %d / vbase = %x\n", 330 periph_id, type, vseg[vseg_id]->vbase); 331 exit(1); 332 } 333 // checking 20 LSB bits for replicated peripherals 334 if( (vseg[vseg_id]->vbase & lsb_mask) != 335 (header->increment * cluster_id) ) 336 { 337 printf("[XML ERROR] All peripherals with same type "); 338 printf(" must have the 20 LSB bits = cluster_id * increment"); 325 printf(" should share the same 8 MSB bits in base address\n"); 339 326 printf("periph index = %d / periph type = %d / vbase = %x\n", 340 327 periph_id, type, vseg[vseg_id]->vbase); … … 342 329 } 343 330 } 331 332 // checking cluster bits for all replicated peripherals 333 if ( (type == PERIPH_TYPE_DMA) || 334 (type == PERIPH_TYPE_MMC) || 335 (type == PERIPH_TYPE_ICU) || 336 (type == PERIPH_TYPE_XCU) || 337 (type == PERIPH_TYPE_TIM) ) 338 { 339 cluster_id = pseg[pseg_id]->clusterid; 340 cluster_xy = (cluster[cluster_id]->x << header->y_width) + 341 cluster[cluster_id]->y; 342 343 if( (vseg[vseg_id]->vbase & cluster_mask) != 344 (header->increment * cluster_xy) ) 345 { 346 printf("[XML ERROR] All replicated peripherals "); 347 printf("must have cluster bits = cluster_id * increment"); 348 printf("periph index = %d / periph type = %d / vbase = %x\n", 349 periph_id, type, vseg[vseg_id]->vbase); 350 exit(1); 351 } 352 } 344 353 } 345 354 } … … 348 357 } // end set_periph_vbase_array() 349 358 350 //////////////////////////////////////////////////////// 351 int getPsegId(unsigned int cluster_id, char * pseg_name) 352 { 359 /////////////////////////////////////////////////////////////// 360 int getClusterId( unsigned int x, unsigned int y ) 361 { 362 // associative search of cluster index 363 unsigned int cluster_id; 364 365 for( cluster_id = 0 ; cluster_id < (header->x_size * header->y_size) ; cluster_id++ ) 366 { 367 if( (cluster[cluster_id]->x == x) && (cluster[cluster_id]->y == y) ) 368 { 369 return cluster_id; 370 } 371 } 372 return -1; 373 } // end getClusterId() 374 375 /////////////////////////////////////////////////////////////// 376 int getPsegId(unsigned int x, unsigned int y, char * pseg_name) 377 { 378 int cluster_id = getClusterId( x, y ); 379 380 if ( cluster_id == -1 ) return -1; 381 382 // associative search for pseg index 353 383 unsigned int pseg_id; 354 384 unsigned int pseg_min = cluster[cluster_id]->pseg_offset; … … 363 393 } 364 394 return -1; 365 } 395 } // end getPsegId() 366 396 367 397 /////////////////////////////////// … … 399 429 unsigned int ok; 400 430 unsigned int value; 431 unsigned int x,y; 401 432 char * str; 402 433 … … 420 451 { 421 452 #if XML_PARSER_DEBUG 422 printf(" name = %s\n", str);453 printf(" name = %s\n", str); 423 454 #endif 424 455 strncpy( task[task_index]->name, str, 31 ); … … 431 462 } 432 463 433 ///////// get clusterid attribute 434 value = getIntValue(reader, "clusterid", &ok); 435 if (ok) 436 { 437 #if XML_PARSER_DEBUG 438 printf(" clusterid = %x\n", value); 439 #endif 440 if (value >= header->clusters) 441 { 442 printf("[XML ERROR] <clusterid> too large for task (%d,%d)\n", 443 vspace_index, task_loc_index); 444 exit(1); 445 } 446 task[task_index]->clusterid = value; 464 ///////// get x coordinate 465 x = getIntValue(reader, "x", &ok); 466 #if XML_PARSER_DEBUG 467 printf(" x = %d\n", x); 468 #endif 469 if ( !(ok && (x < header->x_size)) ) 470 { 471 printf("[XML ERROR] illegal or missing < x > attribute for task (%d,%d)\n", 472 vspace_index, task_loc_index); 473 exit(1); 447 474 } 448 else 449 { 450 printf("[XML ERROR] illegal or missing <clusterid> attribute for task (%d,%d)\n", 475 476 ///////// get y coordinate 477 y = getIntValue(reader, "y", &ok); 478 #if XML_PARSER_DEBUG 479 printf(" y = %d\n", y); 480 #endif 481 if ( !(ok && (y < header->y_size)) ) 482 { 483 printf("[XML ERROR] illegal or missing < y > attribute for task (%d,%d)\n", 484 vspace_index, task_loc_index); 485 exit(1); 486 } 487 488 ///////// set clusterid attribute 489 int index = getClusterId( x, y ); 490 #if XML_PARSER_DEBUG 491 printf(" clusterid = %d\n", index); 492 #endif 493 if( index >= 0 ) 494 { 495 task[task_index]->clusterid = index; 496 } 497 else 498 { 499 printf("[XML ERROR] <clusterid> not found for task (%d,%d)\n", 451 500 vspace_index, task_loc_index); 452 501 exit(1); … … 510 559 { 511 560 #if XML_PARSER_DEBUG 512 printf(" heapname = %s\n", str);513 printf(" heapid = %d\n", index);561 printf(" heapname = %s\n", str); 562 printf(" heapid = %d\n", index); 514 563 #endif 515 564 task[task_index]->heap_vobjid = index; … … 527 576 } 528 577 529 530 578 ////////// get startid attribute 531 579 value = getIntValue(reader, "startid", &ok); … … 533 581 { 534 582 #if XML_PARSER_DEBUG 535 printf(" startid = %x\n", value);583 printf(" startid = %x\n", value); 536 584 #endif 537 585 task[task_index]->startid = value; … … 724 772 unsigned int ok; 725 773 unsigned int value; 774 unsigned int x,y; 726 775 char * str; 727 776 … … 760 809 { 761 810 #if XML_PARSER_DEBUG 762 printf(" name = %s\n", str);811 printf(" name = %s\n", str); 763 812 #endif 764 813 strncpy( vseg[vseg_index]->name, str, 31); … … 776 825 { 777 826 #if XML_PARSER_DEBUG 778 printf(" ident = %d\n", value);827 printf(" ident = %d\n", value); 779 828 #endif 780 829 vseg[vseg_index]->ident = value; … … 790 839 { 791 840 #if XML_PARSER_DEBUG 792 printf(" vbase = 0x%x\n", value);841 printf(" vbase = 0x%x\n", value); 793 842 #endif 794 843 vseg[vseg_index]->vbase = value; … … 801 850 } 802 851 803 ////////// get clusterid and psegname attributes 804 value = getIntValue(reader, "clusterid", &ok); 805 if (ok == 0) 806 { 807 printf("[XML ERROR] illegal or missing <clusterid> for vseg %d\n", 852 ////////// get x coordinate 853 x = getIntValue(reader, "x", &ok); 854 #if XML_PARSER_DEBUG 855 printf(" x = %d\n", x); 856 #endif 857 if ( !(ok && (x < header->x_size)) ) 858 { 859 printf("[XML ERROR] illegal or missing < x > attribute for vseg %d\n", 808 860 vseg_loc_index); 809 861 exit(1); 810 862 } 863 864 ////////// get y coordinate 865 y = getIntValue(reader, "y", &ok); 866 #if XML_PARSER_DEBUG 867 printf(" y = %d\n", y); 868 #endif 869 if ( !(ok && (y < header->y_size)) ) 870 { 871 printf("[XML ERROR] illegal or missing < y > attribute for vseg %d\n", 872 vseg_loc_index); 873 exit(1); 874 } 875 876 ///////// get psegname attribute 811 877 str = getStringValue(reader, "psegname", &ok); 878 #if XML_PARSER_DEBUG 879 printf(" psegname = %s\n", str); 880 #endif 812 881 if (ok == 0) 813 882 { … … 818 887 819 888 /////////// set psegid field 820 int index = getPsegId(value, str); 889 int psegid = getPsegId( x, y, str ); 890 #if XML_PARSER_DEBUG 891 printf(" psegid = %d\n", psegid); 892 #endif 821 893 if (index >= 0) 822 894 { 823 #if XML_PARSER_DEBUG 824 printf(" clusterid = %d\n", value); 825 printf(" psegname = %s\n", str); 826 printf(" psegid = %d\n", index); 827 #endif 828 vseg[vseg_index]->psegid = index; 829 } 830 else 831 { 832 printf("[XML ERROR] pseg not found for vseg %d / clusterid = %d / psegname = %s\n", 833 vseg_loc_index, value, str ); 895 vseg[vseg_index]->psegid = psegid; 896 } 897 else 898 { 899 printf("[XML ERROR] pseg not found for vseg %d / x = %d / y = %d / psegname = %s\n", 900 vseg_loc_index, x, y, str ); 834 901 exit(1); 835 902 } … … 838 905 str = getStringValue(reader, "mode", &ok); 839 906 #if XML_PARSER_DEBUG 840 printf(" mode = %s\n", str);907 printf(" mode = %s\n", str); 841 908 #endif 842 909 if (ok && (strcmp(str, "CXWU") == 0)) { vseg[vseg_index]->mode = 0xF; } … … 955 1022 const char * tag = (const char *) xmlTextReaderConstName(reader); 956 1023 957 if (strcmp(tag, "vseg") == 0) { 1024 if (strcmp(tag, "vseg") == 0) 1025 { 958 1026 vsegNode(reader); 959 1027 } 960 else if (strcmp(tag, "task") == 0) { 1028 else if (strcmp(tag, "task") == 0) 1029 { 961 1030 taskNode(reader); 962 1031 nb_task_vspace++; … … 1144 1213 1145 1214 /////////// set psegid attribute 1146 int index = getPsegId( cluster_index, str);1215 int index = getPsegId( cluster[cluster_index]->x, cluster[cluster_index]->y, str); 1147 1216 if (index >= 0) 1148 1217 { … … 1465 1534 1466 1535 /////////// set psegid attribute 1467 int index = getPsegId( cluster_index, str);1536 int index = getPsegId( cluster[cluster_index]->x, cluster[cluster_index]->y, str); 1468 1537 if (index >= 0) 1469 1538 { … … 1786 1855 1787 1856 //////// set cluster attribute 1788 pseg[pseg_index]->cluster = cluster_index;1857 pseg[pseg_index]->clusterid = cluster_index; 1789 1858 1790 1859 //////// set next_vseg attribute … … 1804 1873 cluster[cluster_index] = (mapping_cluster_t *) malloc(sizeof(mapping_cluster_t)); 1805 1874 1806 //initialise all variables 1807 //they will be incremented by *Node() functions 1808 //FIXME: calloc? 1875 //initialise variables that will be incremented by *Node() functions 1809 1876 cluster[cluster_index]->psegs = 0; 1810 1877 cluster[cluster_index]->procs = 0; … … 1812 1879 cluster[cluster_index]->periphs = 0; 1813 1880 1814 1815 1881 //initialise global variables 1816 //TODO: delete those three1817 1882 proc_loc_index = 0; 1818 1883 coproc_loc_index = 0; … … 1830 1895 } 1831 1896 1832 // checking source file consistency 1833 if (cluster_index >= header->clusters) 1834 { 1835 printf("[XML ERROR] The cluster index is too large : %d\n", cluster_index); 1836 exit(1); 1837 } 1838 1839 #if XML_PARSER_DEBUG 1840 printf(" cluster %d\n", cluster_index); 1841 #endif 1842 1843 1844 /////////// check cluster index attribute (optional) 1845 value = getIntValue(reader, "index", &ok); 1846 if (ok && (value != cluster_index)) 1847 { 1848 printf("[XML ERROR] wrong cluster index / expected value is %d", 1897 #if XML_PARSER_DEBUG 1898 printf("\n cluster %d\n", cluster_index); 1899 #endif 1900 1901 /////////// get x coordinate 1902 value = getIntValue(reader, "x", &ok); 1903 #if XML_PARSER_DEBUG 1904 printf(" x = %d\n", value); 1905 #endif 1906 if (ok && (value < header->x_size) ) 1907 { 1908 cluster[cluster_index]->x = value; 1909 } 1910 else 1911 { 1912 printf("[XML ERROR] Illegal or missing < x > attribute for cluster %d", 1913 cluster_index); 1914 exit(1); 1915 } 1916 1917 /////////// get y coordinate 1918 value = getIntValue(reader, "y", &ok); 1919 #if XML_PARSER_DEBUG 1920 printf(" y = %d\n", value); 1921 #endif 1922 if (ok && (value < header->y_size) ) 1923 { 1924 cluster[cluster_index]->y = value; 1925 } 1926 else 1927 { 1928 printf("[XML ERROR] Illegal or missing < y > attribute for cluster %d", 1849 1929 cluster_index); 1850 1930 exit(1); … … 1858 1938 1859 1939 #if XML_PARSER_DEBUG 1860 1861 1862 1863 1940 printf(" pseg_offset = %d\n", pseg_index); 1941 printf(" proc_offset = %d\n", proc_index); 1942 printf(" coproc_offset = %d\n", coproc_index); 1943 printf(" periph_offset = %d\n", coproc_index); 1864 1944 #endif 1865 1945 … … 1899 1979 1900 1980 #if XML_PARSER_DEBUG 1901 1902 1903 1904 1905 1981 printf(" psegs = %d\n", cluster[cluster_index]->psegs); 1982 printf(" procs = %d\n", cluster[cluster_index]->procs); 1983 printf(" coprocs = %d\n", cluster[cluster_index]->coprocs); 1984 printf(" periphs = %d\n", cluster[cluster_index]->periphs); 1985 printf(" end cluster %d\n", cluster_index); 1906 1986 #endif 1907 1987 cluster_index++; … … 1919 1999 1920 2000 #if XML_PARSER_DEBUG 1921 2001 printf("\n clusters set\n"); 1922 2002 #endif 1923 2003 … … 1933 2013 { 1934 2014 // checking source file consistency 1935 if ( cluster_index != header->clusters)2015 if ( cluster_index != (header->x_size * header->y_size) ) 1936 2016 { 1937 2017 printf("[XML ERROR] Wrong number of clusters\n"); … … 2079 2159 } 2080 2160 2081 /////////// get cluster_x attribute 2082 cluster_x = getIntValue(reader, "cluster_x", &ok); 2083 if (ok) 2084 { 2085 #if XML_PARSER_DEBUG 2086 printf(" cluster_x = %d\n", cluster_x); 2087 #endif 2088 header->cluster_x = cluster_x; 2089 } 2090 else 2091 { 2092 printf("[XML ERROR] illegal or missing <cluster_x> attribute in header\n"); 2093 exit(1); 2094 } 2095 2096 /////////// get cluster_y attribute 2097 cluster_y = getIntValue(reader, "cluster_y", &ok); 2098 if (ok) 2099 { 2100 #if XML_PARSER_DEBUG 2101 printf(" cluster_y = %d\n", cluster_y); 2102 #endif 2103 header->cluster_y = cluster_y; 2104 } 2105 else 2106 { 2107 printf("[XML ERROR] illegal or missing <cluster_y> attribute in header\n"); 2161 /////////// get x_width attribute 2162 value = getIntValue(reader, "x_width", &ok); 2163 if (ok) 2164 { 2165 #if XML_PARSER_DEBUG 2166 printf(" x_width = %d\n", value); 2167 #endif 2168 header->x_width = value; 2169 } 2170 2171 /////////// get y_width attribute 2172 value = getIntValue(reader, "y_width", &ok); 2173 if (ok) 2174 { 2175 #if XML_PARSER_DEBUG 2176 printf(" y_width = %d\n", value); 2177 #endif 2178 header->y_width = value; 2179 } 2180 2181 /////////// get x_size attribute 2182 unsigned int x_size = getIntValue(reader, "x_size", &ok); 2183 if (ok) 2184 { 2185 #if XML_PARSER_DEBUG 2186 printf(" x_size = %d\n", x_size); 2187 #endif 2188 header->x_size = x_size; 2189 } 2190 else 2191 { 2192 printf("[XML ERROR] illegal or missing <x_size> attribute in header\n"); 2193 exit(1); 2194 } 2195 2196 /////////// get y_size attribute 2197 unsigned int y_size = getIntValue(reader, "y_size", &ok); 2198 if (ok) 2199 { 2200 #if XML_PARSER_DEBUG 2201 printf(" y_size = %d\n", y_size); 2202 #endif 2203 header->y_size = y_size; 2204 } 2205 else 2206 { 2207 printf("[XML ERROR] illegal or missing <y_size> attribute in header\n"); 2108 2208 exit(1); 2109 2209 } 2110 2210 2111 2211 //check the number of cluster 2112 value = cluster_x * cluster_y; 2113 if (value >= MAX_CLUSTERS) 2114 { 2115 printf("[XML ERROR] The number of clusters is larger than %d\n", MAX_CLUSTERS); 2116 exit(1); 2117 } 2118 2119 header->clusters = value; 2120 2121 #if XML_PARSER_DEBUG 2122 printf(" clusters = %d\n", value); 2123 #endif 2212 if ( (x_size * y_size) >= MAX_CLUSTERS ) 2213 { 2214 printf("[XML ERROR] Number of clusters cannot be larger than %d\n", MAX_CLUSTERS); 2215 exit(1); 2216 } 2124 2217 2125 2218 ///////// get vspaces attribute … … 2281 2374 printf("Building map.bin for %s\n", header->name); 2282 2375 printf("signature = %x\n", header->signature); 2283 printf("clusters = %d\n", header->clusters); 2376 printf("x_size = %d\n", header->x_size); 2377 printf("y_size = %d\n", header->y_size); 2378 printf("x_width = %d\n", header->x_width); 2379 printf("y_width = %d\n", header->y_width); 2284 2380 printf("vspaces = %d\n", header->vspaces); 2285 2381 printf("psegs = %d\n", header->psegs); … … 2406 2502 file_write(fdout, ifdef); 2407 2503 2408 def_int_write(fdout, "CLUSTER_X ", cluster_x); 2409 def_int_write(fdout, "CLUSTER_Y ", cluster_y); 2410 def_int_write(fdout, "NB_CLUSTERS ", cluster_index); 2504 def_int_write(fdout, "X_SIZE ", header->x_size); 2505 def_int_write(fdout, "Y_SIZE ", header->y_size); 2506 def_int_write(fdout, "X_WIDTH ", header->x_width); 2507 def_int_write(fdout, "Y_WIDTH ", header->y_width); 2508 2509 file_write(fdout, "\n"); 2510 2411 2511 def_int_write(fdout, "NB_PROCS_MAX ", nb_proc_max); 2412 2512 def_int_write(fdout, "NB_TASKS_MAX ", nb_tasks_max);
Note: See TracChangeset
for help on using the changeset viewer.