Skip to content
Snippets Groups Projects
Commit f75b1b3b authored by Georges Da Costa's avatar Georges Da Costa
Browse files

Changes types of most monitored values to u64

parent 43fdc72b
No related branches found
No related tags found
No related merge requests found
......@@ -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++;
}
......
......@@ -19,5 +19,5 @@
*******************************************************/
void init_load();
void get_load(long long* results);
void get_load(uint64_t* results);
void clean_load();
......@@ -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);
......
......@@ -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);
}
}
......
......@@ -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);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment