mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
FlatArray for C-array
This commit is contained in:
parent
94bed40761
commit
698192ed72
@ -450,6 +450,10 @@ namespace ngcore
|
|||||||
: size(asize), data (lh.Alloc<T> (asize))
|
: size(asize), data (lh.Alloc<T> (asize))
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
template <int N>
|
||||||
|
NETGEN_INLINE FlatArray(T (&ar)[N])
|
||||||
|
: size(N), data(ar) { }
|
||||||
|
|
||||||
/// the size
|
/// the size
|
||||||
NETGEN_INLINE size_t Size() const { return size; }
|
NETGEN_INLINE size_t Size() const { return size; }
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ namespace ngcore
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
||||||
MPI_Request ISend (const FlatArray<T> & s, int dest, int tag) const
|
MPI_Request ISend (FlatArray<T> s, int dest, int tag) const
|
||||||
{
|
{
|
||||||
MPI_Request request;
|
MPI_Request request;
|
||||||
MPI_Isend (s.Data(), s.Size(), GetMPIType<T>(), dest, tag, comm, &request);
|
MPI_Isend (s.Data(), s.Size(), GetMPIType<T>(), dest, tag, comm, &request);
|
||||||
@ -187,7 +187,7 @@ namespace ngcore
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
template<typename T, typename T2 = decltype(GetMPIType<T>())>
|
||||||
MPI_Request IRecv (const FlatArray<T> & s, int src, int tag) const
|
MPI_Request IRecv (FlatArray<T> s, int src, int tag) const
|
||||||
{
|
{
|
||||||
MPI_Request request;
|
MPI_Request request;
|
||||||
MPI_Irecv (s.Data(), s.Size(), GetMPIType<T>(), src, tag, comm, &request);
|
MPI_Irecv (s.Data(), s.Size(), GetMPIType<T>(), src, tag, comm, &request);
|
||||||
@ -330,13 +330,13 @@ namespace ngcore
|
|||||||
MPI_Request ISend (T & val, int dest, int tag) const { return 0; }
|
MPI_Request ISend (T & val, int dest, int tag) const { return 0; }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
MPI_Request ISend (const FlatArray<T> & s, int dest, int tag) const { return 0; }
|
MPI_Request ISend (FlatArray<T> s, int dest, int tag) const { return 0; }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
MPI_Request IRecv (T & val, int dest, int tag) const { return 0; }
|
MPI_Request IRecv (T & val, int dest, int tag) const { return 0; }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
MPI_Request IRecv (const FlatArray<T> & s, int src, int tag) const { return 0; }
|
MPI_Request IRecv (FlatArray<T> s, int src, int tag) const { return 0; }
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T Reduce (T d, const MPI_Op & op, int root = 0) const { return d; }
|
T Reduce (T d, const MPI_Op & op, int root = 0) const { return d; }
|
||||||
|
@ -740,7 +740,8 @@ namespace netgen
|
|||||||
nnames[3] = GetNCD3Names();
|
nnames[3] = GetNCD3Names();
|
||||||
int tot_nn = nnames[0] + nnames[1] + nnames[2] + nnames[3];
|
int tot_nn = nnames[0] + nnames[1] + nnames[2] + nnames[3];
|
||||||
for( int k = 1; k < ntasks; k++)
|
for( int k = 1; k < ntasks; k++)
|
||||||
(void) MPI_Isend(nnames, 4, MPI_INT, k, MPI_TAG_MESH+6, comm, &sendrequests[k]);
|
sendrequests[k] = comm.ISend(FlatArray(nnames), k, MPI_TAG_MESH+6);
|
||||||
|
// (void) MPI_Isend(nnames, 4, MPI_INT, k, MPI_TAG_MESH+6, comm, &sendrequests[k]);
|
||||||
auto iterate_names = [&](auto func) {
|
auto iterate_names = [&](auto func) {
|
||||||
for (int k = 0; k < nnames[0]; k++) func(materials[k]);
|
for (int k = 0; k < nnames[0]; k++) func(materials[k]);
|
||||||
for (int k = 0; k < nnames[1]; k++) func(bcnames[k]);
|
for (int k = 0; k < nnames[1]; k++) func(bcnames[k]);
|
||||||
@ -1013,7 +1014,9 @@ namespace netgen
|
|||||||
|
|
||||||
/** Recv bc-names **/
|
/** Recv bc-names **/
|
||||||
int nnames[4] = {0,0,0,0};
|
int nnames[4] = {0,0,0,0};
|
||||||
MPI_Recv(nnames, 4, MPI_INT, 0, MPI_TAG_MESH+6, comm, MPI_STATUS_IGNORE);
|
// MPI_Recv(nnames, 4, MPI_INT, 0, MPI_TAG_MESH+6, comm, MPI_STATUS_IGNORE);
|
||||||
|
comm.Recv(FlatArray(nnames), 0, MPI_TAG_MESH+6);
|
||||||
|
// cout << "nnames = " << FlatArray(nnames) << endl;
|
||||||
materials.SetSize(nnames[0]);
|
materials.SetSize(nnames[0]);
|
||||||
bcnames.SetSize(nnames[1]);
|
bcnames.SetSize(nnames[1]);
|
||||||
cd2names.SetSize(nnames[2]);
|
cd2names.SetSize(nnames[2]);
|
||||||
|
Loading…
Reference in New Issue
Block a user