X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParaMEDMEM%2FMPIProcessorGroup.cxx;h=6e13d8502ff3222be94fdc90ac112182c0ba4bcf;hb=c41e6035d050073ea10040690daae247865b8b74;hp=cb96a69985c008e10847883e7dad5201fed09b35;hpb=378cb2ebe08f8f4543ef632b2bd5f77fe180f978;p=tools%2Fmedcoupling.git diff --git a/src/ParaMEDMEM/MPIProcessorGroup.cxx b/src/ParaMEDMEM/MPIProcessorGroup.cxx old mode 100755 new mode 100644 index cb96a6998..6e13d8502 --- a/src/ParaMEDMEM/MPIProcessorGroup.cxx +++ b/src/ParaMEDMEM/MPIProcessorGroup.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -29,39 +29,38 @@ using namespace std; -/*! \defgroup processor_group Processor Groups - * - * \section processor_group_overview Overview - * The MPIProcessorGroup class is used to set up processor groups that help to define - * the MPI topology of the couplings. They can be set up in various ways, the most common being - * the use of the \c MPIProcessorGroup(Comminterface, int pfirst, int plast) - * constructor. - * - * The following code excerpt creates two processor groups on respectively 3 and 2 processors. - \verbatim - int main() - { - MPI_Init(&argc,&argv); - CommInterface comm_interface; - MPIProcessorGroup codeA_group(comm_interface, 0, 2); - MPIProcessorGroup codeB_group(comm_interface, 3, 4); - - ... - } - \endverbatim -*/ - -namespace ParaMEDMEM +namespace MEDCoupling { - /*! - \addtogroup processor_group - @{ + /*! + \anchor MPIProcessorGroup-det + \class MPIProcessorGroup + + The MPIProcessorGroup class represents a set of distinct "processors" (computation nodes) + in a MPI code. It is used to define the MPI topology of code couplings. + + Groups can be set up in various ways, the most common being + the use of the \c MPIProcessorGroup(Comminterface, int pfirst, int plast) + constructor. + + The following code excerpt creates two processor groups on respectively 3 and 2 processors. + \verbatim + int main() + { + MPI_Init(&argc,&argv); + CommInterface comm_interface; + MPIProcessorGroup codeA_group(comm_interface, 0, 2); // groups processors 0, 1 and 2 + MPIProcessorGroup codeB_group(comm_interface, 3, 4); // groups processors 3 and 4 + + ... + } + \endverbatim */ + /*! * Creates a processor group that is based on all the - MPI_COMM_WORLD processor.This routine must be called by all processors in MPI_COMM_WORLD. + processors of MPI_COMM_WORLD .This routine must be called by all processors in MPI_COMM_WORLD. \param interface CommInterface object giving access to the MPI communication layer */ @@ -87,7 +86,7 @@ namespace ParaMEDMEM */ MPIProcessorGroup::MPIProcessorGroup(const CommInterface& interface, set proc_ids, const MPI_Comm& world_comm): - ProcessorGroup(interface, proc_ids),_world_comm(world_comm) + ProcessorGroup(interface, proc_ids), _world_comm(world_comm) { updateMPISpecificAttributes(); } @@ -110,12 +109,19 @@ namespace ParaMEDMEM copy::const_iterator,int*> (_proc_ids.begin(), _proc_ids.end(), ranks); for (int i=0; i< (int)_proc_ids.size();i++) if (ranks[i]>size_world-1) - throw INTERP_KERNEL::Exception("invalid rank in set argument of MPIProcessorGroup constructor"); + { + delete[] ranks; + _comm_interface.groupFree(&group_world); // MPI_Group is a C structure and won't get de-allocated automatically? + throw INTERP_KERNEL::Exception("invalid rank in set argument of MPIProcessorGroup constructor"); + } _comm_interface.groupIncl(group_world, _proc_ids.size(), ranks, &_group); _comm_interface.commCreate(_world_comm, _group, &_comm); + + // clean-up delete[] ranks; + _comm_interface.groupFree(&group_world); // MPI_Group is a C structure and won't get de-allocated automatically? } /*! Creates a processor group that is based on the processors between \a pstart and \a pend. @@ -138,7 +144,10 @@ namespace ParaMEDMEM _comm_interface.commGroup(_world_comm, &group_world); if (pend>size_world-1 || pend proc_ids) : - ProcessorGroup(proc_group.getCommInterface()),_world_comm(MPI_COMM_WORLD) + ProcessorGroup(proc_group.getCommInterface()), + _world_comm(MPI_COMM_WORLD), _group(MPI_GROUP_NULL), _comm(MPI_COMM_NULL) { cout << "MPIProcessorGroup (const ProcessorGroup& proc_group, set proc_ids)" < procs;