diff --git a/load.c b/load.c index 06b984953980721023c4431089c3b23e264256b0..4147c5b097710e4e3d4ff8370af48ef01752c326 100644 --- a/load.c +++ b/load.c @@ -20,6 +20,7 @@ #include <unistd.h> #include <fcntl.h> #include <stdlib.h> +#include <stdint.h> #define LOAD_BUFFER_SIZE 1024 char buffer[LOAD_BUFFER_SIZE]; @@ -30,12 +31,12 @@ void init_load() { load_fid = open("/proc/stat", O_RDONLY); } -void get_load(long long* results) { +void get_load(uint64_t* results) { pread(load_fid, buffer, LOAD_BUFFER_SIZE-1, 0); int pos=0; while(buffer[pos] > '9' || buffer[pos] < '0') pos++; for(int i=0; i<10; i++) { - results[i] = atoll(buffer+pos); + results[i] = strtoull(buffer+pos, NULL, 10); while(buffer[pos] <= '9' && buffer[pos] >= '0') pos++; pos++; } diff --git a/load.h b/load.h index 1d344cfff91290610429dd43d4f02920eb876fda..f2850073c45eefd7117e293edf8c976e2e2fe20d 100644 --- a/load.h +++ b/load.h @@ -19,5 +19,5 @@ *******************************************************/ void init_load(); -void get_load(long long* results); +void get_load(uint64_t* results); void clean_load(); diff --git a/mojitos.c b/mojitos.c index bd9e04e2c73e8916a4bebc74f0d1ff137be68b7f..f4a16ae99983020c6efea1bec66e9ce2476c8325 100644 --- a/mojitos.c +++ b/mojitos.c @@ -90,7 +90,7 @@ void perf_event_list(char *perf_string, int *nb_perf, int **perf_indexes) { int load_mode = -1; void usage(char** argv) { - printf("Usage : %s [-t time] [-f freq] [-r] [-p perf_list] [-l] [-u] [-d network_device] [-i infiniband_path] [-o logfile] [-e command arguments...]\n", argv[0]); + printf("Usage : %s [-t time] [-f freq] [-r] [-p perf_list] [-l] [-u] [-c] [-d network_device] [-i infiniband_path] [-o logfile] [-e command arguments...]\n", argv[0]); printf("if time==0 then loops infinitively\n"); printf("if -e is present, time and freq are not used\n"); printf("-r activates RAPL\n"); @@ -101,6 +101,7 @@ void usage(char** argv) { printf("-i activates infiniband monitoring (if infiniband_path is X, tries to detect it automatically)\n"); printf("-s activates statistics of overhead in nanoseconds\n"); printf("-u activates report of system load\n"); + printf("-c activates report of processor temperature\n"); exit(EXIT_SUCCESS); } @@ -191,8 +192,8 @@ int main(int argc, char **argv) { int *network_sources = NULL; if(dev != NULL) network_sources = init_network(dev); - long long network_values[4]={0,0,0,0}; - long long tmp_network_values[4]={0,0,0,0}; + uint64_t network_values[4]={0,0,0,0}; + uint64_t tmp_network_values[4]={0,0,0,0}; get_network(network_values, network_sources); int * infiniband_sources = NULL; @@ -200,13 +201,13 @@ int main(int argc, char **argv) { infiniband_sources = init_infiniband(infi_path); if(infiniband_sources == NULL) infi_path = NULL; - long long infiniband_values[4]={0,0,0,0}; - long long tmp_infiniband_values[4]={0,0,0,0}; + uint64_t infiniband_values[4]={0,0,0,0}; + uint64_t tmp_infiniband_values[4]={0,0,0,0}; get_network(infiniband_values, infiniband_sources); // Load initialization - long long load_values[10]={0,0,0,0,0,0,0,0,0,0}; - long long tmp_load_values[10]={0,0,0,0,0,0,0,0,0,0}; + uint64_t load_values[10]={0,0,0,0,0,0,0,0,0,0}; + uint64_t tmp_load_values[10]={0,0,0,0,0,0,0,0,0,0}; if(load_mode == 0) { init_load(); get_load(load_values); @@ -320,16 +321,16 @@ int main(int argc, char **argv) { fprintf(output, "%lld ", counter_values[i]); if(dev != NULL) for(int i=0; i<4; i++) - fprintf(output, "%lld ", tmp_network_values[i]-network_values[i]); + fprintf(output, "%" PRIu64 " ", tmp_network_values[i]-network_values[i]); if(infi_path != NULL) for(int i=0; i<4; i++) - fprintf(output, "%lld ", tmp_infiniband_values[i]-infiniband_values[i]); + fprintf(output, "%" PRIu64 " ", tmp_infiniband_values[i]-infiniband_values[i]); if(rapl_mode==0) for (int r=0; r<rapl->nb; r++) fprintf(output, "%" PRIu64 " ", tmp_rapl_values[r]-rapl_values[r]); if(load_mode==0) for(int i=0; i<10; i++) - fprintf(output, "%lld ", tmp_load_values[i]-load_values[i]); + fprintf(output, "%" PRIu64 " ", tmp_load_values[i]-load_values[i]); if(stat_mode==0) fprintf(output, "%ld ", stat_data); diff --git a/network.c b/network.c index 92e8b46c26407a45c7a78070b2cd99f50978522d..f3f8b3c43e1eace354aa8cbe2dd4e94234f85c3d 100644 --- a/network.c +++ b/network.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <stdint.h> int *init_network(char* dev) { if(dev==NULL) @@ -52,13 +53,16 @@ int *init_network(char* dev) { return sources; } -void get_network(long long* results, int *sources) { +void get_network(uint64_t* results, int *sources) { if(sources==NULL) return; char buffer[128]; for(int i=0; i<4; i++){ pread(sources[i], buffer, 127, 0); - results[i] = atoll(buffer); + + results[i] = strtoull(buffer, NULL, 10); + + //results[i] = atoll(buffer); } } diff --git a/network.h b/network.h index 385562d0d70873b71a68e02aa772587af7c8095a..7ff14ba3e81052135745fe9bcf35bdce1beb61ee 100644 --- a/network.h +++ b/network.h @@ -19,5 +19,5 @@ *******************************************************/ int *init_network(char* dev); -void get_network(long long* results, int * sources); +void get_network(uint64_t* results, int * sources); void clean_network(int *sources);