mpiwrapper

This commit is contained in:
Joachim Schöberl 2019-02-11 22:12:29 +01:00
parent 7aa5c536a8
commit 9b8f273b14
9 changed files with 23 additions and 18 deletions

View File

@ -40,7 +40,7 @@ namespace ngcore
inline MPI_Datatype GetMPIType () {
return MPI_typetrait<T>::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<typename T>
void Send( T & val, int dest, int tag) { ; }

View File

@ -43,6 +43,9 @@ namespace netgen
return string(buf);
}
#else
MPI_Comm MPI_COMM_WORLD, MPI_COMM_NULL;
#endif

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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<Mesh> global_mesh;
void SetGlobalMesh (shared_ptr<Mesh> m)

View File

@ -61,7 +61,7 @@ namespace netgen
DLL_HEADER void SetGlobalMesh (shared_ptr<Mesh> m);
// global communicator for netgen (dummy if no MPI)
extern DLL_HEADER MPI_Comm ng_comm;
extern DLL_HEADER NgMPI_Comm ng_comm;
}

View File

@ -83,7 +83,7 @@ namespace netgen
#endif
}
void Mesh :: SetCommunicator(MPI_Comm acomm)
void Mesh :: SetCommunicator(NgMPI_Comm acomm)
{
this->comm = acomm;
}

View File

@ -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<Segment, 0, size_t> segments;