mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-13 22:50:33 +05:00
Fix compilation/conversion issues
This commit is contained in:
parent
f7467c4b34
commit
08d17a43e3
@ -8,13 +8,21 @@
|
|||||||
|
|
||||||
namespace ngcore {
|
namespace ngcore {
|
||||||
|
|
||||||
template <typename T>
|
// template <typename T>
|
||||||
uintptr_t mpi2ng(T t) {
|
// uintptr_t mpi2ng(T t) {
|
||||||
if constexpr (std::is_pointer_v<T>)
|
// if constexpr (std::is_pointer_v<T>)
|
||||||
return reinterpret_cast<uintptr_t>(t);
|
// return reinterpret_cast<uintptr_t>(t);
|
||||||
else
|
// else
|
||||||
return static_cast<uintptr_t>(t);
|
// return static_cast<uintptr_t>(t);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
int mpi2ng(int v) { return v; }
|
||||||
|
void* mpi2ng(void*p) { return p; }
|
||||||
|
|
||||||
|
// TODO: When we are dealing with arrays of multiple MPI_Status, we need to copy them together in continuous memory
|
||||||
|
NG_MPI_Status* mpi2ng(MPI_Status*p) { return reinterpret_cast<NG_MPI_Status*>(p); }
|
||||||
|
|
||||||
|
NG_MPI_Comm mpi2ng(MPI_Comm c) { return reinterpret_cast<uintptr_t>(c); }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T cast_ng2mpi(uintptr_t t) {
|
T cast_ng2mpi(uintptr_t t) {
|
||||||
@ -37,7 +45,16 @@ MPI_Comm ng2mpi(NG_MPI_Comm c) {
|
|||||||
return cast_ng2mpi<MPI_Comm>(c.value);
|
return cast_ng2mpi<MPI_Comm>(c.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MPI_Group ng2mpi(NG_MPI_Group c) {
|
||||||
|
static_assert(sizeof(MPI_Group) <= sizeof(c.value), "Size mismatch");
|
||||||
|
return cast_ng2mpi<MPI_Group>(c.value);
|
||||||
|
}
|
||||||
|
|
||||||
MPI_Comm* ng2mpi(NG_MPI_Comm* c) { return cast_ng2mpi<MPI_Comm*>(&c->value); }
|
MPI_Comm* ng2mpi(NG_MPI_Comm* c) { return cast_ng2mpi<MPI_Comm*>(&c->value); }
|
||||||
|
MPI_Group* ng2mpi(NG_MPI_Group* c) { return cast_ng2mpi<MPI_Group*>(&c->value); }
|
||||||
|
MPI_Datatype* ng2mpi(NG_MPI_Datatype* c) { return cast_ng2mpi<MPI_Datatype*>(&c->value); }
|
||||||
|
MPI_Request* ng2mpi(NG_MPI_Request* c) { return cast_ng2mpi<MPI_Request*>(&c->value); }
|
||||||
|
MPI_Status* ng2mpi(NG_MPI_Status* c) { return cast_ng2mpi<MPI_Status*>(&c->data[0]); }
|
||||||
|
|
||||||
MPI_Datatype ng2mpi(NG_MPI_Datatype c) {
|
MPI_Datatype ng2mpi(NG_MPI_Datatype c) {
|
||||||
static_assert(sizeof(MPI_Datatype) <= sizeof(c.value), "Size mismatch");
|
static_assert(sizeof(MPI_Datatype) <= sizeof(c.value), "Size mismatch");
|
||||||
@ -49,7 +66,15 @@ MPI_Request ng2mpi(NG_MPI_Request c) {
|
|||||||
return cast_ng2mpi<MPI_Request>(c.value);
|
return cast_ng2mpi<MPI_Request>(c.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MPI_Status* ng2mpi(NG_MPI_Status c) {
|
||||||
|
return cast_ng2mpi<MPI_Status*>(&c.data[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* ng2mpi(void* c) { return c; }
|
||||||
|
char* ng2mpi(char* c) { return c; }
|
||||||
|
char*** ng2mpi(char*** c) { return c; }
|
||||||
int* ng2mpi(int* c) { return c; }
|
int* ng2mpi(int* c) { return c; }
|
||||||
|
int ng2mpi(int c) { return c; }
|
||||||
|
|
||||||
} // namespace ngcore
|
} // namespace ngcore
|
||||||
|
|
||||||
|
@ -15,30 +15,36 @@ NGCORE_API extern std::string mpi_library_version;
|
|||||||
inline void not_implemented() { throw std::runtime_error("Not implemented"); }
|
inline void not_implemented() { throw std::runtime_error("Not implemented"); }
|
||||||
|
|
||||||
struct NG_MPI_Status {
|
struct NG_MPI_Status {
|
||||||
uint64_t data[4];
|
uintptr_t data[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NG_MPI_Comm {
|
struct NG_MPI_Comm {
|
||||||
uintptr_t value;
|
uintptr_t value;
|
||||||
NG_MPI_Comm() { value = 0;}
|
NG_MPI_Comm() { value = 0;}
|
||||||
NG_MPI_Comm(uintptr_t v) : value(v) {}
|
NG_MPI_Comm(uintptr_t v) : value(v) {}
|
||||||
|
|
||||||
|
void operator =(uintptr_t v) { value = v; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NG_MPI_Datatype {
|
struct NG_MPI_Datatype {
|
||||||
uintptr_t value;
|
uintptr_t value;
|
||||||
NG_MPI_Datatype(uintptr_t v) : value(v) {}
|
NG_MPI_Datatype(uintptr_t v) : value(v) {}
|
||||||
operator bool() const { return value != 0; }
|
operator bool() const { return value != 0; }
|
||||||
|
void operator =(uintptr_t v) { value = v; }
|
||||||
|
void operator =(void * v) { value = reinterpret_cast<uintptr_t>(v); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NG_MPI_Request {
|
struct NG_MPI_Request {
|
||||||
uintptr_t value = 0;
|
uintptr_t value = 0;
|
||||||
NG_MPI_Request(uintptr_t v) : value(v) {}
|
NG_MPI_Request(uintptr_t v) : value(v) {}
|
||||||
NG_MPI_Request() = default;
|
NG_MPI_Request() = default;
|
||||||
|
void operator =(uintptr_t v) { value = v; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NG_MPI_Op {
|
struct NG_MPI_Op {
|
||||||
uintptr_t value;
|
uintptr_t value;
|
||||||
NG_MPI_Op(uintptr_t v) : value(v) {}
|
NG_MPI_Op(uintptr_t v) : value(v) {}
|
||||||
|
void operator =(uintptr_t v) { value = v; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NG_MPI_Group {
|
struct NG_MPI_Group {
|
||||||
|
Loading…
Reference in New Issue
Block a user