crown
1.0.0
|
00001 /* 00002 Copyright 2015 Nicolas Melot 00003 00004 This file is part of Crown. 00005 00006 Crown is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 Crown is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Crown. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 00022 /* 00023 * crownFigureGen.c 00024 * 00025 * Created on: 06.06.2013 00026 * Author: Patrick Eitschberger 00027 * 00028 * latest update: 00029 * 05.09.2013 00030 * 2014-01-30 Fixed inverted reading of matric e, support for bigger matrices than cores, updated max core and tasks 00031 */ 00032 #include <stdio.h> 00033 #include <stdlib.h> 00034 #include <string.h> 00035 #include <dirent.h> 00036 00037 // Control if scanf operation went OK and abort with a message stating line of code if any failure occurred. 00038 #define assert_scanf(expr) { int num = expr; if (num == 0 || num == EOF) { fprintf(stderr, "[%s:%s:%d] Error while reading input. Aborting.\n", __FILE__, __FUNCTION__, __LINE__); abort(); }} 00039 00040 static int MAXTASKS = 2000; //upper bound for number of tasks 00041 static int MAXCORES = 1024; //upper bound for number of cores 00042 static int FIGUREHEIGHT = -1; 00043 static int SHOWGROUPS = 1; // include the grouporder in the figure 00044 static char filenameDat[500]; 00045 static char filenameOut[500]; 00046 static char filenameFig[500]; 00047 00048 #define printf_int(var) printf("[DEBUG][%s:%s:%d] %s = %d\n", __FILE__, __FUNCTION__, __LINE__, #var, var); 00049 #define printf_llint(var) printf("[DEBUG][%s:%s:%d] %s = %lld\n", __FILE__, __FUNCTION__, __LINE__, #var, var); 00050 #define printf_float(var) printf("[DEBUG][%s:%s:%d] %s = %f\n", __FILE__, __FUNCTION__, __LINE__, #var, var); 00051 00052 struct task /* task properties */ 00053 { 00054 int taskIndex; 00055 int groupIndex; 00056 int workload; 00057 int coresInGroup; 00058 float efficiency; 00059 int frequencyOfTask; 00060 float runtime; 00061 struct task *next; 00062 struct task *previous; 00063 }; 00064 typedef struct task Task; 00065 00066 static void readfiles(int *L, int *b, int *n, int tau[MAXTASKS], int *corecount, float e[MAXTASKS][MAXCORES], int group[MAXTASKS], int frequency[MAXTASKS], float *M); 00067 static void createGroupSizes(int groupOrder[MAXCORES*2], int corecount); 00068 static Task *fillTasklist(Task *tasklist, int tau[MAXTASKS], float e[MAXTASKS][MAXCORES], int group[MAXTASKS], int frequency[MAXTASKS], int n, int groupOrder[MAXCORES*2]); 00069 static void generateFigureFile(Task * tasklist, int corecount, float M); 00070 //static void displayOutputs(int L, int b, int n, int corecount, int tau[MAXTASKS], float e[MAXTASKS][MAXCORES], float time[MAXCORES], int group[MAXTASKS], int frequency[MAXTASKS], int groupOrder[MAXCORES*2], Task *tasklist, float M); 00071 00072 int main(int argc, char **argv) 00073 { 00074 int L = 0; 00075 int b = 0; 00076 int n = 0; 00077 int corecount = 1; 00078 int tau[MAXTASKS]; 00079 float e[MAXTASKS][MAXCORES]; 00080 float M = 0.0; 00081 //float time[MAXCORES]; 00082 int group[MAXTASKS]; 00083 int frequency[MAXTASKS]; 00084 int groupOrder[MAXCORES*2]; 00085 Task *tasklist = NULL; 00086 Task *deleteElement = NULL; 00087 00088 /* Safe arguments */ 00089 if(argc == 1) 00090 { 00091 fprintf(stderr, "Too few arguments. Please set the filepath (including the filename).\n"); 00092 exit(1); 00093 } 00094 else if(argc == 2) 00095 { 00096 sprintf(filenameDat, "%s", argv[1]); 00097 //printf("%s\n", filenameDat); 00098 } 00099 else if(argc == 3) 00100 { 00101 sprintf(filenameDat, "%s", argv[1]); 00102 //printf("%s\n", filenameDat); 00103 SHOWGROUPS = atoi(argv[2]); 00104 00105 } 00106 else if(argc == 4) 00107 { 00108 sprintf(filenameDat, "%s", argv[1]); 00109 //printf("%s\n", filenameDat); 00110 SHOWGROUPS = atoi(argv[2]); 00111 FIGUREHEIGHT = atoi(argv[3]); 00112 } 00113 else 00114 { 00115 printf("Too many arguments\n"); 00116 exit(2); 00117 } 00118 00119 readfiles(&L, &b, &n, tau, &corecount, e, group, frequency, &M); 00120 createGroupSizes(groupOrder, corecount); 00121 tasklist = fillTasklist(tasklist, tau, e, group, frequency, n, groupOrder); 00122 generateFigureFile(tasklist, corecount, M); //in xfig-format 00123 //displayOutputs(L, b, n, corecount, tau, e, time, group, frequency, groupOrder, tasklist, M); 00124 00125 while(tasklist->next != NULL) 00126 { 00127 deleteElement = tasklist; 00128 tasklist = tasklist->next; 00129 free(deleteElement); 00130 } 00131 00132 return 0; 00133 } 00134 00135 /* reads the inputs from the dat- and out-files (frequency.dat/.out and integrated.dat/out) */ 00136 void readfiles(int *L, int *b, int *n, int tau[MAXTASKS], int *corecount, float e[MAXTASKS][MAXCORES], int group[MAXTASKS], int frequency[MAXTASKS], float *M) 00137 { 00138 int i = 0; 00139 int j = 0; 00140 char line[250]; 00141 size_t length; 00142 FILE *datfile = fopen(filenameDat, "r"); 00143 length = strlen(filenameDat); 00144 strncpy(filenameOut, filenameDat, length - 4); 00145 strcat(filenameOut, ".out"); 00146 FILE *outfile = fopen(filenameOut, "r"); 00147 if (datfile != NULL && outfile != NULL) /* if the files exist... */ 00148 { 00149 /* values from the datfile */ 00150 00151 /* read param L,b,n */ 00152 assert_scanf(fscanf(datfile,"%s %s %s", &line[0], &line[0], &line[0])); 00153 00154 assert_scanf(fscanf(datfile,"%d %s\n", L, &line[0])); 00155 assert_scanf(fscanf(datfile,"%s %s %s", &line[0], &line[0], &line[0])); 00156 assert_scanf(fscanf(datfile,"%d %s", b, &line[0])); 00157 assert_scanf(fscanf(datfile,"%s %s %s", &line[0], &line[0], &line[0])); 00158 assert_scanf(fscanf(datfile,"%d %s", n, &line[0])); 00159 00160 /* go to line with param tau */ 00161 while(strcmp(line,"workload")) 00162 { 00163 assert_scanf(fscanf(datfile,"%s", &line[0])); 00164 } 00165 00166 /* read param tau */ 00167 for(i = 0; i < *n; i++) 00168 { 00169 assert_scanf(fscanf(datfile,"%*d %d", &tau[i])); 00170 //fprintf(stderr, "Task %d gets tau %d\n", i + 1, tau[i]); 00171 } 00172 00173 /* go to line with param e */ 00174 while(strcmp(line,":=")) 00175 { 00176 assert_scanf(fscanf(datfile,"%s", &line[0])); 00177 } 00178 00179 for(i = 0; i < *L; i++) 00180 *corecount = *corecount * 2; 00181 00182 00183 /* read param e */ 00184 for(i = 0; i < *n; i++) 00185 { 00186 assert_scanf(fscanf(datfile,"%*d")); 00187 for(j = 0; j < *corecount; j++) 00188 { 00189 assert_scanf(fscanf(datfile,"%f", &e[i][j])); 00190 } 00191 while(fgetc(datfile) != '\n'); 00192 00193 } 00194 00195 /* set line to 0 because it is also ":=" before */ 00196 sprintf(line, "0"); 00197 00198 /* go to line with param M */ 00199 while(strcmp(line,"parameters")) 00200 { 00201 assert_scanf(fscanf(datfile,"%s", &line[0])); 00202 } 00203 00204 /* read param M */ 00205 assert_scanf(fscanf(datfile,"%s %s %s", &line[0], &line[0], &line[0])); 00206 assert_scanf(fscanf(datfile,"%f %s\n", M, &line[0])); 00207 00208 fclose(datfile); 00209 00210 /* values from the out-file */ 00211 00212 /* set line to 0 because it is also ":=" before */ 00213 sprintf(line, "0"); 00214 00215 /* go to line with step-time (frequency.out) or int-time (integrated.out) */ 00216 while(strcmp(line,":=")) 00217 { 00218 assert_scanf(fscanf(outfile,"%s", &line[0])); 00219 } 00220 00221 /* read param time */ 00222 for(i = 0; i < *corecount; i++) 00223 { 00224 float a; 00225 assert_scanf(fscanf(outfile,"%*d %f", &a)); 00226 } 00227 00228 /* set line to 0 because it is also ":=" before */ 00229 sprintf(line, "0"); 00230 00231 /* go to line with step-group (frequency.out) or int-group (integrated.out) */ 00232 while(strcmp(line,":=")) 00233 { 00234 assert_scanf(fscanf(outfile,"%s", &line[0])); 00235 } 00236 00237 /* read param group */ 00238 int task, tmp; 00239 for(i = 0; i < *n; i++) 00240 { 00241 assert_scanf(fscanf(outfile,"%d %d", &task, &tmp)); 00242 group[task - 1] = tmp; 00243 //fprintf(stderr, "Task %d gets group %d\n", task, group[task-1]); 00244 } 00245 00246 /* set line to 0 because it is also ":=" before */ 00247 sprintf(line, "0"); 00248 00249 /* go to line with step-frequency (frequency.out) or int-frequency (integrated.out) */ 00250 while(strcmp(line,":=")) 00251 { 00252 assert_scanf(fscanf(outfile,"%s", &line[0])); 00253 } 00254 00255 /* read param frequency */ 00256 for(i = 0; i < *n; i++) 00257 { 00258 assert_scanf(fscanf(outfile,"%d %d", &task, &tmp)); 00259 frequency[task - 1] = tmp; 00260 //fprintf(stderr, "Task %d gets frequency %d\n", task, frequency[task-1]); 00261 } 00262 fclose(outfile); 00263 } 00264 } 00265 00266 /* create the order of the groups */ 00267 void createGroupSizes(int groupOrder[MAXCORES*2],int corecount) 00268 { 00269 int i = 0; 00270 int j = 1; 00271 int step = 0; 00272 for(i = 0; i < corecount * 2 - 1 ; i++) 00273 { 00274 if(step == j) 00275 { 00276 step = 0; 00277 j = j * 2; 00278 } 00279 groupOrder[i] = corecount/j; 00280 //printf("%d -> %d\n", i, groupOrder[i]); 00281 step++; 00282 } 00283 } 00284 00285 /* creates a list of tasks sorted by their groupIndex */ 00286 Task *fillTasklist(Task *tasklist, int tau[MAXTASKS], float e[MAXTASKS][MAXCORES], int group[MAXTASKS], int frequency[MAXTASKS], int n, int groupOrder[MAXCORES*2]) 00287 { 00288 Task *newtask = NULL; 00289 Task *currenttask = NULL; 00290 int i = 0; 00291 00292 /* create n task-elements and insert them in the tasklist sorted by groupindex first and then by taskindex */ 00293 for(i = 0; i < n; i++) 00294 { 00295 newtask = malloc(sizeof(Task)); 00296 newtask->taskIndex = i+1; 00297 newtask->groupIndex = group[i]; 00298 newtask->workload = tau[i]; 00299 newtask->coresInGroup = groupOrder[newtask->groupIndex - 1]; 00300 newtask->efficiency = e[i][newtask->coresInGroup - 1]; 00301 newtask->frequencyOfTask = frequency[i]; 00302 newtask->runtime = newtask->workload / newtask->efficiency; 00303 newtask->runtime = newtask->runtime / newtask->coresInGroup; 00304 newtask->runtime = newtask->runtime / newtask->frequencyOfTask; 00305 //newtask->runtime = ((newtask->workload / newtask->efficiency) / newtask->coresInGroup) / newtask->frequencyOfTask; 00306 newtask->next = NULL; 00307 newtask->previous = NULL; 00308 00309 #if 0 00310 struct task /* task properties */ 00311 { 00312 int taskIndex; 00313 int groupIndex; 00314 int workload; 00315 int coresInGroup; 00316 float efficiency; 00317 int frequencyOfTask; 00318 float runtime; 00319 struct task *next; 00320 struct task *previous; 00321 }; 00322 00323 if(newtask->runtime > 10000) 00324 { 00325 printf_int(newtask->groupIndex); 00326 printf_int(newtask->coresInGroup); 00327 printf_int(newtask->taskIndex); 00328 printf_int(newtask->workload); 00329 printf_float(newtask->efficiency); 00330 printf_int(newtask->coresInGroup); 00331 printf_int(newtask->frequencyOfTask); 00332 printf_float(newtask->runtime); 00333 printf_float(newtask->workload / newtask->efficiency / newtask->coresInGroup / newtask->frequencyOfTask); 00334 printf_int(newtask->workload / newtask->efficiency / newtask->coresInGroup / newtask->frequencyOfTask); 00335 00336 abort(); 00337 } 00338 #endif 00339 00340 if (tasklist == NULL) 00341 tasklist = newtask; 00342 else 00343 { 00344 currenttask = tasklist; 00345 while(currenttask->groupIndex <= newtask->groupIndex && currenttask->next != NULL) 00346 currenttask = currenttask->next; 00347 if(currenttask->groupIndex > newtask->groupIndex) 00348 { 00349 if(currenttask->previous == NULL) 00350 { 00351 newtask->next = currenttask; 00352 currenttask->previous = newtask; 00353 tasklist = newtask; 00354 } 00355 else 00356 { 00357 currenttask->previous->next = newtask; 00358 newtask->previous = currenttask->previous; 00359 newtask->next = currenttask; 00360 currenttask->previous = newtask; 00361 } 00362 } 00363 else 00364 { 00365 currenttask->next = newtask; 00366 newtask->previous = currenttask; 00367 } 00368 } 00369 } 00370 return tasklist; 00371 } 00372 00373 /* generate *.fig file with the information from the tasklist */ 00374 void generateFigureFile(Task * tasklist, int corecount, float M) 00375 { 00376 float realtime[MAXCORES]; 00377 int i = 0; 00378 int corewidth = 1000; 00379 Task *currenttask = NULL; 00380 int taskwidth = 0; 00381 int taskheight = 0; 00382 int x = 0; 00383 int y = 0; 00384 // float biggesttime = 0.0; CHANGED LIKE FAVORED FROM NICOLAS (21.06.13) 00385 int scheduleheight = 0; 00386 int groupCountPerLine = 0; 00387 int groupHeight[corecount * 2]; 00388 int xOffset = 1000; 00389 int yOffset = 100; 00390 int barrierwidth = 0; 00391 int barrierheight = 284; 00392 int startCore = 0; 00393 size_t length; 00394 00395 int scalingfactor = 0; 00396 00397 //calculate scalingfactor for the taskheight and scheduleheight 00398 if(FIGUREHEIGHT != -1) // if the figure height is given as param to this program calculate the scalingfactor 00399 { 00400 scalingfactor = (int)((FIGUREHEIGHT - (2 * barrierheight + 500))/M); 00401 } 00402 else // use 1000 as scalingfactor 00403 scalingfactor = 1000; 00404 // printf("scalingfactor = %d\n", scalingfactor); 00405 00406 00407 length = strlen(filenameDat); 00408 strncpy(filenameFig, filenameDat, length - 4); 00409 strcat(filenameFig, ".fig"); 00410 // FILE *figfile = fopen(filenameFig, "w"); 00411 FILE *figfile = stdout; 00412 00413 /* standard outputs for the file properties */ 00414 fprintf(figfile, "#FIG 3.2\n"); 00415 fprintf(figfile, "#generated by Patrick Eitschberger\n"); 00416 fprintf(figfile, "Portrait\n"); 00417 fprintf(figfile, "Center\n"); 00418 fprintf(figfile, "Metric\n"); 00419 fprintf(figfile, "A4\n"); 00420 fprintf(figfile, "100.0\n"); 00421 fprintf(figfile, "Single\n"); 00422 fprintf(figfile, "-2\n"); 00423 fprintf(figfile, "1200 2\n"); 00424 00425 /* Calculate the running times for each core */ 00426 for(i = 0; i < corecount; i++) 00427 realtime[i] = 0.0; 00428 currenttask = tasklist; 00429 while(currenttask != NULL) 00430 { 00431 startCore = (currenttask->groupIndex - (corecount/currenttask->coresInGroup)) * currenttask->coresInGroup; 00432 for(i = startCore; i < startCore + currenttask->coresInGroup; i++) 00433 realtime[i] = realtime[i] + currenttask->runtime; 00434 currenttask = currenttask->next; 00435 } 00436 00437 // CHANGED LIKE FAVORED FROM NICOLAS (21.06.13) /* Calculate the height of the whole schedule */ 00438 // for(i = 0; i < corecount; i++) 00439 // if(realtime[i] > biggesttime) 00440 // biggesttime = realtime[i]; 00441 // scheduleheight = biggesttime * scalingfactor + yOffset + barrierheight; 00442 00443 scheduleheight = M * scalingfactor; 00444 scheduleheight = scheduleheight + yOffset; 00445 scheduleheight = scheduleheight + barrierheight; 00446 00447 /* include time-arrow on the left side with describtion "time" */ 00448 fprintf(figfile,"2 1 0 2 0 7 1 0 -1 6.000 0 0 0 0 1 2\n"); 00449 fprintf(figfile,"2 1 2.00 120.00 240.00\n"); 00450 fprintf(figfile,"%d %d %d %d\n", xOffset, yOffset + barrierheight, xOffset, scheduleheight - barrierheight); 00451 fprintf(figfile, "4 0 0 1 0 1 18 0.0000 4 303 1000 %d %d time\\001\n\n", 200, yOffset + barrierheight + 200); 00452 xOffset = xOffset *2; 00453 00454 /* include the upper barrier */ 00455 barrierwidth = corewidth * corecount + xOffset + 100; 00456 fprintf(figfile, "2 2 1 2 0 20 1 0 20 6.000 0 0 7 0 0 5\n"); 00457 fprintf(figfile, "%d %d %d %d %d %d %d %d %d %d\n\n", xOffset, yOffset, barrierwidth, yOffset, barrierwidth, yOffset + barrierheight, xOffset, yOffset + barrierheight, xOffset, yOffset); 00458 fprintf(figfile, "4 0 0 1 0 1 18 0.0000 4 500 1000 %d %d barrier\\001\n\n", barrierwidth + 100, yOffset + barrierheight ); 00459 00460 /* include tasks as rectangles with describtion "task xy" */ 00461 currenttask = tasklist; 00462 for(i = 0; i < corecount * 2; i++) 00463 groupHeight[i] = scheduleheight; 00464 while(currenttask != NULL) 00465 { 00466 // printf("Gruppe %d: Task %d: gruppenhoehe = %d, niedrigereGruppenhoehe = %d (gruppe %d)\n", currenttask->groupIndex, currenttask->taskIndex, groupHeight[currenttask->groupIndex - 1], groupHeight[currenttask->groupIndex /2], currenttask->groupIndex/2); 00467 if(currenttask->groupIndex != 1 && groupHeight[currenttask->groupIndex - 1] > groupHeight[currenttask->groupIndex / 2 - 1]) 00468 groupHeight[currenttask->groupIndex - 1] = groupHeight[currenttask->groupIndex /2 - 1]; 00469 y = groupHeight[currenttask->groupIndex - 1]; 00470 taskwidth = corewidth * currenttask->coresInGroup; 00471 taskheight = currenttask->runtime * scalingfactor; 00472 00473 #if 0 00474 if(y - taskheight < 0) 00475 { 00476 printf_float(currenttask->runtime); 00477 printf_int(scalingfactor); 00478 00479 printf_llint(taskheight); 00480 printf_llint(y); 00481 printf_llint(y - taskheight); 00482 00483 abort(); 00484 } 00485 #endif 00486 00487 groupCountPerLine = corecount/currenttask->coresInGroup; 00488 x = (currenttask->groupIndex - groupCountPerLine) * taskwidth + xOffset; 00489 fprintf(figfile, "2 2 0 2 0 26 3 0 %d 4.000 0 0 7 0 0 5\n", 35 - currenttask->frequencyOfTask * 5); 00490 fprintf(figfile, "%d %d %d %d %d %d %d %d %d %d\n\n", x, y - taskheight, x + taskwidth, y - taskheight, x + taskwidth, y, x, y, x, y - taskheight); 00491 fprintf(figfile, "4 1 0 1 0 0 18 0.0000 4 303 900 %d %d task %d\\001\n\n", x + taskwidth/2, y - taskheight/2 + 80 + 18, currenttask->taskIndex); 00492 groupHeight[currenttask->groupIndex - 1] = groupHeight[currenttask->groupIndex - 1] - taskheight; 00493 00494 // BUGFIX (05.09.13) /* changes the height of all groups that are placed over the current group */ 00495 for(i = 2; i <= corecount * 2; i++) 00496 if(groupHeight[i - 1] > groupHeight[i / 2 - 1]) 00497 groupHeight[i - 1] = groupHeight[i / 2 - 1]; 00498 currenttask = currenttask->next; 00499 } 00500 00501 /* include the lower barrier */ 00502 barrierwidth = corewidth * corecount + xOffset + 100; 00503 fprintf(figfile, "2 2 1 2 0 20 1 0 20 6.000 0 0 7 0 0 5\n"); 00504 fprintf(figfile, "%d %d %d %d %d %d %d %d %d %d\n\n", xOffset, scheduleheight, barrierwidth , scheduleheight, barrierwidth , scheduleheight + barrierheight, xOffset, scheduleheight + barrierheight, xOffset, scheduleheight); 00505 fprintf(figfile, "4 0 0 1 0 1 18 0.0000 4 303 1000 %d %d barrier\\001\n\n", barrierwidth + 100, scheduleheight + barrierheight ); 00506 00507 /* include a scale for the number of processors */ 00508 y = scheduleheight + barrierheight; 00509 for(i = 0; i <= corecount; i++) 00510 { 00511 fprintf(figfile, "2 1 0 2 0 7 1 0 -1 6.000 0 0 0 0 0 2\n"); 00512 fprintf(figfile, "%d %d %d %d\n\n", xOffset + i * corewidth, y, xOffset + i * corewidth, y + 200); 00513 if(i < corecount) 00514 { 00515 fprintf(figfile, "4 0 0 1 0 1 18 0.0000 4 500 615 %d %d P%d\\001\n\n", xOffset + i * corewidth + 450, y + 400, i + 1); 00516 fprintf(figfile, "2 1 1 1 0 7 2 0 -1 6.000 0 0 0 0 0 2\n"); 00517 fprintf(figfile, "%d %d %d %d\n\n", xOffset + (i + 1) * corewidth, scheduleheight - (int) (realtime[i] * scalingfactor), xOffset + (i + 1) * corewidth, scheduleheight + barrierheight + 200); 00518 } 00519 } 00520 00521 // UPDATE (05.09.13) /* include grouporder for better understanding */ 00522 if(SHOWGROUPS == 1) 00523 { 00524 int groupsinrow = corecount; 00525 y = y + 750; 00526 for(i = corecount * 2 - 1; i > 0 ; i--) 00527 { 00528 if(i >= groupsinrow) 00529 { 00530 x = xOffset + (i - groupsinrow) * (corewidth * corecount / groupsinrow); 00531 fprintf(figfile, "2 2 0 2 0 26 3 0 -1 4.000 0 0 7 0 0 5\n"); 00532 fprintf(figfile, "%d %d %d %d %d %d %d %d %d %d\n\n", x, y, x + (corewidth * corecount / groupsinrow), y, x + (corewidth * corecount / groupsinrow), y + barrierheight, x, y + barrierheight, x, y); 00533 fprintf(figfile, "4 1 0 1 0 0 18 0.0000 4 303 900 %d %d %d\\001\n\n", x + (corewidth * corecount / groupsinrow)/2, y + barrierheight/2 + 80 + 18, i); 00534 } 00535 if(i == groupsinrow) 00536 { 00537 if(groupsinrow == corecount/4) 00538 fprintf(figfile, "4 0 0 1 0 1 18 0.0000 4 303 1000 %d %d groups\\001\n\n", xOffset + corecount * corewidth + 100, y + barrierheight ); 00539 groupsinrow = groupsinrow / 2; 00540 y = y + barrierheight; 00541 } 00542 } 00543 } 00544 00545 // UPDATE (05.09.13) /* include frequency legend */ 00546 if(SHOWGROUPS == 1) 00547 y = y + 500; 00548 else 00549 y = y + 750; 00550 fprintf(figfile, "4 0 0 1 0 1 18 0.0000 4 500 615 %d %d frequencies\\001\n\n", xOffset + corewidth * corecount - 5 * corewidth, y); 00551 y = y + 150; 00552 for(i = 1; i < 6; i++) 00553 { 00554 fprintf(figfile, "2 2 0 2 0 26 3 0 %d 4.000 0 0 7 0 0 5\n", 35 - i * 5); 00555 fprintf(figfile, "%d %d %d %d %d %d %d %d %d %d\n\n", xOffset + corewidth * corecount - (6 - i) * corewidth, y, xOffset + corewidth * corecount - (6 - i - 1) * corewidth, y, xOffset + corewidth * corecount - (6 - i - 1) * corewidth, y + barrierheight, xOffset + corewidth * corecount - (6 - i) * corewidth, y + barrierheight, xOffset + corewidth * corecount - (6 - i) * corewidth, y); 00556 fprintf(figfile, "4 1 0 1 0 0 18 0.0000 4 303 900 %d %d %d\\001\n\n", xOffset + corewidth * corecount - (6 - i) * corewidth + corewidth/2, y + barrierheight/2 + 80 + 18, i); 00557 } 00558 00559 /* include a white rectangle around the figure to get a bigger screen for the eps and png files*/ 00560 fprintf(figfile, "2 2 0 4 7 7 1 0 -1 4.000 0 0 7 0 0 5\n"); 00561 fprintf(figfile, "%d %d %d %d %d %d %d %d %d %d\n\n", 1, 1, barrierwidth + 1000, 1, barrierwidth + 1000, y + 500, 1, y + 500, 1,1); 00562 00563 } 00564 00565 /* print some informations on the screen... only for checking correctness */ 00566 /* 00567 void displayOutputs(int L, int b, int n, int corecount, int tau[MAXTASKS], float e[MAXTASKS][MAXCORES], float time[MAXCORES], int group[MAXTASKS], int frequency[MAXTASKS], int groupOrder[MAXCORES*2], Task *tasklist, float M) 00568 { 00569 int i = 0; 00570 int j = 0; 00571 Task *currenttask = NULL; 00572 00573 printf("param L := %d\n", L); 00574 printf("param b := %d\n", b); 00575 printf("param n := %d\n", n); 00576 printf("\nparam: Tau := # Task workload\n"); 00577 for(i = 0; i < n; i++) 00578 printf("%d %d\n", i, tau[i]); 00579 printf("\nparam e: # Task efficiency for a given amount of cores, generated constant function\n"); 00580 for(i = 0; i < n; i++) 00581 { 00582 for(j = 0; j < corecount; j++) 00583 printf("%.6f ", e[i][j]); 00584 printf("\n"); 00585 } 00586 printf("\n*_time [*] :=\n"); 00587 for(i = 0; i < corecount; i++) 00588 printf("%d %f\n", i, time[i]); 00589 printf("\n*_group [*] :=\n"); 00590 for(i = 0; i < n; i++) 00591 printf("%d %d\n", i+1, group[i]); 00592 printf("\n*_frequency [*] :=\n"); 00593 for(i = 0; i < n; i++) 00594 printf("%d %d\n", i+1, frequency[i]); 00595 printf("\nGroupOrder =\n"); 00596 for(i = 0; i < corecount * 2 - 1; i++) 00597 printf("%d %d\n", i+1, groupOrder[i]); 00598 00599 printf("\nTasklist =\n"); 00600 currenttask = tasklist; 00601 while(currenttask != NULL) 00602 { 00603 printf("Group %d: task %d, runtime %f, workload %d, cores %d, efficiency %f, frequency %d, \n", currenttask->groupIndex, currenttask->taskIndex, currenttask->runtime, currenttask->workload, currenttask->coresInGroup, currenttask->efficiency, currenttask->frequencyOfTask); 00604 currenttask = currenttask->next; 00605 } 00606 printf("\nCost Parameters =\n"); 00607 printf("param M := %f\n", M); 00608 } 00609 */