1 /*
2  * Copyright (c) 2016-2018 Inria. All rights reserved.
3  * Copyright (c) 2017      Research Organization for Information Science
4  *                         and Technology (RIST). All rights reserved.
5  * $COPYRIGHT$
6  *
7  * Additional copyrights may follow
8  *
9  * $HEADER$
10  */
11 
12 #include <ompi_config.h>
13 #include <ompi/request/request.h>
14 #include <ompi/datatype/ompi_datatype.h>
15 #include <ompi/communicator/communicator.h>
16 #include "coll_monitoring.h"
17 
mca_coll_monitoring_bcast(void * buff,int count,struct ompi_datatype_t * datatype,int root,struct ompi_communicator_t * comm,mca_coll_base_module_t * module)18 int mca_coll_monitoring_bcast(void *buff, int count,
19                               struct ompi_datatype_t *datatype,
20                               int root,
21                               struct ompi_communicator_t *comm,
22                               mca_coll_base_module_t *module)
23 {
24     mca_coll_monitoring_module_t*monitoring_module = (mca_coll_monitoring_module_t*) module;
25     size_t type_size, data_size;
26     const int comm_size = ompi_comm_size(comm);
27     ompi_datatype_type_size(datatype, &type_size);
28     data_size = count * type_size;
29     if( root == ompi_comm_rank(comm) ) {
30         int i, rank;
31         mca_common_monitoring_coll_o2a(data_size * (comm_size - 1), monitoring_module->data);
32         for( i = 0; i < comm_size; ++i ) {
33             if( i == root ) continue; /* No self sending */
34             /**
35              * If this fails the destination is not part of my MPI_COM_WORLD
36              * Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank
37              */
38             if( OPAL_SUCCESS == mca_common_monitoring_get_world_rank(i, comm->c_remote_group, &rank) ) {
39                 mca_common_monitoring_record_coll(rank, data_size);
40             }
41         }
42     }
43     return monitoring_module->real.coll_bcast(buff, count, datatype, root, comm, monitoring_module->real.coll_bcast_module);
44 }
45 
mca_coll_monitoring_ibcast(void * buff,int count,struct ompi_datatype_t * datatype,int root,struct ompi_communicator_t * comm,ompi_request_t ** request,mca_coll_base_module_t * module)46 int mca_coll_monitoring_ibcast(void *buff, int count,
47                                struct ompi_datatype_t *datatype,
48                                int root,
49                                struct ompi_communicator_t *comm,
50                                ompi_request_t ** request,
51                                mca_coll_base_module_t *module)
52 {
53     mca_coll_monitoring_module_t*monitoring_module = (mca_coll_monitoring_module_t*) module;
54     size_t type_size, data_size;
55     const int comm_size = ompi_comm_size(comm);
56     ompi_datatype_type_size(datatype, &type_size);
57     data_size = count * type_size;
58     if( root == ompi_comm_rank(comm) ) {
59         int i, rank;
60         mca_common_monitoring_coll_o2a(data_size * (comm_size - 1), monitoring_module->data);
61         for( i = 0; i < comm_size; ++i ) {
62             if( i == root ) continue; /* No self sending */
63             /**
64              * If this fails the destination is not part of my MPI_COM_WORLD
65              * Lookup its name in the rank hastable to get its MPI_COMM_WORLD rank
66              */
67             if( OPAL_SUCCESS == mca_common_monitoring_get_world_rank(i, comm->c_remote_group, &rank) ) {
68                 mca_common_monitoring_record_coll(rank, data_size);
69             }
70         }
71     }
72     return monitoring_module->real.coll_ibcast(buff, count, datatype, root, comm, request, monitoring_module->real.coll_ibcast_module);
73 }
74