From 9b8f273b141b3f938e8b90bb8d92b0e56e580a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Mon, 11 Feb 2019 22:12:29 +0100 Subject: [PATCH] mpiwrapper --- libsrc/core/mpi_wrapper.hpp | 7 ++++--- libsrc/general/mpi_interface.cpp | 3 +++ libsrc/general/mpi_interface.hpp | 5 +++-- libsrc/include/nginterface.h | 10 +++++----- libsrc/include/nginterface_v2.hpp | 8 ++++---- libsrc/meshing/global.cpp | 2 +- libsrc/meshing/global.hpp | 2 +- libsrc/meshing/meshclass.cpp | 2 +- libsrc/meshing/meshclass.hpp | 2 +- 9 files changed, 23 insertions(+), 18 deletions(-) diff --git a/libsrc/core/mpi_wrapper.hpp b/libsrc/core/mpi_wrapper.hpp index 6dca3f29..c072452b 100644 --- a/libsrc/core/mpi_wrapper.hpp +++ b/libsrc/core/mpi_wrapper.hpp @@ -40,7 +40,7 @@ namespace ngcore inline MPI_Datatype GetMPIType () { return MPI_typetrait::MPIType(); } - + class NgMPI_Comm { @@ -100,18 +100,19 @@ namespace ngcore #else + class MPI_Comm { }; class NgMPI_Comm { public: - NgMPI_Comm (int _comm, bool owns = false) + NgMPI_Comm (MPI_Comm _comm, bool owns = false) { ; } size_t Rank() const { return 0; } size_t Size() const { return 1; } - + operator MPI_Comm() const { return MPI_Comm(); } template void Send( T & val, int dest, int tag) { ; } diff --git a/libsrc/general/mpi_interface.cpp b/libsrc/general/mpi_interface.cpp index 3019cbf2..e16f6c8e 100644 --- a/libsrc/general/mpi_interface.cpp +++ b/libsrc/general/mpi_interface.cpp @@ -43,6 +43,9 @@ namespace netgen return string(buf); } + +#else + MPI_Comm MPI_COMM_WORLD, MPI_COMM_NULL; #endif diff --git a/libsrc/general/mpi_interface.hpp b/libsrc/general/mpi_interface.hpp index 5fee6ef9..ac54309d 100644 --- a/libsrc/general/mpi_interface.hpp +++ b/libsrc/general/mpi_interface.hpp @@ -19,7 +19,7 @@ namespace netgen #ifndef PARALLEL /** without MPI, we need a dummy typedef **/ - typedef int MPI_Comm; + // typedef int MPI_Comm; #endif /** This is the "standard" communicator that will be used for netgen-objects. **/ @@ -39,7 +39,8 @@ namespace netgen return id; } #else - enum { MPI_COMM_WORLD = 12345, MPI_COMM_NULL = 0}; + // enum { MPI_COMM_WORLD = 12345, MPI_COMM_NULL = 0}; + extern MPI_Comm MPI_COMM_WORLD, MPI_COMM_NULL; inline int MyMPI_GetNTasks (MPI_Comm comm = ng_comm) { return 1; } inline int MyMPI_GetId (MPI_Comm comm = ng_comm) { return 0; } #endif diff --git a/libsrc/include/nginterface.h b/libsrc/include/nginterface.h index 24e90cc1..22f416a1 100644 --- a/libsrc/include/nginterface.h +++ b/libsrc/include/nginterface.h @@ -37,10 +37,10 @@ // max number of nodes per surface element #define NG_SURFACE_ELEMENT_MAXPOINTS 8 -#ifndef PARALLEL - typedef int MPI_Comm; -#endif -namespace netgen { extern DLL_HEADER MPI_Comm ng_comm; } +// #ifndef PARALLEL +// typedef int MPI_Comm; +// #endif +namespace netgen { extern DLL_HEADER NgMPI_Comm ng_comm; } // implemented element types: @@ -66,7 +66,7 @@ extern "C" { DLL_HEADER void Ng_LoadGeometry (const char * filename); // load netgen mesh - DLL_HEADER void Ng_LoadMesh (const char * filename, MPI_Comm comm = netgen::ng_comm); + DLL_HEADER void Ng_LoadMesh (const char * filename, ngcore::NgMPI_Comm comm = netgen::ng_comm); // load netgen mesh DLL_HEADER void Ng_LoadMeshFromString (const char * mesh_as_string); diff --git a/libsrc/include/nginterface_v2.hpp b/libsrc/include/nginterface_v2.hpp index bd432a43..00d8f24a 100644 --- a/libsrc/include/nginterface_v2.hpp +++ b/libsrc/include/nginterface_v2.hpp @@ -26,9 +26,9 @@ enum NG_ELEMENT_TYPE { enum NG_REFINEMENT_TYPE { NG_REFINE_H = 0, NG_REFINE_P = 1, NG_REFINE_HP = 2 }; #endif -#ifndef PARALLEL - typedef int MPI_Comm; -#endif +// #ifndef PARALLEL +// typedef int MPI_Comm; +// #endif namespace netgen @@ -36,7 +36,7 @@ namespace netgen using namespace std; using namespace ngcore; - extern DLL_HEADER MPI_Comm ng_comm; + extern DLL_HEADER NgMPI_Comm ng_comm; static constexpr int POINTINDEX_BASE = 1; diff --git a/libsrc/meshing/global.cpp b/libsrc/meshing/global.cpp index 88cb7a38..eadb59fc 100644 --- a/libsrc/meshing/global.cpp +++ b/libsrc/meshing/global.cpp @@ -32,7 +32,7 @@ namespace netgen // TraceGlobal glob2("global2"); // global communicator for netgen - DLL_HEADER MyMPI_Comm ng_comm = MPI_COMM_WORLD; + DLL_HEADER NgMPI_Comm ng_comm = MPI_COMM_WORLD; weak_ptr global_mesh; void SetGlobalMesh (shared_ptr m) diff --git a/libsrc/meshing/global.hpp b/libsrc/meshing/global.hpp index c97815e3..aa7f7cd2 100644 --- a/libsrc/meshing/global.hpp +++ b/libsrc/meshing/global.hpp @@ -61,7 +61,7 @@ namespace netgen DLL_HEADER void SetGlobalMesh (shared_ptr m); // global communicator for netgen (dummy if no MPI) - extern DLL_HEADER MPI_Comm ng_comm; + extern DLL_HEADER NgMPI_Comm ng_comm; } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 3ba4c913..eeda22da 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -83,7 +83,7 @@ namespace netgen #endif } - void Mesh :: SetCommunicator(MPI_Comm acomm) + void Mesh :: SetCommunicator(NgMPI_Comm acomm) { this->comm = acomm; } diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 2aea32fe..0f88ddcd 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -33,7 +33,7 @@ namespace netgen T_POINTS points; // The communicator for this mesh. Just a dummy if compiled without MPI. - NgMPI_Comm comm; + NgMPI_Comm comm = MPI_COMM_NULL; /// line-segments at edges Array segments;