2,7 → 2,6 |
#include <stdlib.h> |
#include <math.h> |
#include <unistd.h> |
#include <string.h> |
|
#define MAXCONTEXT 100 |
#define MAXJOB 100000 |
50,7 → 49,7 |
unsigned long long log_end_tsc = 0; |
unsigned long long total_dtsc = 0; |
|
int draw_data[DRAW_NUM+1]; |
int draw_data[DRAW_NUM]; |
|
int gnuplot_clear() { |
|
63,52 → 62,24 |
|
} |
|
int gnuplot_draw(char *title,unsigned long long max_limit,int type) { |
int gnuplot_draw(unsigned long long max_limit) { |
|
FILE *gnuplot_data, *gnuplot_command; |
char temp_name[30]; |
int i,pid,*current_mem; |
int i; |
|
current_mem = malloc(sizeof(int)*(DRAW_NUM+1)); |
memcpy(current_mem,draw_data,sizeof(int)*(DRAW_NUM+1)); |
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); |
|
pid = fork(); |
if (pid == 0) { |
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]); |
|
srand(getpid()); |
fclose(gnuplot_data); |
|
getchar(); |
fclose(gnuplot_command); |
|
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; |
|
} |
371,7 → 342,7 |
int elaborate_statistics(int num, int task_type) { |
|
int i,k,h; |
char pidstr[10],tmpstr[30]; |
char pidstr[10]; |
unsigned long long temp_tsc,max_tsc,min_tsc; |
unsigned long long last_start, delta_start, first_exec; |
unsigned long long max_limit; |
413,26 → 384,6 |
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) { |
453,6 → 404,10 |
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,'%'); |
461,39 → 416,14 |
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]++; |
} |
|
sprintf(tmpstr,"Int C-dist"); |
gnuplot_draw(tmpstr,max_limit,0); |
gnuplot_draw(max_limit); |
|
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; |
530,14 → 460,13 |
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; |
} |
} |
|
sprintf(tmpstr,"Int Arr.Delta"); |
gnuplot_draw(tmpstr,max_limit,0); |
gnuplot_draw(max_limit); |
|
} |
|
566,26 → 495,6 |
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; |
610,11 → 519,10 |
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]++; |
} |
|
sprintf(tmpstr,"[%d:%s] jobs C-dist",context_list[num].ctx,pidstr); |
gnuplot_draw(tmpstr,max_limit,0); |
gnuplot_draw(max_limit); |
|
last_start = 0; |
temp_tsc = 0; |
635,7 → 543,7 |
} |
} |
|
printf(" Min Arr. Delta dTSC [%12llu] us [%12llu]\n",min_tsc,min_tsc*1000/clk_per_msec); |
printf(" Min Arr. Delta dTSC [%12llu] us [%12llu]\n\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); |
|
652,14 → 560,13 |
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 = job_list[i].start; |
last_start = exec_list[i].start; |
} |
} |
|
sprintf(tmpstr,"[%d:%s] jobs Arr.Delta",context_list[num].ctx,pidstr); |
gnuplot_draw(tmpstr,max_limit,0); |
gnuplot_draw(max_limit); |
|
} |
|
673,8 → 580,6 |
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); |
706,11 → 611,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++) { |
728,7 → 633,7 |
elaborate_statistics(i,task_type); |
|
} |
|
|
return 0; |
|
} |