![bosilca](/assets/img/avatar_default.png)
Add a monitoring PML, OSC and IO. They track all data exchanges between processes, with capability to include or exclude collective traffic. The monitoring infrastructure is driven using MPI_T, and can be tuned of and on any time o any communicators/files/windows. Documentations and examples have been added, as well as a shared library that can be used with LD_PRELOAD and that allows the monitoring of any application. Signed-off-by: George Bosilca <bosilca@icl.utk.edu> Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * add ability to querry pml monitorinting results with MPI Tools interface using performance variables "pml_monitoring_messages_count" and "pml_monitoring_messages_size" Signed-off-by: George Bosilca <bosilca@icl.utk.edu> * Fix a convertion problem and add a comment about the lack of component retain in the new component infrastructure. Signed-off-by: George Bosilca <bosilca@icl.utk.edu> * Allow the pvar to be written by invoking the associated callback. Signed-off-by: George Bosilca <bosilca@icl.utk.edu> * Various fixes for the monitoring. Allocate all counting arrays in a single allocation Don't delay the initialization (do it at the first add_proc as we know the number of processes in MPI_COMM_WORLD) Add a choice: with or without MPI_T (default). Signed-off-by: George Bosilca <bosilca@icl.utk.edu> * Cleanup for the monitoring module. Fixed few bugs, and reshape the operations to prepare for global or communicator-based monitoring. Start integrating support for MPI_T as well as MCA monitoring. Signed-off-by: George Bosilca <bosilca@icl.utk.edu> * Adding documentation about how to use pml_monitoring component. Document present the use with and without MPI_T. May not reflect exactly how it works right now, but should reflects how it should work in the end. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Change rank into MPI_COMM_WORLD and size(MPI_COMM_WORLD) to global variables in pml_monitoring.c. Change mca_pml_monitoring_flush() signature so we don't need the size and rank parameters. Signed-off-by: George Bosilca <bosilca@icl.utk.edu> * Improve monitoring support (including integration with MPI_T) Use mca_pml_monitoring_enable to check status state. Set mca_pml_monitoring_current_filename iif parameter is set Allow 3 modes for pml_monitoring_enable_output: - 1 : stdout; - 2 : stderr; - 3 : filename Fix test : 1 for differenciated messages, >1 for not differenciated. Fix output. Add documentation for pml_monitoring_enable_output parameter. Remove useless parameter in example Set filename only if using mpi tools Adding missing parameters for fprintf in monitoring_flush (for output in std's cases) Fix expected output/results for example header Fix exemple when using MPI_Tools : a null-pointer can't be passed directly. It needs to be a pointer to a null-pointer Base whether to output or not on message count, in order to print something if only empty messages are exchanged Add a new example on how to access performance variables from within the code Allocate arrays regarding value returned by binding Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add overhead benchmark, with script to use data and create graphs out of the results Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix segfault error at end when not loading pml Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Start create common monitoring module. Factorise version numbering Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix microbenchmarks script Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Improve readability of code NULL can't be passed as a PVAR parameter value. It must be a pointer to NULL or an empty string. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add osc monitoring component Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add error checking if running out of memory in osc_monitoring Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Resolve brutal segfault when double freeing filename Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Moving to ompi/mca/common the proper parts of the monitoring system Using common functions instead of pml specific one. Removing pml ones. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add calls to record monitored data from osc. Use common function to translate ranks. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix test_overhead benchmark script distribution Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix linking library with mca/common Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add passive operations in monitoring_test Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix from rank calculation. Add more detailed error messages Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix alignments. Fix common_monitoring_get_world_rank function. Remove useless trailing new lines Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix osc_monitoring mget_message_count function call Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Change common_monitoring function names to respect the naming convention. Move to common_finalize the common parts of finalization. Add some comments. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add monitoring common output system Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add error message when trying to flush to a file, and open fails. Remove erroneous info message when flushing wereas the monitoring is already disabled. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Consistent output file name (with and without MPI_T). Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Always output to a file when flushing at pvar_stop(flush). Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Update the monitoring documentation. Complete informations from HowTo. Fix a few mistake and typos. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Use the world_rank for printf's. Fix name generation for output files when using MPI_T. Minor changes in benchmarks starting script Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Clean potential previous runs, but keep the results at the end in order to potentially reprocess the data. Add comments. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add security check for unique initialization for osc monitoring Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Clean the amout of symbols available outside mca/common/monitoring Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Remove use of __sync_* built-ins. Use opal_atomic_* instead. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Allocate the hashtable on common/monitoring component initialization. Define symbols to set the values for error/warning/info verbose output. Use opal_atomic instead of built-in function in osc/monitoring template initialization. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Deleting now useless file : moved to common/monitoring Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add histogram ditribution of message sizes Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add histogram array of 2-based log of message sizes. Use simple call to reset/allocate arrays in common_monitoring.c Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add informations in dumping file. Separate per category (pt2pt/osc/coll (to come)) monitored data Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add coll component for collectives communications monitoring Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix warning messages : use c_name as the magic id is not always defined. Moreover, there was a % missing. Add call to release underlying modules. Add debug info messages. Add warning which may lead to further analysis. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix log10_2 constant initialization. Fix index calculation for histogram array. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add debug info messages to follow more easily initialization steps. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Group all the var/pvar definitions to common_monitoring. Separate initial filename from the current on, to ease its lifetime management. Add verifications to ensure common is initialized once only. Move state variable management to common_monitoring. monitoring_filter only indicates if filtering is activated. Fix out of range access in histogram. List is not used with the struct mca_monitoring_coll_data_t, so heritate only from opal_object_t. Remove useless dead code. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix invalid memory allocation. Initialize initial_filename to empty string to avoid invalid read in mca_base_var_register. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Don't install the test scripts. Signed-off-by: George Bosilca <bosilca@icl.utk.edu> Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix missing procs in hashtable. Cache coll monitoring data. * Add MCA_PML_BASE_FLAG_REQUIRE_WORLD flag to the PML layer. * Cache monitoring data relative to collectives operations on creation. * Remove double caching. * Use same proc name definition for hash table when inserting and when retrieving. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Use intermediate variable to avoid invalid write while retrieving ranks in hashtable. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add missing release of the last element in flush_all. Add release of the hashtable in finalize. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Use a linked list instead of a hashtable to keep tracks of communicator data. Add release of the structure at finalize time. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Set world_rank from hashtable only if found Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Use predefined symbol from opal system to print int Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Move collective monitoring data to a hashtable. Add pvar to access the monitoring_coll_data. Move functions header to a private file only to be used in ompi/mca/common/monitoring Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix pvar registration. Use OMPI_ERROR isntead of -1 as returned error value. Fix releasing of coll_data_t objects. Affect value only if data is found in the hashtable. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add automated check (with MPI_Tools) of monitoring. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix procs list caching in common_monitoring_coll_data_t * Fix monitoring_coll_data type definition. * Use size(COMM_WORLD)-1 to determine max number of digits. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add linking to Fortran applications for LD_PRELOAD usage of monitoring_prof Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add PVAR's handles. Clean up code (visibility, add comments...). Start updating the documentation Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix coll operations monitoring. Update check_monitoring accordingly to the added pvar. Fix monitoring array allocation. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Documentation update. Update and then move the latex and README documentation to a more logical place Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Aggregate monitoring COLL data to the generated matrix. Update documentation accordingly. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix monitoring_prof (bad variable.vector used, and wrong array in PMPI_Gather). Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add reduce_scatter and reduce_scatter_block monitoring. Reduce memory footprint of monitoring_prof. Unify OSC related outputs. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add the use of a machine file for overhead benchmark Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Check for out-of-bound write in histogram Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Fix common_monitoring_cache object init for MPI_COMM_WORLD Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add RDMA benchmarks to test_overhead Add error file output. Add MPI_Put and MPI_Get results analysis. Add overhead computation for complete sending (pingpong / 2). Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add computation of average and median of overheads. Add comments and copyrigths to the test_overhead script Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add technical documentation Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Adapt to the new definition of communicators Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Update expected output in test/monitoring/monitoring_test.c Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add dumping histogram in edge case Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Adding a reduce(pml_monitoring_messages_count, MPI_MAX) example Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add consistency in header inclusion. Include ompi/mpi/fortran/mpif-h/bindings.h only if needed. Add sanity check before emptying hashtable. Fix typos in documentation. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * misc monitoring fixes * test/monitoring: fix test when weak symbols are not available * monitoring: fix a typo and add a missing file in Makefile.am and have monitoring_common.h and monitoring_common_coll.h included in the distro * test/monitoring: cleanup all tests and make distclean a happy panda * test/monitoring: use gettimeofday() if clock_gettime() is unavailable * monitoring: silence misc warnings (#3) Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp> * Cleanups. Signed-off-by: George Bosilca <bosilca@icl.utk.edu> * Changing int64_t to size_t. Keep the size_t used accross all monitoring components. Adapt the documentation. Remove useless MPI_Request and MPI_Status from monitoring_test.c. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add parameter for RMA test case Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Clean the maximum bound computation for proc list dump. Use ptrdiff_t instead of OPAL_PTRDIFF_TYPE to reflect the changes from commit fa5cd0dbe5d261bd9d2cc61d5b305b4ef6a2dda6. Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add communicator-specific monitored collective data reset Signed-off-by: Clement Foyer <clement.foyer@inria.fr> * Add monitoring scripts to the 'make dist' Also install them in the build and the install directories. Signed-off-by: George Bosilca <bosilca@icl.utk.edu>
445 строки
19 KiB
C
445 строки
19 KiB
C
/*
|
|
* Copyright (c) 2013-2017 The University of Tennessee and The University
|
|
* of Tennessee Research Foundation. All rights
|
|
* reserved.
|
|
* Copyright (c) 2013-2017 Inria. All rights reserved.
|
|
* Copyright (c) 2013-2015 Bull SAS. All rights reserved.
|
|
* Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
|
|
* Copyright (c) 2017 Research Organization for Information Science
|
|
* and Technology (RIST). All rights reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
|
|
/*
|
|
pml monitoring PMPI profiler
|
|
|
|
Designed by:
|
|
George Bosilca <bosilca@icl.utk.edu>
|
|
Emmanuel Jeannot <emmanuel.jeannot@inria.fr>
|
|
Guillaume Papauré <guillaume.papaure@bull.net>
|
|
Clément Foyer <clement.foyer@inria.fr>
|
|
|
|
Contact the authors for questions.
|
|
|
|
To be run as:
|
|
|
|
mpirun -np 4 \
|
|
--mca pml_monitoring_enable 1 \
|
|
-x LD_PRELOAD=ompi_install_dir/lib/ompi_monitoring_prof.so \
|
|
./my_app
|
|
|
|
...
|
|
...
|
|
...
|
|
|
|
writing 4x4 matrix to monitoring_msg.mat
|
|
writing 4x4 matrix to monitoring_size.mat
|
|
writing 4x4 matrix to monitoring_avg.mat
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <mpi.h>
|
|
#include <string.h>
|
|
|
|
static MPI_T_pvar_session session;
|
|
static int comm_world_size;
|
|
static int comm_world_rank;
|
|
|
|
struct monitoring_result
|
|
{
|
|
char * pvar_name;
|
|
int pvar_idx;
|
|
MPI_T_pvar_handle pvar_handle;
|
|
size_t * vector;
|
|
};
|
|
typedef struct monitoring_result monitoring_result;
|
|
|
|
/* PML Sent */
|
|
static monitoring_result pml_counts;
|
|
static monitoring_result pml_sizes;
|
|
/* OSC Sent */
|
|
static monitoring_result osc_scounts;
|
|
static monitoring_result osc_ssizes;
|
|
/* OSC Recv */
|
|
static monitoring_result osc_rcounts;
|
|
static monitoring_result osc_rsizes;
|
|
/* COLL Sent/Recv */
|
|
static monitoring_result coll_counts;
|
|
static monitoring_result coll_sizes;
|
|
|
|
static int write_mat(char *, size_t *, unsigned int);
|
|
static void init_monitoring_result(const char *, monitoring_result *);
|
|
static void start_monitoring_result(monitoring_result *);
|
|
static void stop_monitoring_result(monitoring_result *);
|
|
static void get_monitoring_result(monitoring_result *);
|
|
static void destroy_monitoring_result(monitoring_result *);
|
|
|
|
int MPI_Init(int* argc, char*** argv)
|
|
{
|
|
int result, MPIT_result;
|
|
int provided;
|
|
|
|
result = PMPI_Init(argc, argv);
|
|
|
|
PMPI_Comm_size(MPI_COMM_WORLD, &comm_world_size);
|
|
PMPI_Comm_rank(MPI_COMM_WORLD, &comm_world_rank);
|
|
|
|
MPIT_result = MPI_T_init_thread(MPI_THREAD_SINGLE, &provided);
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
fprintf(stderr, "ERROR : failed to intialize MPI_T interface, preventing to get monitoring results: check your OpenMPI installation\n");
|
|
PMPI_Abort(MPI_COMM_WORLD, MPIT_result);
|
|
}
|
|
|
|
MPIT_result = MPI_T_pvar_session_create(&session);
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
fprintf(stderr, "ERROR : failed to create MPI_T session, preventing to get monitoring results: check your OpenMPI installation\n");
|
|
PMPI_Abort(MPI_COMM_WORLD, MPIT_result);
|
|
}
|
|
|
|
init_monitoring_result("pml_monitoring_messages_count", &pml_counts);
|
|
init_monitoring_result("pml_monitoring_messages_size", &pml_sizes);
|
|
init_monitoring_result("osc_monitoring_messages_sent_count", &osc_scounts);
|
|
init_monitoring_result("osc_monitoring_messages_sent_size", &osc_ssizes);
|
|
init_monitoring_result("osc_monitoring_messages_recv_count", &osc_rcounts);
|
|
init_monitoring_result("osc_monitoring_messages_recv_size", &osc_rsizes);
|
|
init_monitoring_result("coll_monitoring_messages_count", &coll_counts);
|
|
init_monitoring_result("coll_monitoring_messages_size", &coll_sizes);
|
|
|
|
start_monitoring_result(&pml_counts);
|
|
start_monitoring_result(&pml_sizes);
|
|
start_monitoring_result(&osc_scounts);
|
|
start_monitoring_result(&osc_ssizes);
|
|
start_monitoring_result(&osc_rcounts);
|
|
start_monitoring_result(&osc_rsizes);
|
|
start_monitoring_result(&coll_counts);
|
|
start_monitoring_result(&coll_sizes);
|
|
|
|
return result;
|
|
}
|
|
|
|
int MPI_Finalize(void)
|
|
{
|
|
int result, MPIT_result;
|
|
size_t * exchange_count_matrix_1 = NULL;
|
|
size_t * exchange_size_matrix_1 = NULL;
|
|
size_t * exchange_count_matrix_2 = NULL;
|
|
size_t * exchange_size_matrix_2 = NULL;
|
|
size_t * exchange_all_size_matrix = NULL;
|
|
size_t * exchange_all_count_matrix = NULL;
|
|
size_t * exchange_all_avg_matrix = NULL;
|
|
|
|
stop_monitoring_result(&pml_counts);
|
|
stop_monitoring_result(&pml_sizes);
|
|
stop_monitoring_result(&osc_scounts);
|
|
stop_monitoring_result(&osc_ssizes);
|
|
stop_monitoring_result(&osc_rcounts);
|
|
stop_monitoring_result(&osc_rsizes);
|
|
stop_monitoring_result(&coll_counts);
|
|
stop_monitoring_result(&coll_sizes);
|
|
|
|
get_monitoring_result(&pml_counts);
|
|
get_monitoring_result(&pml_sizes);
|
|
get_monitoring_result(&osc_scounts);
|
|
get_monitoring_result(&osc_ssizes);
|
|
get_monitoring_result(&osc_rcounts);
|
|
get_monitoring_result(&osc_rsizes);
|
|
get_monitoring_result(&coll_counts);
|
|
get_monitoring_result(&coll_sizes);
|
|
|
|
if (0 == comm_world_rank) {
|
|
exchange_count_matrix_1 = (size_t *) calloc(comm_world_size * comm_world_size, sizeof(size_t));
|
|
exchange_size_matrix_1 = (size_t *) calloc(comm_world_size * comm_world_size, sizeof(size_t));
|
|
exchange_count_matrix_2 = (size_t *) calloc(comm_world_size * comm_world_size, sizeof(size_t));
|
|
exchange_size_matrix_2 = (size_t *) calloc(comm_world_size * comm_world_size, sizeof(size_t));
|
|
exchange_all_size_matrix = (size_t *) calloc(comm_world_size * comm_world_size, sizeof(size_t));
|
|
exchange_all_count_matrix = (size_t *) calloc(comm_world_size * comm_world_size, sizeof(size_t));
|
|
exchange_all_avg_matrix = (size_t *) calloc(comm_world_size * comm_world_size, sizeof(size_t));
|
|
}
|
|
|
|
/* Gather PML and COLL results */
|
|
PMPI_Gather(pml_counts.vector, comm_world_size, MPI_UNSIGNED_LONG, exchange_count_matrix_1, comm_world_size, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);
|
|
PMPI_Gather(pml_sizes.vector, comm_world_size, MPI_UNSIGNED_LONG, exchange_size_matrix_1, comm_world_size, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);
|
|
PMPI_Gather(coll_counts.vector, comm_world_size, MPI_UNSIGNED_LONG, exchange_count_matrix_2, comm_world_size, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);
|
|
PMPI_Gather(coll_sizes.vector, comm_world_size, MPI_UNSIGNED_LONG, exchange_size_matrix_2, comm_world_size, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);
|
|
|
|
if (0 == comm_world_rank) {
|
|
int i, j;
|
|
|
|
for (i = 0; i < comm_world_size; ++i) {
|
|
for (j = i + 1; j < comm_world_size; ++j) {
|
|
/* Reduce PML results */
|
|
exchange_count_matrix_1[i * comm_world_size + j] = exchange_count_matrix_1[j * comm_world_size + i] = (exchange_count_matrix_1[i * comm_world_size + j] + exchange_count_matrix_1[j * comm_world_size + i]) / 2;
|
|
exchange_size_matrix_1[i * comm_world_size + j] = exchange_size_matrix_1[j * comm_world_size + i] = (exchange_size_matrix_1[i * comm_world_size + j] + exchange_size_matrix_1[j * comm_world_size + i]) / 2;
|
|
if (exchange_count_matrix_1[i * comm_world_size + j] != 0)
|
|
exchange_all_size_matrix[i * comm_world_size + j] = exchange_all_size_matrix[j * comm_world_size + i] = exchange_size_matrix_1[i * comm_world_size + j] / exchange_count_matrix_1[i * comm_world_size + j];
|
|
|
|
/* Reduce COLL results */
|
|
exchange_count_matrix_2[i * comm_world_size + j] = exchange_count_matrix_2[j * comm_world_size + i] = (exchange_count_matrix_2[i * comm_world_size + j] + exchange_count_matrix_2[j * comm_world_size + i]) / 2;
|
|
exchange_size_matrix_2[i * comm_world_size + j] = exchange_size_matrix_2[j * comm_world_size + i] = (exchange_size_matrix_2[i * comm_world_size + j] + exchange_size_matrix_2[j * comm_world_size + i]) / 2;
|
|
if (exchange_count_matrix_2[i * comm_world_size + j] != 0)
|
|
exchange_all_count_matrix[i * comm_world_size + j] = exchange_all_count_matrix[j * comm_world_size + i] = exchange_size_matrix_2[i * comm_world_size + j] / exchange_count_matrix_2[i * comm_world_size + j];
|
|
}
|
|
}
|
|
|
|
/* Write PML matrices */
|
|
write_mat("monitoring_pml_msg.mat", exchange_count_matrix_1, comm_world_size);
|
|
write_mat("monitoring_pml_size.mat", exchange_size_matrix_1, comm_world_size);
|
|
write_mat("monitoring_pml_avg.mat", exchange_all_size_matrix, comm_world_size);
|
|
|
|
/* Write COLL matrices */
|
|
write_mat("monitoring_coll_msg.mat", exchange_count_matrix_2, comm_world_size);
|
|
write_mat("monitoring_coll_size.mat", exchange_size_matrix_2, comm_world_size);
|
|
write_mat("monitoring_coll_avg.mat", exchange_all_count_matrix, comm_world_size);
|
|
|
|
/* Aggregate PML and COLL in ALL matrices */
|
|
for (i = 0; i < comm_world_size; ++i) {
|
|
for (j = i + 1; j < comm_world_size; ++j) {
|
|
exchange_all_size_matrix[i * comm_world_size + j] = exchange_all_size_matrix[j * comm_world_size + i] = exchange_size_matrix_1[i * comm_world_size + j] + exchange_size_matrix_2[i * comm_world_size + j];
|
|
exchange_all_count_matrix[i * comm_world_size + j] = exchange_all_count_matrix[j * comm_world_size + i] = exchange_count_matrix_1[i * comm_world_size + j] + exchange_count_matrix_2[i * comm_world_size + j];
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Gather OSC results */
|
|
PMPI_Gather(osc_scounts.vector, comm_world_size, MPI_UNSIGNED_LONG, exchange_count_matrix_1, comm_world_size, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);
|
|
PMPI_Gather(osc_ssizes.vector, comm_world_size, MPI_UNSIGNED_LONG, exchange_size_matrix_1, comm_world_size, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);
|
|
PMPI_Gather(osc_rcounts.vector, comm_world_size, MPI_UNSIGNED_LONG, exchange_count_matrix_2, comm_world_size, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);
|
|
PMPI_Gather(osc_rsizes.vector, comm_world_size, MPI_UNSIGNED_LONG, exchange_size_matrix_2, comm_world_size, MPI_UNSIGNED_LONG, 0, MPI_COMM_WORLD);
|
|
|
|
if (0 == comm_world_rank) {
|
|
int i, j;
|
|
|
|
for (i = 0; i < comm_world_size; ++i) {
|
|
for (j = i + 1; j < comm_world_size; ++j) {
|
|
/* Reduce OSC results */
|
|
exchange_count_matrix_1[i * comm_world_size + j] = exchange_count_matrix_1[j * comm_world_size + i] = (exchange_count_matrix_1[i * comm_world_size + j] + exchange_count_matrix_1[j * comm_world_size + i] + exchange_count_matrix_2[i * comm_world_size + j] + exchange_count_matrix_2[j * comm_world_size + i]) / 2;
|
|
exchange_size_matrix_1[i * comm_world_size + j] = exchange_size_matrix_1[j * comm_world_size + i] = (exchange_size_matrix_1[i * comm_world_size + j] + exchange_size_matrix_1[j * comm_world_size + i] + exchange_size_matrix_2[i * comm_world_size + j] + exchange_size_matrix_2[j * comm_world_size + i]) / 2;
|
|
if (exchange_count_matrix_1[i * comm_world_size + j] != 0)
|
|
exchange_all_avg_matrix[i * comm_world_size + j] = exchange_all_avg_matrix[j * comm_world_size + i] = exchange_size_matrix_1[i * comm_world_size + j] / exchange_count_matrix_1[i * comm_world_size + j];
|
|
}
|
|
}
|
|
|
|
/* Write OSC matrices */
|
|
write_mat("monitoring_osc_msg.mat", exchange_count_matrix_1, comm_world_size);
|
|
write_mat("monitoring_osc_size.mat", exchange_size_matrix_1, comm_world_size);
|
|
write_mat("monitoring_osc_avg.mat", exchange_all_avg_matrix, comm_world_size);
|
|
|
|
/* Aggregate OSC in ALL matrices and compute AVG */
|
|
for (i = 0; i < comm_world_size; ++i) {
|
|
for (j = i + 1; j < comm_world_size; ++j) {
|
|
exchange_all_size_matrix[i * comm_world_size + j] = exchange_all_size_matrix[j * comm_world_size + i] += exchange_size_matrix_1[i * comm_world_size + j];
|
|
exchange_all_count_matrix[i * comm_world_size + j] = exchange_all_count_matrix[j * comm_world_size + i] += exchange_count_matrix_1[i * comm_world_size + j];
|
|
if (exchange_all_count_matrix[i * comm_world_size + j] != 0)
|
|
exchange_all_avg_matrix[i * comm_world_size + j] = exchange_all_avg_matrix[j * comm_world_size + i] = exchange_all_size_matrix[i * comm_world_size + j] / exchange_all_count_matrix[i * comm_world_size + j];
|
|
}
|
|
}
|
|
|
|
/* Write ALL matrices */
|
|
write_mat("monitoring_all_msg.mat", exchange_all_count_matrix, comm_world_size);
|
|
write_mat("monitoring_all_size.mat", exchange_all_size_matrix, comm_world_size);
|
|
write_mat("monitoring_all_avg.mat", exchange_all_avg_matrix, comm_world_size);
|
|
|
|
/* Free matrices */
|
|
free(exchange_count_matrix_1);
|
|
free(exchange_size_matrix_1);
|
|
free(exchange_count_matrix_2);
|
|
free(exchange_size_matrix_2);
|
|
free(exchange_all_count_matrix);
|
|
free(exchange_all_size_matrix);
|
|
free(exchange_all_avg_matrix);
|
|
}
|
|
|
|
destroy_monitoring_result(&pml_counts);
|
|
destroy_monitoring_result(&pml_sizes);
|
|
destroy_monitoring_result(&osc_scounts);
|
|
destroy_monitoring_result(&osc_ssizes);
|
|
destroy_monitoring_result(&osc_rcounts);
|
|
destroy_monitoring_result(&osc_rsizes);
|
|
destroy_monitoring_result(&coll_counts);
|
|
destroy_monitoring_result(&coll_sizes);
|
|
|
|
MPIT_result = MPI_T_pvar_session_free(&session);
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
fprintf(stderr, "WARNING : failed to free MPI_T session, monitoring results may be impacted : check your OpenMPI installation\n");
|
|
}
|
|
|
|
MPIT_result = MPI_T_finalize();
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
fprintf(stderr, "WARNING : failed to finalize MPI_T interface, monitoring results may be impacted : check your OpenMPI installation\n");
|
|
}
|
|
|
|
result = PMPI_Finalize();
|
|
|
|
return result;
|
|
}
|
|
|
|
void init_monitoring_result(const char * pvar_name, monitoring_result * res)
|
|
{
|
|
int count;
|
|
int MPIT_result;
|
|
MPI_Comm comm_world = MPI_COMM_WORLD;
|
|
|
|
res->pvar_name = strdup(pvar_name);
|
|
|
|
MPIT_result = MPI_T_pvar_get_index(res->pvar_name, MPI_T_PVAR_CLASS_SIZE, &(res->pvar_idx));
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
fprintf(stderr, "ERROR : cannot find monitoring MPI_T \"%s\" pvar, check that you have monitoring pml\n", pvar_name);
|
|
PMPI_Abort(MPI_COMM_WORLD, MPIT_result);
|
|
}
|
|
|
|
MPIT_result = MPI_T_pvar_handle_alloc(session, res->pvar_idx, comm_world, &(res->pvar_handle), &count);
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
fprintf(stderr, "ERROR : failed to allocate handle on \"%s\" pvar, check that you have monitoring pml\n", pvar_name);
|
|
PMPI_Abort(MPI_COMM_WORLD, MPIT_result);
|
|
}
|
|
|
|
if (count != comm_world_size) {
|
|
fprintf(stderr, "ERROR : COMM_WORLD has %d ranks \"%s\" pvar contains %d values, check that you have monitoring pml\n", comm_world_size, pvar_name, count);
|
|
PMPI_Abort(MPI_COMM_WORLD, count);
|
|
}
|
|
|
|
res->vector = (size_t *) malloc(comm_world_size * sizeof(size_t));
|
|
}
|
|
|
|
void start_monitoring_result(monitoring_result * res)
|
|
{
|
|
int MPIT_result;
|
|
|
|
MPIT_result = MPI_T_pvar_start(session, res->pvar_handle);
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
fprintf(stderr, "ERROR : failed to start handle on \"%s\" pvar, check that you have enabled the monitoring pml\n", res->pvar_name);
|
|
PMPI_Abort(MPI_COMM_WORLD, MPIT_result);
|
|
}
|
|
}
|
|
|
|
void stop_monitoring_result(monitoring_result * res)
|
|
{
|
|
int MPIT_result;
|
|
|
|
MPIT_result = MPI_T_pvar_stop(session, res->pvar_handle);
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
fprintf(stderr, "ERROR : failed to stop handle on \"%s\" pvar, check that you have enabled the monitoring pml\n", res->pvar_name);
|
|
MPI_Abort(MPI_COMM_WORLD, MPIT_result);
|
|
}
|
|
}
|
|
|
|
void get_monitoring_result(monitoring_result * res)
|
|
{
|
|
int MPIT_result;
|
|
|
|
MPIT_result = MPI_T_pvar_read(session, res->pvar_handle, res->vector);
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
fprintf(stderr, "ERROR : failed to read \"%s\" pvar, check that you have enabled the monitoring pml\n", res->pvar_name);
|
|
PMPI_Abort(MPI_COMM_WORLD, MPIT_result);
|
|
}
|
|
}
|
|
|
|
void destroy_monitoring_result(monitoring_result * res)
|
|
{
|
|
int MPIT_result;
|
|
|
|
MPIT_result = MPI_T_pvar_handle_free(session, &(res->pvar_handle));
|
|
if (MPIT_result != MPI_SUCCESS) {
|
|
printf("ERROR : failed to free handle on \"%s\" pvar, check that you have enabled the monitoring pml\n", res->pvar_name);
|
|
MPI_Abort(MPI_COMM_WORLD, MPIT_result);
|
|
}
|
|
|
|
free(res->pvar_name);
|
|
free(res->vector);
|
|
}
|
|
|
|
int write_mat(char * filename, size_t * mat, unsigned int dim)
|
|
{
|
|
FILE *matrix_file;
|
|
int i, j;
|
|
|
|
matrix_file = fopen(filename, "w");
|
|
if (!matrix_file) {
|
|
fprintf(stderr, "ERROR : failed to open \"%s\" file in write mode, check your permissions\n", filename);
|
|
return -1;
|
|
}
|
|
|
|
printf("writing %ux%u matrix to %s\n", dim, dim, filename);
|
|
|
|
for (i = 0; i < comm_world_size; ++i) {
|
|
for (j = 0; j < comm_world_size; ++j) {
|
|
fprintf(matrix_file, "%zu ", mat[i * comm_world_size + j]);
|
|
}
|
|
fprintf(matrix_file, "\n");
|
|
}
|
|
fflush(matrix_file);
|
|
fclose(matrix_file);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* MPI binding for fortran
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include "ompi_config.h"
|
|
#include "opal/threads/thread_usage.h"
|
|
#include "ompi/mpi/fortran/base/constants.h"
|
|
#include "ompi/mpi/fortran/base/fint_2_int.h"
|
|
|
|
void monitoring_prof_mpi_init_f2c( MPI_Fint * );
|
|
void monitoring_prof_mpi_finalize_f2c( MPI_Fint * );
|
|
|
|
void monitoring_prof_mpi_init_f2c( MPI_Fint *ierr ) {
|
|
int c_ierr;
|
|
int argc = 0;
|
|
char ** argv = NULL;
|
|
|
|
c_ierr = MPI_Init(&argc, &argv);
|
|
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
|
|
}
|
|
|
|
void monitoring_prof_mpi_finalize_f2c( MPI_Fint *ierr ) {
|
|
int c_ierr;
|
|
|
|
c_ierr = MPI_Finalize();
|
|
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
|
|
}
|
|
|
|
#if OPAL_HAVE_WEAK_SYMBOLS
|
|
#pragma weak MPI_INIT = monitoring_prof_mpi_init_f2c
|
|
#pragma weak mpi_init = monitoring_prof_mpi_init_f2c
|
|
#pragma weak mpi_init_ = monitoring_prof_mpi_init_f2c
|
|
#pragma weak mpi_init__ = monitoring_prof_mpi_init_f2c
|
|
#pragma weak MPI_Init_f = monitoring_prof_mpi_init_f2c
|
|
#pragma weak MPI_Init_f08 = monitoring_prof_mpi_init_f2c
|
|
|
|
#pragma weak MPI_FINALIZE = monitoring_prof_mpi_finalize_f2c
|
|
#pragma weak mpi_finalize = monitoring_prof_mpi_finalize_f2c
|
|
#pragma weak mpi_finalize_ = monitoring_prof_mpi_finalize_f2c
|
|
#pragma weak mpi_finalize__ = monitoring_prof_mpi_finalize_f2c
|
|
#pragma weak MPI_Finalize_f = monitoring_prof_mpi_finalize_f2c
|
|
#pragma weak MPI_Finalize_f08 = monitoring_prof_mpi_finalize_f2c
|
|
#elif OMPI_BUILD_FORTRAN_BINDINGS
|
|
#define OMPI_F77_PROTOTYPES_MPI_H
|
|
#include "ompi/mpi/fortran/mpif-h/bindings.h"
|
|
|
|
OMPI_GENERATE_F77_BINDINGS (MPI_INIT,
|
|
mpi_init,
|
|
mpi_init_,
|
|
mpi_init__,
|
|
monitoring_prof_mpi_init_f2c,
|
|
(MPI_Fint *ierr),
|
|
(ierr) )
|
|
|
|
OMPI_GENERATE_F77_BINDINGS (MPI_FINALIZE,
|
|
mpi_finalize,
|
|
mpi_finalize_,
|
|
mpi_finalize__,
|
|
monitoring_prof_mpi_finalize_f2c,
|
|
(MPI_Fint *ierr),
|
|
(ierr) )
|
|
#endif
|