diff --git a/i7z.c b/i7z.c old mode 100644 new mode 100755 index 61e2757..6e9bd2f --- a/i7z.c +++ b/i7z.c @@ -28,6 +28,8 @@ char* CPU_FREQUENCY_LOGGING_FILE_single="cpu_freq_log.txt"; char* CPU_FREQUENCY_LOGGING_FILE_dual="cpu_freq_log_dual_%d.txt"; char* CSTATE_LOGGING_FILE_single="cpu_cstate_log.txt"; char* CSTATE_LOGGING_FILE_dual="cpu_cstate_log_dual_%d.txt"; +char* CPU_TEMPERATURE_LOGGING_FILE_single="cpu_temperature_log.txt"; +char* CPU_TEMPERATURE_LOGGING_FILE_dual="cpu_temperature_log_dual_%d.txt"; int Single_Socket(); int Dual_Socket(); @@ -42,14 +44,19 @@ FILE *fp_log_file_freq_1, *fp_log_file_freq_2; FILE *fp_log_file_Cstates; FILE *fp_log_file_Cstates_1, *fp_log_file_Cstates_2; +FILE *fp_log_file_temperature; +FILE *fp_log_file_temperature_1, *fp_log_file_temperature_2; + void logOpenFile_single() { if(prog_options.logging==1) { fp_log_file_freq = fopen(CPU_FREQUENCY_LOGGING_FILE_single,"w"); fp_log_file_Cstates = fopen(CSTATE_LOGGING_FILE_single,"w"); + fp_log_file_temperature = fopen(CPU_TEMPERATURE_LOGGING_FILE_single, "w"); } else if(prog_options.logging==2) { fp_log_file_freq = fopen(CPU_FREQUENCY_LOGGING_FILE_single,"a"); fp_log_file_Cstates = fopen(CSTATE_LOGGING_FILE_single,"a"); + fp_log_file_temperature = fopen(CPU_TEMPERATURE_LOGGING_FILE_single, "a"); } } @@ -65,6 +72,9 @@ void logCloseFile_single() //the above line puts a \n after every CSTATE is logged. fclose(fp_log_file_Cstates); + fprintf(fp_log_file_temperature, "\n"); + //the above line puts a \n after every temperature is logged. + fclose(fp_log_file_temperature); } } @@ -77,6 +87,9 @@ void logOpenFile_dual(int socket_num) char str_file2[100]; snprintf(str_file2,100,CSTATE_LOGGING_FILE_dual,socket_num); + char str_file3[100]; + snprintf(str_file3,100,CPU_TEMPERATURE_LOGGING_FILE_dual,socket_num); + if(socket_num==0){ if(prog_options.logging==1) fp_log_file_freq_1 = fopen(str_file1,"w"); @@ -102,6 +115,19 @@ void logOpenFile_dual(int socket_num) else if(prog_options.logging==2) fp_log_file_Cstates_2 = fopen(str_file2,"a"); } + + if(socket_num==0){ + if(prog_options.logging==1) + fp_log_file_temperature_1 = fopen(str_file3,"w"); + else if(prog_options.logging==2) + fp_log_file_temperature_1 = fopen(str_file3,"a"); + } + if(socket_num==1){ + if(prog_options.logging==1) + fp_log_file_temperature_2 = fopen(str_file3,"w"); + else if(prog_options.logging==2) + fp_log_file_temperature_2 = fopen(str_file3,"a"); + } } void logCloseFile_dual(int socket_num) @@ -140,6 +166,23 @@ void logCloseFile_dual(int socket_num) fclose(fp_log_file_Cstates_2); } } + + if(socket_num==0){ + if(prog_options.logging!=0){ + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_1,"\n"); + //the above line puts a \n after every freq is logged. + fclose(fp_log_file_temperature_1); + } + } + if(socket_num==1){ + if(prog_options.logging!=0){ + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_2,"\n"); + //the above line puts a \n after every freq is logged. + fclose(fp_log_file_temperature_2); + } + } } @@ -377,6 +420,146 @@ void logCpuCstates_dual_ts(struct timespec *value, int socket_num) //HW use tim +void logCpuTemperature_single(float value) +{ + //below when just logging + if(prog_options.logging==1) { + fprintf(fp_log_file_temperature,"%f\n",value); //newline, replace \n with \t to get everything separated with tabs + } + //below when appending + if(prog_options.logging==2) { + fprintf(fp_log_file_temperature,"%f\t",value); + } +} + +void logCpuFTemperature_single_c(char* value) +{ + //below when just logging + if(prog_options.logging==1) { + fprintf(fp_log_file_temperature,"%s\n",value); //newline, replace \n with \t to get everything separated with tabs + } + //below when appending + if(prog_options.logging==2) { + fprintf(fp_log_file_temperature,"%s\t",value); + } +} + +void logCpuFTemperature_single_d(int value) +{ + //below when just logging + if(prog_options.logging==1) { + fprintf(fp_log_file_temperature,"%d\n",value); //newline, replace \n with \t to get everything separated with tabs + } + //below when appending + if(prog_options.logging==2) { + fprintf(fp_log_file_temperature,"%d\t",value); + } +} + +// fix for issue 48, suggested by Hakan +void logCpuTemperature_single_ts(struct timespec *value) //HW use timespec to avoid floating point overflow +{ + //below when just logging + if(prog_options.logging==1) { + fprintf(fp_log_file_temperature,"%d.%.9d\n",value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs + } + //below when appending + if(prog_options.logging==2) { + fprintf(fp_log_file_temperature,"%d.%.9d\t",value->tv_sec,value->tv_nsec); + } +} + + +void logCpuTemperature_dual(float value,int socket_num) +{ + if(socket_num==0){ + //below when just logging + if(prog_options.logging==1) + fprintf(fp_log_file_temperature_1,"%f\n",value); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_1,"%f\t",value); + } + if(socket_num==1){ + //below when just logging + if(prog_options.logging==1) + fprintf(fp_log_file_temperature_2,"%f\n",value); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_2,"%f\t",value); + } +} + +void logCpuTemperature_dual_c(char* value,int socket_num) +{ + if(socket_num==0){ + //below when just logging + if(prog_options.logging==1) + fprintf(fp_log_file_temperature_1,"%s\n",value); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_1,"%s\t",value); + } + if(socket_num==1){ + //below when just logging + if(prog_options.logging==1) + fprintf(fp_log_file_temperature_2,"%s\n",value); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_2,"%s\t",value); + } +} + +void logCpuTemperature_dual_d(int value,int socket_num) +{ + if(socket_num==0){ + //below when just logging + if(prog_options.logging==1) + fprintf(fp_log_file_temperature_1,"%d\n",value); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_1,"%d\t",value); + } + if(socket_num==1){ + //below when just logging + if(prog_options.logging==1) + fprintf(fp_log_file_temperature_2,"%d\n",value); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_2,"%d\t",value); + } +} + +void logCpuTemperature_dual_ts(struct timespec *value, int socket_num) //HW use timespec to avoid floating point overflow +{ + if(socket_num==0){ + //below when just logging + if(prog_options.logging==1) + fprintf(fp_log_file_temperature_1,"%d.%.9d\n",value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_1,"%d.%.9d\t",value->tv_sec,value->tv_nsec); + } + if(socket_num==1){ + //below when just logging + if(prog_options.logging==1) + fprintf(fp_log_file_temperature_2,"%d.%.9d\n",value->tv_sec,value->tv_nsec); //newline, replace \n with \t to get everything separated with tabs + + //below when appending + if(prog_options.logging==2) + fprintf(fp_log_file_temperature_2,"%d.%.9d\t",value->tv_sec,value->tv_nsec); + } +} + + + void atexit_runsttysane() { diff --git a/i7z.h b/i7z.h old mode 100644 new mode 100755 index 76c9b33..f0cee56 --- a/i7z.h +++ b/i7z.h @@ -64,6 +64,15 @@ void logCpuCstates_dual(float value, int); void logCpuCstates_dual_c(char* value, int); void logCpuCstates_dual_ts(struct timespec *value, int) ; +void logCpuTemperature_single(float value); +void logCpuTemperature_single_c(char* value); +void logCpuTemperature_single_d(int value); +void logCpuTemperature_single_ts(struct timespec *value) ; + +void logCpuTemperature_dual(float value, int); +void logCpuTemperature_dual_c(char* value, int); +void logCpuTemperature_dual_ts(struct timespec *value, int) ; + struct cpu_heirarchy_info { int max_online_cpu; int num_sockets; diff --git a/i7z_Dual_Socket.c b/i7z_Dual_Socket.c old mode 100644 new mode 100755 index 1388339..312b735 --- a/i7z_Dual_Socket.c +++ b/i7z_Dual_Socket.c @@ -587,6 +587,8 @@ void print_i7z_socket(struct cpu_socket_info socket_0, int printw_offset, int PL logCpuFreq_dual_ts(&global_ts, socket_0.socket_num); logCpuCstates_dual_ts(&global_ts, socket_0.socket_num); + + logCpuTemperature_dual_ts(&global_ts, socket_0.socket_num); for (ii = 0; ii < numCPUs; ii++) { @@ -600,6 +602,8 @@ void print_i7z_socket(struct cpu_socket_info socket_0, int printw_offset, int PL logCpuFreq_dual(_FREQ[i],socket_0.socket_num); } + logCpuTemperature_dual(Read_Thermal_Status_CPU(i), socket_0.socket_num); + logCpuCstates_dual_c(" [",socket_0.socket_num); logCpuCstates_dual((float)THRESHOLD_BETWEEN_0_100(C0_time[i] * 100),socket_0.socket_num); logCpuCstates_dual_c(",",socket_0.socket_num); //c1_time = C1_time[i] * 100 - (C3_time[i] + C6_time[i] + C7_time[i]) * 100; diff --git a/i7z_Single_Socket.c b/i7z_Single_Socket.c old mode 100644 new mode 100755 index 16e98c1..3f52ea1 --- a/i7z_Single_Socket.c +++ b/i7z_Single_Socket.c @@ -588,6 +588,8 @@ void print_i7z_socket_single(struct cpu_socket_info socket_0, int printw_offset, logCpuCstates_single_ts( &global_ts); + logCpuTemperature_single_ts( &global_ts); + for (ii = 0; ii < numCPUs; ii++) { assert(ii < MAX_SK_PROCESSORS); i = core_list[ii]; @@ -597,6 +599,9 @@ void print_i7z_socket_single(struct cpu_socket_info socket_0, int printw_offset, if ( (print_core[ii]) && !isinf(_FREQ[i]) ) { logCpuFreq_single(_FREQ[i]); } + + logCpuTemperature_single(Read_Thermal_Status_CPU(i)); + logCpuCstates_single_c(" ["); logCpuCstates_single((float)THRESHOLD_BETWEEN_0_100(C0_time[i] * 100)); logCpuCstates_single_c(","); c1_time = C1_time[i] * 100 - (C3_time[i] + C6_time[i] + C7_time[i]) * 100;