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

Adds monitoring for infiniband

parent f085d558
No related branches found
No related tags found
No related merge requests found
/*******************************************************
Copyright (C) 2018-2020 Georges Da Costa <georges.da-costa@irit.fr>
This file is part of Mojitos.
Mojitos is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Mojitos is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <https://www.gnu.org/licenses/>.
*******************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glob.h>
char **init_infiniband(char* infi_path) {
if(infi_path==NULL)
return NULL;
if(strcmp(infi_path,"X")==0) {
glob_t res;
glob("/sys/class/infiniband/*/ports/*/counters/", 0, NULL, &res);
infi_path = res.gl_pathv[0];
}
char *filenames[] = {"%s/port_rcv_packets",
"%s/port_rcv_data",
"%s/port_xmit_packets",
"%s/port_xmit_data"};
char** sources = malloc(sizeof(char*)*4);
for(int i=0; i<4; i++) {
sources[i] = malloc(200);
sprintf(sources[i], filenames[i], infi_path);
}
return sources;
}
/* void get_network(long long* results, char** sources) { */
/* if(sources==NULL) */
/* return; */
/* for(int i=0; i<4; i++){ */
/* FILE* f = fopen(sources[i], "rb"); */
/* fscanf(f, "%lld", &results[i]); */
/* fclose(f); */
/* } */
/* } */
/* void clean_network(char **sources) { */
/* if(sources==NULL) */
/* return; */
/* for(int i=0;i<4;i++) */
/* free(sources[i]); */
/* free(sources); */
/* } */
/*******************************************************
Copyright (C) 2018-2019 Georges Da Costa <georges.da-costa@irit.fr>
This file is part of Mojitos.
Mojitos is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Mojitos is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <https://www.gnu.org/licenses/>.
*******************************************************/
char **init_infiniband(char* infi_path);
all: mojitos all: mojitos
OBJECTS = mojitos.o counters_individual.o counters.h rapl.o rapl.h network.h network.o load.o OBJECTS = mojitos.o counters_individual.o counters.h rapl.o rapl.h network.h network.o load.o infiniband.o
mojitos:$(OBJECTS) counters_option.h mojitos:$(OBJECTS) counters_option.h
gcc $(DEBUG) -O3 -Wall -o mojitos $(OBJECTS) -lpowercap gcc $(DEBUG) -O3 -Wall -o mojitos $(OBJECTS) -lpowercap
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "counters.h" #include "counters.h"
#include "rapl.h" #include "rapl.h"
#include "network.h" #include "network.h"
#include "infiniband.h"
#include "load.h" #include "load.h"
int rapl_mode=-1; int rapl_mode=-1;
...@@ -88,14 +89,15 @@ void perf_event_list(char *perf_string, int *nb_perf, int **perf_indexes) { ...@@ -88,14 +89,15 @@ void perf_event_list(char *perf_string, int *nb_perf, int **perf_indexes) {
int load_mode = -1; int load_mode = -1;
void usage(char** argv) { void usage(char** argv) {
printf("Usage : %s [-t time] [-f freq] [-r] [-p perf_list] [-l] [-u] [-d network_device] [-o logfile] [-e command arguments...]\n", argv[0]); 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("if time==0 then loops infinitively\n"); printf("if time==0 then loops infinitively\n");
printf("if -e is present, time and freq are not used\n"); printf("if -e is present, time and freq are not used\n");
printf("-r activates RAPL\n"); printf("-r activates RAPL\n");
printf("-p activates performance counters\n"); printf("-p activates performance counters\n");
printf(" perf_list is coma separated list of performance counters without space. Ex: instructions,cache_misses\n"); printf(" perf_list is coma separated list of performance counters without space. Ex: instructions,cache_misses\n");
printf("-l lists the possible performance counters and quits\n"); printf("-l lists the possible performance counters and quits\n");
printf("-d activates network monitoring (if network_device is X tries to detect it automatically)\n"); printf("-d activates network monitoring (if network_device is X, tries to detect it automatically)\n");
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("-s activates statistics of overhead in nanoseconds\n");
printf("-u activates report of system load\n"); printf("-u activates report of system load\n");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
...@@ -123,6 +125,7 @@ int main(int argc, char **argv) { ...@@ -123,6 +125,7 @@ int main(int argc, char **argv) {
int delta=0; int delta=0;
int frequency=1; int frequency=1;
char *dev = NULL; char *dev = NULL;
char *infi_path = NULL;
char **application = NULL; char **application = NULL;
if(argc==1) if(argc==1)
...@@ -134,7 +137,7 @@ int main(int argc, char **argv) { ...@@ -134,7 +137,7 @@ int main(int argc, char **argv) {
signal(15, flush); signal(15, flush);
int c; int c;
while ((c = getopt (argc, argv, "lhftdeoprsu")) != -1 && application==NULL) while ((c = getopt (argc, argv, "ilhftdeoprsu")) != -1 && application==NULL)
switch (c) { switch (c) {
case 'f': case 'f':
frequency=atoi(argv[optind]); frequency=atoi(argv[optind]);
...@@ -150,6 +153,9 @@ int main(int argc, char **argv) { ...@@ -150,6 +153,9 @@ int main(int argc, char **argv) {
case 'd': case 'd':
dev = argv[optind]; dev = argv[optind];
break; break;
case 'i':
infi_path = argv[optind];
break;
case 'o': case 'o':
output = fopen(argv[optind],"wb"); output = fopen(argv[optind],"wb");
break; break;
...@@ -188,6 +194,13 @@ int main(int argc, char **argv) { ...@@ -188,6 +194,13 @@ int main(int argc, char **argv) {
long long tmp_network_values[4]={0,0,0,0}; long long tmp_network_values[4]={0,0,0,0};
get_network(network_values, network_sources); get_network(network_values, network_sources);
char ** infiniband_sources = NULL;
if(infi_path != NULL)
infiniband_sources = init_infiniband(infi_path);
long long infiniband_values[4]={0,0,0,0};
long long tmp_infiniband_values[4]={0,0,0,0};
get_network(infiniband_values, infiniband_sources);
// Load initialization // Load initialization
long long load_values[10]={0,0,0,0,0,0,0,0,0,0}; 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}; long long tmp_load_values[10]={0,0,0,0,0,0,0,0,0,0};
...@@ -229,6 +242,8 @@ int main(int argc, char **argv) { ...@@ -229,6 +242,8 @@ int main(int argc, char **argv) {
fprintf(output, "%s ", perf_static_info[perf_indexes[i]].name); fprintf(output, "%s ", perf_static_info[perf_indexes[i]].name);
if(dev!=NULL) if(dev!=NULL)
fprintf(output, "rxp rxb txp txb "); fprintf(output, "rxp rxb txp txb ");
if(infi_path!=NULL)
fprintf(output, "irxp irxb itxp itxb ");
if(rapl_mode==0) if(rapl_mode==0)
for (int r=0; r<rapl->nbpackages*rapl->nbzones; r++) for (int r=0; r<rapl->nbpackages*rapl->nbzones; r++)
...@@ -254,6 +269,9 @@ int main(int argc, char **argv) { ...@@ -254,6 +269,9 @@ int main(int argc, char **argv) {
get_counters(fd, counter_values); get_counters(fd, counter_values);
if(dev != NULL) if(dev != NULL)
get_network(tmp_network_values, network_sources); get_network(tmp_network_values, network_sources);
if(infi_path != NULL)
get_network(tmp_infiniband_values, infiniband_sources);
if(rapl_mode==0) if(rapl_mode==0)
get_rapl(tmp_rapl_values, rapl); get_rapl(tmp_rapl_values, rapl);
if(load_mode==0) if(load_mode==0)
...@@ -296,6 +314,9 @@ int main(int argc, char **argv) { ...@@ -296,6 +314,9 @@ int main(int argc, char **argv) {
if(dev != NULL) if(dev != NULL)
for(int i=0; i<4; i++) for(int i=0; i<4; i++)
fprintf(output, "%lld ", tmp_network_values[i]-network_values[i]); fprintf(output, "%lld ", 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]);
if(rapl_mode==0) if(rapl_mode==0)
for (int r=0; r<rapl->nbpackages*rapl->nbzones; r++) for (int r=0; r<rapl->nbpackages*rapl->nbzones; r++)
fprintf(output, "%ld ", tmp_rapl_values[r]-rapl_values[r]); fprintf(output, "%ld ", tmp_rapl_values[r]-rapl_values[r]);
...@@ -316,6 +337,8 @@ int main(int argc, char **argv) { ...@@ -316,6 +337,8 @@ int main(int argc, char **argv) {
memcpy(load_values, tmp_load_values, sizeof(load_values)); memcpy(load_values, tmp_load_values, sizeof(load_values));
if(dev !=NULL) if(dev !=NULL)
memcpy(network_values, tmp_network_values, sizeof(network_values)); memcpy(network_values, tmp_network_values, sizeof(network_values));
if(infi_path !=NULL)
memcpy(infiniband_values, tmp_infiniband_values, sizeof(infiniband_values));
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);
usleep(1000*1000/frequency-(ts.tv_nsec/1000)%(1000*1000/frequency)); usleep(1000*1000/frequency-(ts.tv_nsec/1000)%(1000*1000/frequency));
} }
...@@ -327,6 +350,8 @@ int main(int argc, char **argv) { ...@@ -327,6 +350,8 @@ int main(int argc, char **argv) {
} }
if(dev!=NULL) if(dev!=NULL)
clean_network(network_sources); clean_network(network_sources);
if(infi_path!=NULL)
clean_network(infiniband_sources);
if(perf_mode==0){ if(perf_mode==0){
clean_counters(fd); clean_counters(fd);
free(counter_values); free(counter_values);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment