FlatArray for C-array

This commit is contained in:
Joachim Schöberl 2020-08-03 14:45:32 +02:00
parent 94bed40761
commit 698192ed72
3 changed files with 13 additions and 6 deletions

View File

@ -450,6 +450,10 @@ namespace ngcore
: size(asize), data (lh.Alloc<T> (asize))
{ ; }
template <int N>
NETGEN_INLINE FlatArray(T (&ar)[N])
: size(N), data(ar) { }
/// the size
NETGEN_INLINE size_t Size() const { return size; }

View File

@ -171,7 +171,7 @@ namespace ngcore
}
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_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>())>
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_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; }
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>
MPI_Request IRecv (T & val, int dest, int tag) const { return 0; }
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>
T Reduce (T d, const MPI_Op & op, int root = 0) const { return d; }

View File

@ -740,7 +740,8 @@ namespace netgen
nnames[3] = GetNCD3Names();
int tot_nn = nnames[0] + nnames[1] + nnames[2] + nnames[3];
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) {
for (int k = 0; k < nnames[0]; k++) func(materials[k]);
for (int k = 0; k < nnames[1]; k++) func(bcnames[k]);
@ -1013,7 +1014,9 @@ namespace netgen
/** Recv bc-names **/
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]);
bcnames.SetSize(nnames[1]);
cd2names.SetSize(nnames[2]);