Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add back logging CPU temperature feature #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions i7z.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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");
}
}

Expand All @@ -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);
}
}

Expand All @@ -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");
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}
}


Expand Down Expand Up @@ -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()
{
Expand Down
9 changes: 9 additions & 0 deletions i7z.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions i7z_Dual_Socket.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions i7z_Single_Socket.c
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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;
Expand Down