Nektar++
Comm.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: Comm.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Base communication class
32//
33///////////////////////////////////////////////////////////////////////////////
34#ifndef NEKTAR_LIB_UTILITIES_COMM_H
35#define NEKTAR_LIB_UTILITIES_COMM_H
36
37#include <memory>
38#include <type_traits>
39#include <utility>
40#include <vector>
41
44
48
49namespace Nektar
50{
51namespace LibUtilities
52{
53// Forward declarations
54class Comm;
55
56/// Pointer to a Communicator object.
57typedef std::shared_ptr<Comm> CommSharedPtr;
58
59/// Datatype of the NekFactory used to instantiate classes derived from
60/// the EquationSystem class.
62
64
65/// Type of operation to perform in AllReduce.
67{
72};
73
74const char *const ReduceOperatorMap[] = {"ReduceSum", "ReduceMax", "ReduceMin"};
75
76/// Class for communicator request type
78{
79public:
80 /// Default constructor
81 CommRequest() = default;
82 /// Default destructor
83 virtual ~CommRequest() = default;
84};
85
86typedef std::shared_ptr<CommRequest> CommRequestSharedPtr;
87
88/// Base communications class
89class Comm : public std::enable_shared_from_this<Comm>
90{
91public:
92 LIB_UTILITIES_EXPORT Comm(int narg, char *arg[]);
94
95 LIB_UTILITIES_EXPORT inline void Finalise();
96
97 /// Returns number of processes
98 LIB_UTILITIES_EXPORT inline int GetSize() const;
99 LIB_UTILITIES_EXPORT inline int GetRank();
100 LIB_UTILITIES_EXPORT inline const std::string &GetType() const;
101
103 LIB_UTILITIES_EXPORT inline bool IsSerial();
104 LIB_UTILITIES_EXPORT inline std::tuple<int, int, int> GetVersion();
105
106 /// Block execution until all processes reach this point
107 LIB_UTILITIES_EXPORT inline void Block();
108
109 /// Return the time in seconds
111
112 template <class T> void Send(int pProc, T &pData);
113 template <class T> void Recv(int pProc, T &pData);
114 template <class T>
115 void SendRecv(int pSendProc, T &pSendData, int pRecvProc, T &pRecvData);
116
117 template <class T> void AllReduce(T &pData, enum ReduceOperator pOp);
118
119 template <class T> void AlltoAll(T &pSendData, T &pRecvData);
120 template <class T1, class T2>
121 void AlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap, T2 &pSendDataOffsetMap,
122 T1 &pRecvData, T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap);
123
124 template <class T> void AllGather(T &pSendData, T &pRecvData);
125 template <class T>
126 void AllGatherv(T &pSendData, T &pRecvData,
127 Array<OneD, int> &pRecvDataSizeMap,
128 Array<OneD, int> &pRecvDataOffsetMap);
129 template <class T>
130 void AllGatherv(T &pRecvData, Array<OneD, int> &pRecvDataSizeMap,
131 Array<OneD, int> &pRecvDataOffsetMap);
132
133 template <class T> void Bcast(T &pData, int pRoot);
134 template <class T> T Gather(int rootProc, T &val);
135 template <class T> T Scatter(int rootProc, T &pData);
136
137 template <class T>
138 void DistGraphCreateAdjacent(T &sources, T &sourceweights, int reorder);
139 template <class T1, class T2>
140 void NeighborAlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap,
141 T2 &pSendDataOffsetMap, T1 &pRecvData,
142 T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap);
143
144 template <class T>
145 void Irsend(int pProc, T &pData, int count,
146 const CommRequestSharedPtr &request, int loc);
147 template <class T>
148 void Isend(int pProc, T &pData, int count,
149 const CommRequestSharedPtr &request, int loc);
150 template <class T>
151 void SendInit(int pProc, T &pData, int count,
152 const CommRequestSharedPtr &request, int loc);
153 template <class T>
154 void Irecv(int pProc, T &pData, int count,
155 const CommRequestSharedPtr &request, int loc);
156 template <class T>
157 void RecvInit(int pProc, T &pData, int count,
158 const CommRequestSharedPtr &request, int loc);
159
160 inline void StartAll(const CommRequestSharedPtr &request);
161 inline void WaitAll(const CommRequestSharedPtr &request);
162
163 inline CommRequestSharedPtr CreateRequest(int num);
165 LIB_UTILITIES_EXPORT inline void SplitComm(int pRows, int pColumns,
166 int pTime = 1);
172 LIB_UTILITIES_EXPORT inline std::pair<CommSharedPtr, CommSharedPtr>
174
175protected:
176 int m_size; ///< Number of processes
177 std::string m_type; ///< Type of communication
178 CommSharedPtr m_commRow; ///< Row communicator
179 CommSharedPtr m_commColumn; ///< Column communicator
182
183 Comm();
184
185 virtual void v_Finalise() = 0;
186 virtual int v_GetRank() = 0;
187 virtual bool v_TreatAsRankZero() = 0;
188 virtual bool v_IsSerial() = 0;
189 virtual std::tuple<int, int, int> v_GetVersion() = 0;
190 virtual void v_Block() = 0;
191 virtual NekDouble v_Wtime() = 0;
192 virtual void v_Send(void *buf, int count, CommDataType dt, int dest) = 0;
193 virtual void v_Recv(void *buf, int count, CommDataType dt, int source) = 0;
194 virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype,
195 int dest, void *recvbuf, int recvcount,
196 CommDataType recvtype, int source) = 0;
197 virtual void v_AllReduce(void *buf, int count, CommDataType dt,
198 enum ReduceOperator pOp) = 0;
199 virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype,
200 void *recvbuf, int recvcount,
201 CommDataType recvtype) = 0;
202 virtual void v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[],
203 CommDataType sendtype, void *recvbuf,
204 int recvcounts[], int rdispls[],
205 CommDataType recvtype) = 0;
206 virtual void v_AllGather(void *sendbuf, int sendcount,
207 CommDataType sendtype, void *recvbuf,
208 int recvcount, CommDataType recvtype) = 0;
209 virtual void v_AllGatherv(void *sendbuf, int sendcount,
210 CommDataType sendtype, void *recvbuf,
211 int recvcounts[], int rdispls[],
212 CommDataType recvtype) = 0;
213 virtual void v_AllGatherv(void *recvbuf, int recvcounts[], int rdispls[],
214 CommDataType recvtype) = 0;
215 virtual void v_Bcast(void *buffer, int count, CommDataType dt,
216 int root) = 0;
217 virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype,
218 void *recvbuf, int recvcount, CommDataType recvtype,
219 int root) = 0;
220 virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype,
221 void *recvbuf, int recvcount, CommDataType recvtype,
222 int root) = 0;
223
224 virtual void v_DistGraphCreateAdjacent(int indegree, const int sources[],
225 const int sourceweights[],
226 int reorder) = 0;
227
228 virtual void v_NeighborAlltoAllv(void *sendbuf, int sendcounts[],
229 int sdispls[], CommDataType sendtype,
230 void *recvbuf, int recvcounts[],
231 int rdispls[], CommDataType recvtype) = 0;
232
233 virtual void v_Irsend(void *buf, int count, CommDataType dt, int dest,
234 CommRequestSharedPtr request, int loc) = 0;
235 virtual void v_Isend(void *buf, int count, CommDataType dt, int dest,
236 CommRequestSharedPtr request, int loc) = 0;
237 virtual void v_SendInit(void *buf, int count, CommDataType dt, int dest,
238 CommRequestSharedPtr request, int loc) = 0;
239 virtual void v_Irecv(void *buf, int count, CommDataType dt, int source,
240 CommRequestSharedPtr request, int loc) = 0;
241 virtual void v_RecvInit(void *buf, int count, CommDataType dt, int source,
242 CommRequestSharedPtr request, int loc) = 0;
243 virtual void v_StartAll(CommRequestSharedPtr request) = 0;
244 virtual void v_WaitAll(CommRequestSharedPtr request) = 0;
246
247 virtual void v_SplitComm(int pRows, int pColumns, int pTime) = 0;
248
249 virtual CommSharedPtr v_CommCreateIf(int flag) = 0;
250 LIB_UTILITIES_EXPORT virtual std::pair<CommSharedPtr, CommSharedPtr>
252};
253
254/**
255 *
256 */
257inline void Comm::Finalise()
258{
259 v_Finalise();
260}
261
262/**
263 *
264 */
265inline int Comm::GetSize() const
266{
267 return m_size;
268}
269
270/**
271 *
272 */
273inline int Comm::GetRank()
274{
275 return v_GetRank();
276}
277
278/**
279 *
280 */
281inline const std::string &Comm::GetType() const
282{
283 return m_type;
284}
285
286/**
287 *
288 */
290{
291 return v_TreatAsRankZero();
292}
293
294/**
295 *
296 */
297inline bool Comm::IsSerial()
298{
299 return v_IsSerial();
300}
301
302/**
303 * @return tuple of {major, minor, patch} version numbers
304 */
305inline std::tuple<int, int, int> Comm::GetVersion()
306{
307 return v_GetVersion();
308}
309
310/**
311 *
312 */
313inline void Comm::Block()
314{
315 v_Block();
316}
317
318/**
319 *
320 */
321inline double Comm::Wtime()
322{
323 return v_Wtime();
324}
325
326/**
327 *
328 */
329template <class T> void Comm::Send(int pProc, T &pData)
330{
334}
335
336/**
337 *
338 */
339template <class T> void Comm::Recv(int pProc, T &pData)
340{
344}
345
346/**
347 *
348 */
349template <class T>
350void Comm::SendRecv(int pSendProc, T &pSendData, int pRecvProc, T &pRecvData)
351{
358}
359
360/**
361 *
362 */
363template <class T> void Comm::AllReduce(T &pData, enum ReduceOperator pOp)
364{
368}
369
370/**
371 *
372 */
373template <class T> void Comm::AlltoAll(T &pSendData, T &pRecvData)
374{
376 "AlltoAll only valid with Array or vector arguments.");
377 int sendSize = CommDataTypeTraits<T>::GetCount(pSendData);
378 int recvSize = CommDataTypeTraits<T>::GetCount(pRecvData);
379 ASSERTL0(sendSize == recvSize,
380 "Send and Recv arrays have incompatible sizes in AlltoAll");
381
382 int count = sendSize / GetSize();
383 ASSERTL0(count * GetSize() == sendSize,
384 "Array size incompatible with size of communicator");
385
388 CommDataTypeTraits<T>::GetPointer(pRecvData), count,
390}
391
392/**
393 *
394 */
395template <class T1, class T2>
396void Comm::AlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap,
397 T2 &pSendDataOffsetMap, T1 &pRecvData,
398 T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
399{
401 "AlltoAllv only valid with Array or vector arguments.");
402 static_assert(std::is_same<T2, std::vector<int>>::value ||
403 std::is_same<T2, Array<OneD, int>>::value,
404 "Alltoallv size and offset maps should be integer vectors.");
406 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataSizeMap),
407 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataOffsetMap),
410 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataSizeMap),
411 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataOffsetMap),
413}
414
415/**
416 *
417 */
418template <class T> void Comm::AllGather(T &pSendData, T &pRecvData)
419{
420 BOOST_STATIC_ASSERT_MSG(
422 "AllGather only valid with Array or vector arguments.");
423
424 int sendSize = CommDataTypeTraits<T>::GetCount(pSendData);
425 int recvSize = sendSize;
426
427 pRecvData = T(recvSize * GetSize());
428
431 CommDataTypeTraits<T>::GetPointer(pRecvData), recvSize,
433}
434
435/**
436 *
437 */
438template <class T>
439void Comm::AllGatherv(T &pSendData, T &pRecvData,
440 Array<OneD, int> &pRecvDataSizeMap,
441 Array<OneD, int> &pRecvDataOffsetMap)
442{
443 BOOST_STATIC_ASSERT_MSG(
445 "AllGatherv only valid with Array or vector arguments.");
446
447 int sendSize = CommDataTypeTraits<T>::GetCount(pSendData);
448
452 pRecvDataSizeMap.get(), pRecvDataOffsetMap.get(),
454}
455
456/**
457 *
458 */
459template <class T>
460void Comm::AllGatherv(T &pRecvData, Array<OneD, int> &pRecvDataSizeMap,
461 Array<OneD, int> &pRecvDataOffsetMap)
462{
463 BOOST_STATIC_ASSERT_MSG(
465 "AllGatherv only valid with Array or vector arguments.");
466
468 pRecvDataSizeMap.get(), pRecvDataOffsetMap.get(),
470}
471
472/**
473 *
474 */
475template <class T> void Comm::Bcast(T &pData, int pRoot)
476{
480}
481
482/**
483 * Concatenate all the input arrays, in rank order, onto the process with rank
484 * == rootProc
485 */
486template <class T> T Comm::Gather(const int rootProc, T &val)
487{
489 "Gather only valid with Array or vector arguments.");
490 bool amRoot = (GetRank() == rootProc);
491 unsigned nEl = CommDataTypeTraits<T>::GetCount(val);
492
493 unsigned nOut = amRoot ? GetSize() * nEl : 0;
494 T ans(nOut);
495 void *recvbuf = amRoot ? CommDataTypeTraits<T>::GetPointer(ans) : NULL;
496
500 return ans;
501}
502
503/**
504 * Scatter pData across ranks in chunks of len(pData)/num_ranks
505 */
506template <class T> T Comm::Scatter(const int rootProc, T &pData)
507{
509 "Scatter only valid with Array or vector arguments.");
510
511 bool amRoot = (GetRank() == rootProc);
512 unsigned nEl = CommDataTypeTraits<T>::GetCount(pData) / GetSize();
513
514 void *sendbuf = amRoot ? CommDataTypeTraits<T>::GetPointer(pData) : NULL;
515 T ans(nEl);
516
520 return ans;
521}
522
523/**
524 * This replaces the current MPI communicator with a new one that also holds
525 * the distributed graph topology information. If reordering is enabled using
526 * this might break code where process/rank numbers are assumed to remain
527 * constant. This also assumes that the graph is bi-directional, so all
528 * sources are also destinations with equal weighting.
529 *
530 * @param sources Ranks of processes for which the calling process is the
531 * destination/source
532 * @param sourceweights Weights of the corresponding edges into the calling
533 * process
534 * @param reorder Ranks may be reordered (true) or not (false)
535 */
536template <class T>
537void Comm::DistGraphCreateAdjacent(T &sources, T &sourceweights, int reorder)
538{
539 static_assert(
541 "DistGraphCreateAdjacent only valid with Array or vector arguments.");
542
544 CommDataTypeTraits<T>::GetCount(sourceweights),
545 "Sources and weights array sizes don't match");
546
547 int indegree = CommDataTypeTraits<T>::GetCount(sources);
548
550 indegree, (const int *)CommDataTypeTraits<T>::GetPointer(sources),
551 (const int *)CommDataTypeTraits<T>::GetPointer(sourceweights), reorder);
552}
553
554/**
555 * Sends data to neighboring processes in a virtual topology communicator. All
556 * processes send different amounts of data to, and receive different amounts
557 * of data from, all neighbors
558 *
559 * @param pSendData Array/vector to send to neighbors
560 * @param pSendDataSizeMap Array/vector where entry i specifies the number
561 * of elements to send to neighbor i
562 * @param pSendDataOffsetMap Array/vector where entry i specifies the
563 * displacement (offset from pSendData) from which to
564 * send data to neighbor i
565 * @param pRecvData Array/vector to place incoming data in to
566 * @param pRecvDataSizeMap Array/vector where entry i specifies the number
567 * of elements to receive from neighbor i
568 * @param pRecvDataOffsetMap Array/vector where entry i specifies the
569 * displacement (offset from pRecvData) from which to
570 * receive data from neighbor i
571 */
572template <class T1, class T2>
573void Comm::NeighborAlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap,
574 T2 &pSendDataOffsetMap, T1 &pRecvData,
575 T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
576{
577 static_assert(
579 "NeighbourAlltoAllv only valid with Array or vector arguments.");
580 static_assert(
581 std::is_same<T2, std::vector<int>>::value ||
582 std::is_same<T2, Array<OneD, int>>::value,
583 "NeighborAllToAllv size and offset maps should be integer vectors.");
586 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataSizeMap),
587 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataOffsetMap),
590 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataSizeMap),
591 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataOffsetMap),
593}
594
595/**
596 * Starts a ready-mode nonblocking send
597 *
598 * @param pProc Rank of destination
599 * @param pData Array/vector to send
600 * @param count Number of elements to send in pData
601 * @param request Communication request object
602 * @param loc Location in request to use
603 */
604template <class T>
605void Comm::Irsend(int pProc, T &pData, int count,
606 const CommRequestSharedPtr &request, int loc)
607{
609 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
610}
611
612/**
613 * Starts a nonblocking send
614 *
615 * @param pProc Rank of destination
616 * @param pData Array/vector to send
617 * @param count Number of elements to send in pData
618 * @param request Communication request object
619 * @param loc Location in request to use
620 */
621template <class T>
622void Comm::Isend(int pProc, T &pData, int count,
623 const CommRequestSharedPtr &request, int loc)
624{
626 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
627}
628
629/**
630 * Creates a persistent request for a send
631 *
632 * @param pProc Rank of destination
633 * @param pData Array/vector to send
634 * @param count Number of elements to send in pData
635 * @param request Communication request object
636 * @param loc Location in request to use
637 */
638template <class T>
639void Comm::SendInit(int pProc, T &pData, int count,
640 const CommRequestSharedPtr &request, int loc)
641{
643 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
644}
645
646/**
647 * Begins a nonblocking receive
648 *
649 * @param pProc Rank of source
650 * @param pData Array/vector to place incoming data in to
651 * @param count Number of elements to receive in to pData
652 * @param request Communication request object
653 * @param loc Location in request to use
654 */
655template <class T>
656void Comm::Irecv(int pProc, T &pData, int count,
657 const CommRequestSharedPtr &request, int loc)
658{
660 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
661}
662
663/**
664 * Create a persistent request for a receive
665 *
666 * @param pProc Rank of source
667 * @param pData Array/vector to place incoming data in to
668 * @param count Number of elements to receive in to pData
669 * @param request Communication request object
670 * @param loc Location in request to use
671 */
672template <class T>
673void Comm::RecvInit(int pProc, T &pData, int count,
674 const CommRequestSharedPtr &request, int loc)
675{
677 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
678}
679
680/**
681 * Starts a collection of persistent requests
682 *
683 * @param request Communication request object
684 */
685inline void Comm::StartAll(const CommRequestSharedPtr &request)
686{
687 v_StartAll(request);
688}
689
690/**
691 * Waits for all CommRequests in the request object to complete.
692 *
693 * @param request Communication request object
694 */
695inline void Comm::WaitAll(const CommRequestSharedPtr &request)
696{
697 v_WaitAll(request);
698}
699
700/**
701 * Creates a number of CommRequests.
702 *
703 * @param num Number of requests to generate in the communication request object
704 *
705 * @return Communication request object
706 */
708{
709 return v_CreateRequest(num);
710}
711
712/**
713 * @brief If the flag is non-zero create a new communicator.
714 */
716{
717 return v_CommCreateIf(flag);
718}
719
720/**
721 * @brief Splits this communicator into a grid of size pRows*pColumns
722 * and creates row and column communicators. By default the communicator
723 * is a single row.
724 */
725inline void Comm::SplitComm(int pRows, int pColumns, int pTime)
726{
727 v_SplitComm(pRows, pColumns, pTime);
728}
729
730/**
731 * @brief Retrieve the row communicator to which this process belongs.
732 */
734{
735 if (!m_commRow.get())
736 {
737 return shared_from_this();
738 }
739 else
740 {
741 return m_commRow;
742 }
743}
744
745/**
746 * @brief Retrieve the column communicator to which this process
747 * belongs.
748 */
750{
751 if (!m_commColumn.get())
752 {
753 return shared_from_this();
754 }
755 else
756 {
757 return m_commColumn;
758 }
759}
760
761/**
762 * @brief Retrieve the time communicator to which this process
763 * belongs.
764 */
766{
767 if (!m_commTime.get())
768 {
769 return shared_from_this();
770 }
771 else
772 {
773 return m_commTime;
774 }
775}
776
777/**
778 * @brief Retrieve the space communicator to which this process
779 * belongs.
780 */
782{
783 if (!m_commSpace.get())
784 {
785 return shared_from_this();
786 }
787 else
788 {
789 return m_commSpace;
790 }
791}
792
793/**
794 *
795 */
797{
798 return true;
799}
800
801/**
802 *
803 */
804std::pair<CommSharedPtr, CommSharedPtr> Comm::SplitCommNode()
805{
806 return v_SplitCommNode();
807}
808
809} // namespace LibUtilities
810} // namespace Nektar
811
812#endif
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
#define LIB_UTILITIES_EXPORT
Base communications class.
Definition: Comm.h:90
void SendRecv(int pSendProc, T &pSendData, int pRecvProc, T &pRecvData)
Definition: Comm.h:350
void AllGather(T &pSendData, T &pRecvData)
Definition: Comm.h:418
virtual CommSharedPtr v_CommCreateIf(int flag)=0
void AlltoAll(T &pSendData, T &pRecvData)
Definition: Comm.h:373
CommSharedPtr GetSpaceComm()
Retrieve the space communicator to which this process belongs.
Definition: Comm.h:781
void Isend(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition: Comm.h:622
virtual std::pair< CommSharedPtr, CommSharedPtr > v_SplitCommNode()
CommSharedPtr m_commColumn
Column communicator.
Definition: Comm.h:179
virtual std::tuple< int, int, int > v_GetVersion()=0
virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)=0
CommSharedPtr CommCreateIf(int flag)
If the flag is non-zero create a new communicator.
Definition: Comm.h:715
CommSharedPtr GetColumnComm()
Retrieve the column communicator to which this process belongs.
Definition: Comm.h:749
bool RemoveExistingFiles()
Definition: Comm.h:796
T Gather(int rootProc, T &val)
Definition: Comm.h:486
void Block()
Block execution until all processes reach this point.
Definition: Comm.h:313
CommSharedPtr GetRowComm()
Retrieve the row communicator to which this process belongs.
Definition: Comm.h:733
CommRequestSharedPtr CreateRequest(int num)
Definition: Comm.h:707
NekDouble Wtime()
Return the time in seconds.
Definition: Comm.h:321
void StartAll(const CommRequestSharedPtr &request)
Definition: Comm.h:685
virtual void v_Isend(void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc)=0
virtual void v_NeighborAlltoAllv(void *sendbuf, int sendcounts[], int sdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)=0
CommSharedPtr m_commRow
Row communicator.
Definition: Comm.h:178
const std::string & GetType() const
Definition: Comm.h:281
virtual void v_WaitAll(CommRequestSharedPtr request)=0
virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source)=0
void Bcast(T &pData, int pRoot)
Definition: Comm.h:475
int GetSize() const
Returns number of processes.
Definition: Comm.h:265
void SendInit(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition: Comm.h:639
virtual void v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[], CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)=0
virtual void v_AllGather(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)=0
void SplitComm(int pRows, int pColumns, int pTime=1)
Splits this communicator into a grid of size pRows*pColumns and creates row and column communicators....
Definition: Comm.h:725
virtual void v_Recv(void *buf, int count, CommDataType dt, int source)=0
virtual void v_Send(void *buf, int count, CommDataType dt, int dest)=0
virtual int v_GetRank()=0
virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)=0
CommSharedPtr m_commTime
Definition: Comm.h:180
void AllGatherv(T &pSendData, T &pRecvData, Array< OneD, int > &pRecvDataSizeMap, Array< OneD, int > &pRecvDataOffsetMap)
Definition: Comm.h:439
void Send(int pProc, T &pData)
Definition: Comm.h:329
int m_size
Number of processes.
Definition: Comm.h:176
std::string m_type
Type of communication.
Definition: Comm.h:177
void Recv(int pProc, T &pData)
Definition: Comm.h:339
void WaitAll(const CommRequestSharedPtr &request)
Definition: Comm.h:695
virtual void v_Irsend(void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc)=0
virtual void v_AllReduce(void *buf, int count, CommDataType dt, enum ReduceOperator pOp)=0
virtual NekDouble v_Wtime()=0
virtual CommRequestSharedPtr v_CreateRequest(int num)=0
void AllReduce(T &pData, enum ReduceOperator pOp)
Definition: Comm.h:363
virtual void v_AllGatherv(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)=0
std::pair< CommSharedPtr, CommSharedPtr > SplitCommNode()
Definition: Comm.h:804
virtual void v_RecvInit(void *buf, int count, CommDataType dt, int source, CommRequestSharedPtr request, int loc)=0
void RecvInit(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition: Comm.h:673
virtual void v_Block()=0
std::tuple< int, int, int > GetVersion()
Definition: Comm.h:305
void Irecv(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition: Comm.h:656
virtual void v_Finalise()=0
CommSharedPtr GetTimeComm()
Retrieve the time communicator to which this process belongs.
Definition: Comm.h:765
void AlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap, T2 &pSendDataOffsetMap, T1 &pRecvData, T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
Definition: Comm.h:396
virtual void v_DistGraphCreateAdjacent(int indegree, const int sources[], const int sourceweights[], int reorder)=0
virtual void v_Bcast(void *buffer, int count, CommDataType dt, int root)=0
void DistGraphCreateAdjacent(T &sources, T &sourceweights, int reorder)
Definition: Comm.h:537
virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)=0
virtual void v_StartAll(CommRequestSharedPtr request)=0
void Irsend(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition: Comm.h:605
T Scatter(int rootProc, T &pData)
Definition: Comm.h:506
virtual bool v_TreatAsRankZero()=0
virtual void v_Irecv(void *buf, int count, CommDataType dt, int source, CommRequestSharedPtr request, int loc)=0
virtual bool v_IsSerial()=0
CommSharedPtr m_commSpace
Definition: Comm.h:181
virtual void v_AllGatherv(void *recvbuf, int recvcounts[], int rdispls[], CommDataType recvtype)=0
virtual void v_SendInit(void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc)=0
void NeighborAlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap, T2 &pSendDataOffsetMap, T1 &pRecvData, T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
Definition: Comm.h:573
virtual void v_SplitComm(int pRows, int pColumns, int pTime)=0
Class for communicator request type.
Definition: Comm.h:78
virtual ~CommRequest()=default
Default destructor.
CommRequest()=default
Default constructor.
Provides a generic Factory class.
Definition: NekFactory.hpp:105
array buffer
Definition: GsLib.hpp:83
LibUtilities::NekFactory< std::string, Comm, int, char ** > CommFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class.
Definition: Comm.h:61
const char *const ReduceOperatorMap[]
Definition: Comm.h:74
unsigned int CommDataType
Definition: CommDataType.h:70
std::shared_ptr< CommRequest > CommRequestSharedPtr
Definition: Comm.h:86
CommFactory & GetCommFactory()
ReduceOperator
Type of operation to perform in AllReduce.
Definition: Comm.h:67
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:57
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble