From ba8b586eeac1aeb50e36c63d7015d9249800150a Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 8 Feb 2013 12:47:59 +0000 Subject: [PATCH] 0021756: [CEA 602] MEDPartitioner improvements / Wrap Metis functions into a C function located in a MEDPARTITIONER_metis.c to avoid problems with Metis included in Parmetis-3 that campilation breaks at extern "C" {#include "metis.h"} because "metis.h" includes C++ declarations of MPI -#include "metis.h" +#include "MEDPARTITIONER_metis.h" --- .../MEDPARTITIONER_MetisGraph.cxx | 12 ++-- src/MEDPartitioner/MEDPARTITIONER_metis.c | 55 +++++++++++++++++++ src/MEDPartitioner/MEDPARTITIONER_metis.h | 30 ++++++++++ 3 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 src/MEDPartitioner/MEDPARTITIONER_metis.c create mode 100644 src/MEDPartitioner/MEDPARTITIONER_metis.h diff --git a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx index 5f89b9573..05a83a28b 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx @@ -25,12 +25,10 @@ #include -#ifdef MED_ENABLE_METIS extern "C" { -#include "metis.h" +#include "MEDPARTITIONER_metis.h" } -#endif using namespace MEDPARTITIONER; @@ -90,11 +88,11 @@ void METISGraph::partGraph(int ndomain, if (MyGlobals::_Verbose>10) std::cout << "METISGraph::partGraph METIS_PartGraph METIS_PartGraph(RecursiveOrKway)" << std::endl; if (options_string != "k") - METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, - &base, &nparts, options, &edgecut, partition); + MEDPARTITIONER_METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, + &base, &nparts, options, &edgecut, partition); else - METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, - &base, &nparts, options, &edgecut, partition); + MEDPARTITIONER_METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, + &base, &nparts, options, &edgecut, partition); } else //force this case because METIS send all 1 in value { diff --git a/src/MEDPartitioner/MEDPARTITIONER_metis.c b/src/MEDPartitioner/MEDPARTITIONER_metis.c new file mode 100644 index 000000000..ec8cde2bc --- /dev/null +++ b/src/MEDPartitioner/MEDPARTITIONER_metis.c @@ -0,0 +1,55 @@ +// Copyright (C) 2007-2012 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Creation of this C code is forced by the following. +// +// In case if Metis is a part of Parmetis V3, extern "C" {#include "metis.h"} causes +// inclusion of C++ code of MPI via parmetis.h <- mpi.h <- mpicxx.h +// that breaks compilation. To workaround this problem we create a wrapping C +// function, inclusion of whose declaration causes no problem. + +#include "MEDPARTITIONER_metis.h" + +#if defined(MED_ENABLE_METIS) + #include +#else + typedef int idxtype; +#endif + +void MEDPARTITIONER_METIS_PartGraphRecursive(int *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, + idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, + int *options, int *edgecut, idxtype *part) +{ +#if defined(MED_ENABLE_METIS) + METIS_PartGraphRecursive(nvtxs, xadj, adjncy, vwgt, + adjwgt, wgtflag, numflag, nparts, + options, edgecut, part); +#endif +} + +void MEDPARTITIONER_METIS_PartGraphKway(int *nvtxs, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, + idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, + int *options, int *edgecut, idxtype *part) +{ +#if defined(MED_ENABLE_METIS) + METIS_PartGraphKway(nvtxs, xadj, adjncy, vwgt, + adjwgt, wgtflag, numflag, nparts, + options, edgecut, part); +#endif +} diff --git a/src/MEDPartitioner/MEDPARTITIONER_metis.h b/src/MEDPartitioner/MEDPARTITIONER_metis.h new file mode 100644 index 000000000..6b2832d90 --- /dev/null +++ b/src/MEDPartitioner/MEDPARTITIONER_metis.h @@ -0,0 +1,30 @@ +// Copyright (C) 2007-2012 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// Creation of this C code is forced by the following. +// +// In case if Metis is a part of Parmetis V3, extern "C" {#include "metis.h"} causes +// inclusion of C++ code of MPI via parmetis.h <- mpi.h <- mpicxx.h +// that breaks compilation. To workaround this problem we create a wrapping C +// function, inclusion of whose declaration causes no problem. + + +void MEDPARTITIONER_METIS_PartGraphRecursive(int *, int *, int *, int *, int *, int *, int *, int *, int *, int *, int *); + +void MEDPARTITIONER_METIS_PartGraphKway(int *, int *, int *, int *, int *, int *, int *, int *, int *, int *, int *); -- 2.39.2