diff --git a/counters.h b/counters.h index d919c951305549a5f3b3ff2f9fd587e192f4e6b9..15926127826cb8745e740cd315eef88617112835 100644 --- a/counters.h +++ b/counters.h @@ -26,4 +26,4 @@ counter_t init_counters(const int nb_perf, const __u32 *types, const __u64 *name void clean_counters(counter_t fd); void start_counters(counter_t fd); void reset_counters(counter_t fd); -void get_counters(counter_t fd, long long *values); +void get_counters(counter_t fd, uint64_t *values); diff --git a/counters_individual.c b/counters_individual.c index f9648702ba4e8ce155a05d2197e687357ad90350..2d20e915386433c6feeaa39816e39044461a6291 100644 --- a/counters_individual.c +++ b/counters_individual.c @@ -26,6 +26,7 @@ #include <stdio.h> #include <stdint.h> #include <asm/unistd.h> +#include <stdint.h> #include "counters.h" @@ -91,19 +92,21 @@ void reset_counters(counter_t counters) { ioctl(counters->counters[counter][core], PERF_EVENT_IOC_RESET, 0); } -void get_counters(counter_t counters, long long *values) { +void get_counters(counter_t counters, uint64_t *values) { //memset(values, 0, nb_perf*sizeof(long long)); for(int i=0; i<counters->nbperf; i++) { - long long accu=0; - long long count; + uint64_t accu=0; + uint64_t count=0; for (int core=0; core<counters->nbcores; core++) { - if (-1 == read(counters->counters[i][core], &count, sizeof(long long))) { + if (-1 == read(counters->counters[i][core], &count, sizeof(uint64_t))) { fprintf(stderr, "PB Lecture resultat"); exit(EXIT_FAILURE); } accu += count; } + printf("%lu! \n", accu); + values[i] = accu; } - reset_counters(counters); + //reset_counters(counters); } diff --git a/makefile b/makefile index 759677ecda3abe16a7e3b1a92bf4975465ea806e..23c02dc6d9dc9dfba711565ad5eef2707aaa2934 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ all: mojitos -OBJECTS = mojitos.o counters_individual.o counters.h rapl.o network.o load.o infiniband.o +OBJECTS = mojitos.o counters_individual.o rapl.o network.o load.o infiniband.o mojitos:$(OBJECTS) counters_option.h gcc $(DEBUG) -O3 -Wall -o mojitos $(OBJECTS) -lpowercap diff --git a/mojitos.c b/mojitos.c index fe26e93a7efb5e053e6f354758ab5b5a031f7ab4..23908c5ff3e2f699e77684721317537818d30e80 100644 --- a/mojitos.c +++ b/mojitos.c @@ -221,9 +221,9 @@ int main(int argc, char **argv) { // prepare rapl data stores rapl_size = rapl->nb * sizeof(uint64_t); //rapl_values = malloc(rapl_size); - rapl_values = calloc(sizeof(char), rapl_size); + rapl_values = calloc(sizeof(uint64_t), rapl_size); //tmp_rapl_values = malloc(rapl_size); - tmp_rapl_values = calloc(sizeof(char), rapl_size); + tmp_rapl_values = calloc(sizeof(uint64_t), rapl_size); // initialize with dummy values get_rapl(rapl_values, rapl); } @@ -231,13 +231,16 @@ int main(int argc, char **argv) { __u32* perf_type; __u64* perf_key; counter_t fd=0; - long long *counter_values=NULL; + uint64_t *counter_values=NULL; + uint64_t *tmp_counter_values=NULL; if(perf_mode==0) { perf_type_key(&perf_type, &perf_key, perf_indexes, nb_perf); fd = init_counters(nb_perf, perf_type, perf_key); - reset_counters(fd); - // reading HPC will reset their values so no need for a buffer - counter_values = malloc(nb_perf*sizeof(long long)); + + counter_values = malloc(nb_perf*sizeof(uint64_t)); + tmp_counter_values = malloc(nb_perf*sizeof(uint64_t)); + + get_counters(fd, counter_values); } struct timespec ts; struct timespec ts_ref; @@ -272,7 +275,7 @@ int main(int argc, char **argv) { // Get Data if(perf_mode==0) - get_counters(fd, counter_values); + get_counters(fd, tmp_counter_values); if(dev != NULL) get_network(tmp_network_values, network_sources); if(infi_path != NULL) @@ -316,7 +319,7 @@ int main(int argc, char **argv) { } if(perf_mode==0) for(int i=0; i<nb_perf;i++) - fprintf(output, "%lld ", counter_values[i]); + fprintf(output, "%" PRIu64 " ", tmp_counter_values[i]-counter_values[i]); if(dev != NULL) for(int i=0; i<4; i++) fprintf(output, "%" PRIu64 " ", tmp_network_values[i]-network_values[i]); @@ -337,6 +340,8 @@ int main(int argc, char **argv) { if(application != NULL) break; + if(perf_mode==0) + memcpy(counter_values, tmp_counter_values, nb_perf*sizeof(uint64_t)); if(rapl_mode==0) memcpy(rapl_values, tmp_rapl_values, rapl_size); if(load_mode==0) @@ -363,6 +368,7 @@ int main(int argc, char **argv) { if(perf_mode==0){ clean_counters(fd); free(counter_values); + free(tmp_counter_values); free(perf_type); free(perf_key); free(perf_indexes);