X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParaMEDMEM%2FMPIProcessorGroup.cxx;h=1e40fd65d9cef1e6d976ec2b63aebdc69b9001df;hb=0bf52b9b294008eeb79b593572b035bff39bc7b7;hp=ee5b68ac96206739900783c5b1cc195cddd75241;hpb=3b1d77efdd048ef4aad858e96138bf79318119df;p=tools%2Fmedcoupling.git diff --git a/src/ParaMEDMEM/MPIProcessorGroup.cxx b/src/ParaMEDMEM/MPIProcessorGroup.cxx index ee5b68ac9..1e40fd65d 100644 --- a/src/ParaMEDMEM/MPIProcessorGroup.cxx +++ b/src/ParaMEDMEM/MPIProcessorGroup.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -92,6 +92,23 @@ namespace MEDCoupling } + /*! Creates a processor group that is based on the processors included in \a proc_ids_by_name[name]. + This routine must be called by all processors in MPI_COMM_WORLD. + + \param interface CommInterface object giving access to the MPI + communication layer + \param proc_ids_by_name a map defining a relation between a name and a set of ids that are to be integrated in the group. + The ids number are to be understood in terms of MPI_COMM_WORLD ranks. + \param simCodeTag identifier of the group + */ + + MPIProcessorGroup::MPIProcessorGroup(const CommInterface& interface, std::map> proc_ids_by_name, const std::string& simCodeTag, const MPI_Comm& world_comm): + ProcessorGroup(interface, proc_ids_by_name, simCodeTag), _world_comm(world_comm) + { + updateMPISpecificAttributes(); + } + + void MPIProcessorGroup::updateMPISpecificAttributes() { //Creation of a communicator @@ -115,7 +132,7 @@ namespace MEDCoupling throw INTERP_KERNEL::Exception("invalid rank in set argument of MPIProcessorGroup constructor"); } - _comm_interface.groupIncl(group_world, _proc_ids.size(), ranks, &_group); + _comm_interface.groupIncl(group_world, (int)_proc_ids.size(), ranks, &_group); _comm_interface.commCreate(_world_comm, _group, &_comm); @@ -181,10 +198,20 @@ namespace MEDCoupling MPIProcessorGroup::~MPIProcessorGroup() { - _comm_interface.groupFree(&_group); + release(); + } + + /** Destructor involves MPI operations: make sure this is accessible from a proper + * method for Python wrapping. + */ + void MPIProcessorGroup::release() + { + if (_group != MPI_GROUP_EMPTY) + _comm_interface.groupFree(&_group); + _group = MPI_GROUP_EMPTY; if (_comm!=_world_comm && _comm !=MPI_COMM_NULL) _comm_interface.commFree(&_comm); - + _comm = MPI_COMM_NULL; } /*! Translation of the rank id between two processor groups. This method translates rank \a rank