Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1499 → Rev 1500

/demos/trunk/newtrace/utils/extract.c
2,6 → 2,7
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
#include <string.h>
 
#define MAXCONTEXT 100
#define MAXJOB 100000
49,7 → 50,7
unsigned long long log_end_tsc = 0;
unsigned long long total_dtsc = 0;
 
int draw_data[DRAW_NUM];
int draw_data[DRAW_NUM+1];
 
int gnuplot_clear() {
 
62,24 → 63,52
 
}
 
int gnuplot_draw(unsigned long long max_limit) {
int gnuplot_draw(char *title,unsigned long long max_limit,int type) {
 
FILE *gnuplot_data, *gnuplot_command;
int i;
char temp_name[30];
int i,pid,*current_mem;
 
gnuplot_data = fopen("/tmp/pwcet_tmp","w");
gnuplot_command = popen("gnuplot","w");
fprintf(gnuplot_command,"plot \"%s\" using 1:2 with lines\n","/tmp/pwcet_tmp");
fflush(gnuplot_command);
current_mem = malloc(sizeof(int)*(DRAW_NUM+1));
memcpy(current_mem,draw_data,sizeof(int)*(DRAW_NUM+1));
 
for (i=0;i<DRAW_NUM;i++)
fprintf(gnuplot_data,"%f\t%f\n",(double)i * (double)max_limit / (double)DRAW_NUM,(float)draw_data[i]);
pid = fork();
if (pid == 0) {
 
fclose(gnuplot_data);
getchar();
fclose(gnuplot_command);
srand(getpid());
 
sprintf(temp_name,"/tmp/pwcet%d",rand()%10000);
 
gnuplot_data = fopen(temp_name,"w");
gnuplot_command = popen("gnuplot","w");
 
for (i=0;i<DRAW_NUM;i++)
fprintf(gnuplot_data,"%f\t%f\n",(double)i * (double)max_limit / (double)DRAW_NUM,(float)(current_mem[i]));
 
fflush(gnuplot_data);
fclose(gnuplot_data);
 
fprintf(gnuplot_command,"set xlabel \"Time [us]\"\n");
if (type == 0) {
fprintf(gnuplot_command,"set ylabel \"Frequency [#]\"\n");
 
fprintf(gnuplot_command,"plot \"%s\" using 1:2 title \"%s\" with lines\n",temp_name,title);
fflush(gnuplot_command);
} else {
fprintf(gnuplot_command,"set ylabel \"Time [us]\"\n");
 
fprintf(gnuplot_command,"plot \"%s\" using 1:2 title \"%s\" with lines\n",temp_name,title);
fflush(gnuplot_command);
}
 
sleep(100);
 
pclose(gnuplot_command);
 
exit(0);
 
}
 
return 0;
}
342,7 → 371,7
int elaborate_statistics(int num, int task_type) {
 
int i,k,h;
char pidstr[10];
char pidstr[10],tmpstr[30];
unsigned long long temp_tsc,max_tsc,min_tsc;
unsigned long long last_start, delta_start, first_exec;
unsigned long long max_limit;
384,6 → 413,26
printf(" Mean Exec dTSC [%12llu] us [%12llu]\n",temp_tsc / k, temp_tsc / k*1000/clk_per_msec);
printf(" Max Exec dTSC [%12llu] us [%12llu]\n\n",max_tsc, max_tsc*1000/clk_per_msec);
 
gnuplot_clear();
max_limit = total_dtsc*1000/clk_per_msec;
for (i=0;i<exec_total;i++)
if (exec_list[i].ctx == context_list[num].ctx) {
int h1,h2,h3;
h1 = ((exec_list[i].start-log_start_tsc)*1000/clk_per_msec) * DRAW_NUM / max_limit;
h2 = ((exec_list[i].start+exec_list[i].dtsc-log_start_tsc)*1000/clk_per_msec) * DRAW_NUM / max_limit;
for (h3=h1;h3<h2;h3++)
if (h3 <= DRAW_NUM) draw_data[h3] += (exec_list[i].dtsc*1000/clk_per_msec)*(h3-h1)/(h2-h1);
for (h3=h2;h3<=DRAW_NUM;h3++)
if (h3 <= DRAW_NUM) draw_data[h3] += (exec_list[i].dtsc*1000/clk_per_msec);
}
sprintf(tmpstr,"Ctx [%d:%s] Demand-Function",context_list[num].ctx,pidstr);
gnuplot_draw(tmpstr,max_limit,1);
 
}
 
if (task_type == INTERRUPT) {
404,10 → 453,6
k++;
}
 
gnuplot_clear();
 
max_limit = max_tsc*1000/clk_per_msec;
 
printf(" Total Execution dTSC [%12llu] us [%12llu]\n",temp_tsc,temp_tsc*1000/clk_per_msec);
printf(" Mean CPU Bandwidth [%11f%c]\n",(double)(temp_tsc)/(double)(total_dtsc)*100.0,'%');
printf(" after first int [%11f%c]\n",(double)(temp_tsc)/(double)(total_dtsc-first_exec)*100.0,'%');
416,14 → 461,39
printf(" Mean Interrupt dTSC [%12llu] us [%12llu]\n",temp_tsc / k,temp_tsc / k*1000/clk_per_msec);
printf(" Max Interrupt dTSC [%12llu] us [%12llu]\n\n",max_tsc,max_tsc*1000/clk_per_msec);
 
gnuplot_clear();
max_limit = max_tsc*1000/clk_per_msec;
 
for (i=0;i<exec_total;i++)
if (exec_list[i].ctx == context_list[num].ctx) {
h = (exec_list[i].dtsc*1000/clk_per_msec) * DRAW_NUM / max_limit;
if (h < DRAW_NUM) draw_data[h]++;
if (h <= DRAW_NUM) draw_data[h]++;
}
 
gnuplot_draw(max_limit);
sprintf(tmpstr,"Int C-dist");
gnuplot_draw(tmpstr,max_limit,0);
 
gnuplot_clear();
max_limit = total_dtsc*1000/clk_per_msec;
for (i=0;i<exec_total;i++)
if (exec_list[i].ctx == context_list[num].ctx) {
int h1,h2,h3;
 
h1 = ((exec_list[i].start-log_start_tsc)*1000/clk_per_msec) * DRAW_NUM / max_limit;
h2 = ((exec_list[i].start+exec_list[i].dtsc-log_start_tsc)*1000/clk_per_msec) * DRAW_NUM / max_limit;
for (h3=h1;h3<h2;h3++)
if (h3 <= DRAW_NUM) draw_data[h3] += (exec_list[i].dtsc*1000/clk_per_msec)*(h3-h1)/(h2-h1);
for (h3=h2;h3<=DRAW_NUM;h3++)
if (h3 <= DRAW_NUM) draw_data[h3] += (exec_list[i].dtsc*1000/clk_per_msec);
 
}
sprintf(tmpstr,"Int Demand-Function");
gnuplot_draw(tmpstr,max_limit,1);
 
last_start = 0;
temp_tsc = 0;
max_tsc = 0;
460,13 → 530,14
delta_start = exec_list[i].start - last_start;
 
h = (delta_start*1000/clk_per_msec) * DRAW_NUM / max_limit;
if (h < DRAW_NUM) draw_data[h]++;
if (h <= DRAW_NUM) draw_data[h]++;
 
last_start = exec_list[i].start;
}
}
 
gnuplot_draw(max_limit);
sprintf(tmpstr,"Int Arr.Delta");
gnuplot_draw(tmpstr,max_limit,0);
 
}
 
495,6 → 566,26
printf(" Mean Exec dTSC [%12llu] us [%12llu]\n",temp_tsc / k,temp_tsc / k*1000/clk_per_msec);
printf(" Max Exec dTSC [%12llu] us [%12llu]\n\n",max_tsc,max_tsc*1000/clk_per_msec);
 
gnuplot_clear();
max_limit = total_dtsc*1000/clk_per_msec;
for (i=0;i<exec_total;i++)
if (exec_list[i].ctx == context_list[num].ctx) {
int h1,h2,h3;
h1 = ((exec_list[i].start-log_start_tsc)*1000/clk_per_msec) * DRAW_NUM / max_limit;
h2 = ((exec_list[i].start+exec_list[i].dtsc-log_start_tsc)*1000/clk_per_msec) * DRAW_NUM / max_limit;
for (h3=h1;h3<h2;h3++)
if (h3 <= DRAW_NUM) draw_data[h3] += (exec_list[i].dtsc*1000/clk_per_msec)*(h3-h1)/(h2-h1);
for (h3=h2;h3<=DRAW_NUM;h3++)
if (h3 <= DRAW_NUM) draw_data[h3] += (exec_list[i].dtsc*1000/clk_per_msec);
}
sprintf(tmpstr,"Ctx [%d:%s] Demand-Function",context_list[num].ctx,pidstr);
gnuplot_draw(tmpstr,max_limit,1);
 
temp_tsc = 0;
max_tsc = 0;
min_tsc = 0xFFFFFFFF;
519,10 → 610,11
for (i=0;i<job_total;i++)
if (job_list[i].ctx == context_list[num].ctx) {
h = (job_list[i].dtsc*1000/clk_per_msec) * DRAW_NUM / max_limit;
if (h < DRAW_NUM) draw_data[h]++;
if (h <= DRAW_NUM) draw_data[h]++;
}
 
gnuplot_draw(max_limit);
sprintf(tmpstr,"[%d:%s] jobs C-dist",context_list[num].ctx,pidstr);
gnuplot_draw(tmpstr,max_limit,0);
 
last_start = 0;
temp_tsc = 0;
543,7 → 635,7
}
}
 
printf(" Min Arr. Delta dTSC [%12llu] us [%12llu]\n\n",min_tsc,min_tsc*1000/clk_per_msec);
printf(" Min Arr. Delta dTSC [%12llu] us [%12llu]\n",min_tsc,min_tsc*1000/clk_per_msec);
printf(" Mean Arr. Delta dTSC [%12llu] us [%12llu]\n",temp_tsc / k,temp_tsc / k*1000/clk_per_msec);
printf(" Max Arr. Delta dTSC [%12llu] us [%12llu]\n\n",max_tsc,max_tsc*1000/clk_per_msec);
560,13 → 652,14
delta_start = job_list[i].start - last_start;
 
h = (delta_start*1000/clk_per_msec) * DRAW_NUM / max_limit;
if (h < DRAW_NUM) draw_data[h]++;
if (h <= DRAW_NUM) draw_data[h]++;
 
last_start = exec_list[i].start;
last_start = job_list[i].start;
}
}
 
gnuplot_draw(max_limit);
sprintf(tmpstr,"[%d:%s] jobs Arr.Delta",context_list[num].ctx,pidstr);
gnuplot_draw(tmpstr,max_limit,0);
 
}
 
580,6 → 673,8
int task_type;
unsigned long long total_tsc;
 
srand(getpid());
 
if (argc < 3) {
printf("%s: Enter the input file name and clk_per_msec [%s filename clk_per_msec]\n",argv[0],argv[0]);
exit(1);
611,11 → 706,11
 
/* Remove preemption from the computation time */
create_job_list();
 
/*
for (k=0;k<job_total;k++)
printf("Job CTX [%5d] Start [%12llu] dTSC [%12llu]\n",
job_list[k].ctx,job_list[k].start,job_list[k].dtsc);
 
*/
printf("\nCompute Task Statistics.... \n\n");
 
for (i=0;i<context_total;i++) {
633,7 → 728,7
elaborate_statistics(i,task_type);
 
}
 
return 0;
 
}