diff --git a/mpiP-histogram.c b/mpiP-histogram.c new file mode 100644 index 0000000..8f9d595 --- /dev/null +++ b/mpiP-histogram.c @@ -0,0 +1,32 @@ +#include "mpiP-histogram.h" + +void +init_histogram (mpiPi_histogram_t * h, int first_bin_max, int size, + int *intervals) +{ + h->first_bin_max = first_bin_max; + h->hist_size = size; + h->bin_intervals = intervals; +} + +static int +get_histogram_bin (mpiPi_histogram_t * h, int val) +{ + int wv = val; + int bin; + + bin = 0; + + if (h->bin_intervals == NULL) + { + while (wv > h->first_bin_max && bin < h->hist_size) + { + wv >>= 1; + bin++; + } + } + else /* Add code for custom intervals later */ + { + } + return bin; +} diff --git a/mpiP-histogram.h b/mpiP-histogram.h new file mode 100644 index 0000000..1a12cca --- /dev/null +++ b/mpiP-histogram.h @@ -0,0 +1,17 @@ +#ifndef MPIPHISTOGRAM_H +#define MPIPHISTOGRAM_H + +#include + +typedef struct _mpiPi_histogram +{ + int first_bin_max; + int hist_size; + int *bin_intervals; +} mpiPi_histogram_t; + +void init_histogram (mpiPi_histogram_t * h, int first_bin_max, int size, + int *intervals); +static int get_histogram_bin (mpiPi_histogram_t * h, int val); + +#endif // MPIPHISTOGRAM_H diff --git a/mpiP-statistics.c b/mpiP-statistics.c new file mode 100644 index 0000000..b3455d2 --- /dev/null +++ b/mpiP-statistics.c @@ -0,0 +1,96 @@ + + +static int +mpiPi_callsite_stats_pc_hashkey (const void *p) +{ + int res = 0; + int i; + callsite_stats_t *csp = (callsite_stats_t *) p; + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp); + for (i = 0; i < MPIP_CALLSITE_STACK_DEPTH; i++) + { + res ^= (unsigned) (long) csp->pc[i]; + } + return 52271 ^ csp->op ^ res ^ csp->rank; +} + +static int +mpiPi_callsite_stats_pc_comparator (const void *p1, const void *p2) +{ + int i; + callsite_stats_t *csp_1 = (callsite_stats_t *) p1; + callsite_stats_t *csp_2 = (callsite_stats_t *) p2; + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp_1); + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp_2); + +#define express(f) {if ((csp_1->f) > (csp_2->f)) {return 1;} if ((csp_1->f) < (csp_2->f)) {return -1;}} + express (op); + express (rank); + + for (i = 0; i < MPIP_CALLSITE_STACK_DEPTH; i++) + { + express (pc[i]); + } +#undef express + + return 0; +} + +static int +mpiPi_callsite_stats_src_hashkey (const void *p) +{ + int res = 0; + callsite_stats_t *csp = (callsite_stats_t *) p; + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp); + return 52271 ^ csp->op ^ res ^ csp->rank ^ csp->csid; +} + +static int +mpiPi_callsite_stats_src_comparator (const void *p1, const void *p2) +{ + callsite_stats_t *csp_1 = (callsite_stats_t *) p1; + callsite_stats_t *csp_2 = (callsite_stats_t *) p2; + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp_1); + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp_2); + +#define express(f) {if ((csp_1->f) > (csp_2->f)) {return 1;} if ((csp_1->f) < (csp_2->f)) {return -1;}} + express (op); + express (csid); + express (rank); +#undef express + + return 0; +} + +static int +mpiPi_callsite_stats_MPI_id_hashkey (const void *p) +{ + callsite_stats_t *csp = (callsite_stats_t *) p; + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp); + return 52271 ^ csp->op; +} + +static int +mpiPi_callsite_stats_src_id_hashkey (const void *p) +{ + int res = 0; + callsite_stats_t *csp = (callsite_stats_t *) p; + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp); + return 52271 ^ csp->op ^ res ^ csp->csid; +} + +static int +mpiPi_callsite_stats_src_id_comparator (const void *p1, const void *p2) +{ + callsite_stats_t *csp_1 = (callsite_stats_t *) p1; + callsite_stats_t *csp_2 = (callsite_stats_t *) p2; + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp_1); + MPIP_CALLSITE_STATS_COOKIE_ASSERT (csp_2); + +#define express(f) {if ((csp_1->f) > (csp_2->f)) {return 1;} if ((csp_1->f) < (csp_2->f)) {return -1;}} + express (op); + express (csid); +#undef express + + return 0; +} diff --git a/mpiP-statistics.h b/mpiP-statistics.h new file mode 100644 index 0000000..03a8327 --- /dev/null +++ b/mpiP-statistics.h @@ -0,0 +1,33 @@ +#ifndef MPIPCALLSITE_STATS_H +#define MPIPCALLSITE_STATS_H + +typedef struct _callsite_stats +{ + unsigned op; + unsigned rank; + int csid; + long long count; + double cumulativeTime; + double cumulativeTimeSquared; + double maxDur; + double minDur; + double maxDataSent; + double minDataSent; + double maxIO; + double minIO; + double maxRMA; + double minRMA; + double cumulativeDataSent; + double cumulativeIO; + double cumulativeRMA; + long long arbitraryMessageCount; + double *siteData; + int siteDataIdx; + void *pc[MPIP_CALLSITE_STACK_DEPTH_MAX]; + char *filename[MPIP_CALLSITE_STACK_DEPTH_MAX]; + char *functname[MPIP_CALLSITE_STACK_DEPTH_MAX]; + int lineno[MPIP_CALLSITE_STACK_DEPTH_MAX]; + long cookie; +} callsite_stats_t; + +#endif // MPIPCALLSITE_STATS_H diff --git a/mpiP-threads.h b/mpiP-threads.h index d1bc339..290d4a0 100644 --- a/mpiP-threads.h +++ b/mpiP-threads.h @@ -2,8 +2,9 @@ #define MPIP_THREADS_H #include "mpiPi_def.h" -#include "thread_safe_list.h" +#include "mpiP-tslist.h" #include "mpiP-hash.h" +#include "mpiP-statistics.h" typedef struct { int enabled; diff --git a/thread_safe_list.c b/mpiP-tslist.c similarity index 99% rename from thread_safe_list.c rename to mpiP-tslist.c index bb29afe..e971b0d 100644 --- a/thread_safe_list.c +++ b/mpiP-tslist.c @@ -16,7 +16,7 @@ #include #include #include "arch.h" -#include "thread_safe_list.h" +#include "mpiP-tslist.h" mpiP_tslist_t *mpiP_tslist_create() { diff --git a/thread_safe_list.h b/mpiP-tslist.h similarity index 100% rename from thread_safe_list.h rename to mpiP-tslist.h diff --git a/mpiPi.c b/mpiPi.c index 244edfb..a49561d 100644 --- a/mpiPi.c +++ b/mpiPi.c @@ -1225,31 +1225,6 @@ mpiPi_update_callsite_stats (unsigned op, unsigned rank, void **pc, return; } - -static int -get_histogram_bin (mpiPi_histogram_t * h, int val) -{ - int wv = val; - int bin; - - bin = 0; - - if (h->bin_intervals == NULL) - { - while (wv > h->first_bin_max && bin < h->hist_size) - { - wv >>= 1; - bin++; - } - } - else /* Add code for custom intervals later */ - { - } - - return bin; -} - - void mpiPi_update_collective_stats (int op, double dur, double size, MPI_Comm * comm)