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

Changes the type for performance counters to uint64

parent a51c4116
Branches
Tags
No related merge requests found
......@@ -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);
......@@ -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);
}
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
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment