From f75b1b3b183f4d5ceb1bc2553cb8c14454bf70c0 Mon Sep 17 00:00:00 2001 From: Georges Da Costa <dacosta@irit.fr> Date: Wed, 17 Mar 2021 20:36:28 +0100 Subject: [PATCH] Changes types of most monitored values to u64 --- load.c | 5 +++-- load.h | 2 +- mojitos.c | 21 +++++++++++---------- network.c | 8 ++++++-- network.h | 2 +- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/load.c b/load.c index 06b9849..4147c5b 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 1d344cf..f285007 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 bd9e04e..f4a16ae 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 92e8b46..f3f8b3c 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 385562d..7ff14ba 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); -- GitLab