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
50{
51// Forward declarations
52class Comm;
53
54/// Pointer to a Communicator object.
55typedef std::shared_ptr<Comm> CommSharedPtr;
56
57/// Datatype of the NekFactory used to instantiate classes derived from
58/// the EquationSystem class.
60
62
63/// Type of operation to perform in AllReduce.
65{
70};
71
72const char *const ReduceOperatorMap[] = {"ReduceSum", "ReduceMax", "ReduceMin"};
73
74/// Class for communicator request type
76{
77public:
78 /// Default constructor
79 CommRequest() = default;
80 /// Default destructor
81 virtual ~CommRequest() = default;
82};
83
84typedef std::shared_ptr<CommRequest> CommRequestSharedPtr;
85
86/// Base communications class
87class Comm : public std::enable_shared_from_this<Comm>
88{
89public:
90 LIB_UTILITIES_EXPORT Comm(int narg, char *arg[]);
92
93 LIB_UTILITIES_EXPORT inline void Finalise();
94
95 /// Returns number of processes
96 LIB_UTILITIES_EXPORT inline int GetSize() const;
97 LIB_UTILITIES_EXPORT inline int GetRank();
98 LIB_UTILITIES_EXPORT inline const std::string &GetType() const;
99
101 LIB_UTILITIES_EXPORT inline bool IsSerial();
103 LIB_UTILITIES_EXPORT inline std::tuple<int, int, int> GetVersion();
104
105 /// Block execution until all processes reach this point
106 LIB_UTILITIES_EXPORT inline void Block();
107
108 /// Return the time in seconds
110
111 template <class T> void Send(int pProc, T &pData);
112 template <class T> void Recv(int pProc, T &pData);
113 template <class T>
114 void SendRecv(int pSendProc, T &pSendData, int pRecvProc, T &pRecvData);
115
116 template <class T> void AllReduce(T &pData, enum ReduceOperator pOp);
117
118 template <class T> void AlltoAll(T &pSendData, T &pRecvData);
119 template <class T1, class T2>
120 void AlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap, T2 &pSendDataOffsetMap,
121 T1 &pRecvData, T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap);
122
123 template <class T> void AllGather(T &pSendData, T &pRecvData);
124 template <class T>
125 void AllGatherv(T &pSendData, T &pRecvData,
126 Array<OneD, int> &pRecvDataSizeMap,
127 Array<OneD, int> &pRecvDataOffsetMap);
128 template <class T>
129 void AllGatherv(T &pRecvData, Array<OneD, int> &pRecvDataSizeMap,
130 Array<OneD, int> &pRecvDataOffsetMap);
131
132 template <class T> void Bcast(T &pData, int pRoot);
133 template <class T> T Gather(int rootProc, T &val);
134 template <class T> T Scatter(int rootProc, T &pData);
135
136 template <class T>
137 void DistGraphCreateAdjacent(T &sources, T &sourceweights, int reorder);
138 template <class T1, class T2>
139 void NeighborAlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap,
140 T2 &pSendDataOffsetMap, T1 &pRecvData,
141 T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap);
142
143 template <class T>
144 void Irsend(int pProc, T &pData, int count,
145 const CommRequestSharedPtr &request, int loc);
146 template <class T>
147 void Isend(int pProc, T &pData, int count,
148 const CommRequestSharedPtr &request, int loc);
149 template <class T>
150 void SendInit(int pProc, T &pData, int count,
151 const CommRequestSharedPtr &request, int loc);
152 template <class T>
153 void Irecv(int pProc, T &pData, int count,
154 const CommRequestSharedPtr &request, int loc);
155 template <class T>
156 void RecvInit(int pProc, T &pData, int count,
157 const CommRequestSharedPtr &request, int loc);
158
159 inline void StartAll(const CommRequestSharedPtr &request);
160 inline void WaitAll(const CommRequestSharedPtr &request);
161
162 inline CommRequestSharedPtr CreateRequest(int num);
164 LIB_UTILITIES_EXPORT inline void SplitComm(int pRows, int pColumns,
165 int pTime = 1);
171 LIB_UTILITIES_EXPORT inline std::pair<CommSharedPtr, CommSharedPtr>
173
174protected:
175 int m_size; ///< Number of processes
176 std::string m_type; ///< Type of communication
177 CommSharedPtr m_commRow; ///< Row communicator
178 CommSharedPtr m_commColumn; ///< Column communicator
181
182 Comm();
183
184 virtual void v_Finalise() = 0;
185 virtual int v_GetRank() = 0;
186 virtual bool v_TreatAsRankZero() = 0;
187 virtual bool v_IsSerial() = 0;
188 virtual std::tuple<int, int, int> v_GetVersion() = 0;
189 virtual void v_Block() = 0;
190 virtual NekDouble v_Wtime() = 0;
191 virtual void v_Send(void *buf, int count, CommDataType dt, int dest) = 0;
192 virtual void v_Recv(void *buf, int count, CommDataType dt, int source) = 0;
193 virtual void v_SendRecv(void *sendbuf, int sendcount, CommDataType sendtype,
194 int dest, void *recvbuf, int recvcount,
195 CommDataType recvtype, int source) = 0;
196 virtual void v_AllReduce(void *buf, int count, CommDataType dt,
197 enum ReduceOperator pOp) = 0;
198 virtual void v_AlltoAll(void *sendbuf, int sendcount, CommDataType sendtype,
199 void *recvbuf, int recvcount,
200 CommDataType recvtype) = 0;
201 virtual void v_AlltoAllv(void *sendbuf, int sendcounts[], int sensdispls[],
202 CommDataType sendtype, void *recvbuf,
203 int recvcounts[], int rdispls[],
204 CommDataType recvtype) = 0;
205 virtual void v_AllGather(void *sendbuf, int sendcount,
206 CommDataType sendtype, void *recvbuf,
207 int recvcount, CommDataType recvtype) = 0;
208 virtual void v_AllGatherv(void *sendbuf, int sendcount,
209 CommDataType sendtype, void *recvbuf,
210 int recvcounts[], int rdispls[],
211 CommDataType recvtype) = 0;
212 virtual void v_AllGatherv(void *recvbuf, int recvcounts[], int rdispls[],
213 CommDataType recvtype) = 0;
214 virtual void v_Bcast(void *buffer, int count, CommDataType dt,
215 int root) = 0;
216 virtual void v_Gather(void *sendbuf, int sendcount, CommDataType sendtype,
217 void *recvbuf, int recvcount, CommDataType recvtype,
218 int root) = 0;
219 virtual void v_Scatter(void *sendbuf, int sendcount, CommDataType sendtype,
220 void *recvbuf, int recvcount, CommDataType recvtype,
221 int root) = 0;
222
223 virtual void v_DistGraphCreateAdjacent(int indegree, const int sources[],
224 const int sourceweights[],
225 int reorder) = 0;
226
227 virtual void v_NeighborAlltoAllv(void *sendbuf, int sendcounts[],
228 int sdispls[], CommDataType sendtype,
229 void *recvbuf, int recvcounts[],
230 int rdispls[], CommDataType recvtype) = 0;
231
232 virtual void v_Irsend(void *buf, int count, CommDataType dt, int dest,
233 CommRequestSharedPtr request, int loc) = 0;
234 virtual void v_Isend(void *buf, int count, CommDataType dt, int dest,
235 CommRequestSharedPtr request, int loc) = 0;
236 virtual void v_SendInit(void *buf, int count, CommDataType dt, int dest,
237 CommRequestSharedPtr request, int loc) = 0;
238 virtual void v_Irecv(void *buf, int count, CommDataType dt, int source,
239 CommRequestSharedPtr request, int loc) = 0;
240 virtual void v_RecvInit(void *buf, int count, CommDataType dt, int source,
241 CommRequestSharedPtr request, int loc) = 0;
242 virtual void v_StartAll(CommRequestSharedPtr request) = 0;
243 virtual void v_WaitAll(CommRequestSharedPtr request) = 0;
245
246 virtual void v_SplitComm(int pRows, int pColumns, int pTime) = 0;
247
248 virtual CommSharedPtr v_CommCreateIf(int flag) = 0;
249 LIB_UTILITIES_EXPORT virtual std::pair<CommSharedPtr, CommSharedPtr>
251};
252
253/**
254 *
255 */
256inline void Comm::Finalise()
257{
258 v_Finalise();
259}
260
261/**
262 *
263 */
264inline int Comm::GetSize() const
265{
266 return m_size;
267}
268
269/**
270 *
271 */
272inline int Comm::GetRank()
273{
274 return v_GetRank();
275}
276
277/**
278 *
279 */
280inline const std::string &Comm::GetType() const
281{
282 return m_type;
283}
284
285/**
286 *
287 */
289{
290 return v_TreatAsRankZero();
291}
292
293/**
294 *
295 */
296inline bool Comm::IsSerial()
297{
298 return v_IsSerial();
299}
300
301/**
302 *
303 */
305{
306 return m_commTime.get();
307}
308
309/**
310 * @return tuple of {major, minor, patch} version numbers
311 */
312inline std::tuple<int, int, int> Comm::GetVersion()
313{
314 return v_GetVersion();
315}
316
317/**
318 *
319 */
320inline void Comm::Block()
321{
322 v_Block();
323}
324
325/**
326 *
327 */
328inline double Comm::Wtime()
329{
330 return v_Wtime();
331}
332
333/**
334 *
335 */
336template <class T> void Comm::Send(int pProc, T &pData)
337{
341}
342
343/**
344 *
345 */
346template <class T> void Comm::Recv(int pProc, T &pData)
347{
351}
352
353/**
354 *
355 */
356template <class T>
357void Comm::SendRecv(int pSendProc, T &pSendData, int pRecvProc, T &pRecvData)
358{
365}
366
367/**
368 *
369 */
370template <class T> void Comm::AllReduce(T &pData, enum ReduceOperator pOp)
371{
375}
376
377/**
378 *
379 */
380template <class T> void Comm::AlltoAll(T &pSendData, T &pRecvData)
381{
383 "AlltoAll only valid with Array or vector arguments.");
384 int sendSize = CommDataTypeTraits<T>::GetCount(pSendData);
385 int recvSize = CommDataTypeTraits<T>::GetCount(pRecvData);
386 ASSERTL0(sendSize == recvSize,
387 "Send and Recv arrays have incompatible sizes in AlltoAll");
388
389 int count = sendSize / GetSize();
390 ASSERTL0(count * GetSize() == sendSize,
391 "Array size incompatible with size of communicator");
392
395 CommDataTypeTraits<T>::GetPointer(pRecvData), count,
397}
398
399/**
400 *
401 */
402template <class T1, class T2>
403void Comm::AlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap,
404 T2 &pSendDataOffsetMap, T1 &pRecvData,
405 T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
406{
408 "AlltoAllv only valid with Array or vector arguments.");
409 static_assert(std::is_same<T2, std::vector<int>>::value ||
410 std::is_same<T2, Array<OneD, int>>::value,
411 "Alltoallv size and offset maps should be integer vectors.");
413 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataSizeMap),
414 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataOffsetMap),
417 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataSizeMap),
418 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataOffsetMap),
420}
421
422/**
423 *
424 */
425template <class T> void Comm::AllGather(T &pSendData, T &pRecvData)
426{
427 BOOST_STATIC_ASSERT_MSG(
429 "AllGather only valid with Array or vector arguments.");
430
431 int sendSize = CommDataTypeTraits<T>::GetCount(pSendData);
432 int recvSize = sendSize;
433
434 pRecvData = T(recvSize * GetSize());
435
438 CommDataTypeTraits<T>::GetPointer(pRecvData), recvSize,
440}
441
442/**
443 *
444 */
445template <class T>
446void Comm::AllGatherv(T &pSendData, T &pRecvData,
447 Array<OneD, int> &pRecvDataSizeMap,
448 Array<OneD, int> &pRecvDataOffsetMap)
449{
450 BOOST_STATIC_ASSERT_MSG(
452 "AllGatherv only valid with Array or vector arguments.");
453
454 int sendSize = CommDataTypeTraits<T>::GetCount(pSendData);
455
459 pRecvDataSizeMap.get(), pRecvDataOffsetMap.get(),
461}
462
463/**
464 *
465 */
466template <class T>
467void Comm::AllGatherv(T &pRecvData, Array<OneD, int> &pRecvDataSizeMap,
468 Array<OneD, int> &pRecvDataOffsetMap)
469{
470 BOOST_STATIC_ASSERT_MSG(
472 "AllGatherv only valid with Array or vector arguments.");
473
475 pRecvDataSizeMap.get(), pRecvDataOffsetMap.get(),
477}
478
479/**
480 *
481 */
482template <class T> void Comm::Bcast(T &pData, int pRoot)
483{
487}
488
489/**
490 * Concatenate all the input arrays, in rank order, onto the process with rank
491 * == rootProc
492 */
493template <class T> T Comm::Gather(const int rootProc, T &val)
494{
496 "Gather only valid with Array or vector arguments.");
497 bool amRoot = (GetRank() == rootProc);
498 unsigned nEl = CommDataTypeTraits<T>::GetCount(val);
499
500 unsigned nOut = amRoot ? GetSize() * nEl : 0;
501 T ans(nOut);
502 void *recvbuf = amRoot ? CommDataTypeTraits<T>::GetPointer(ans) : nullptr;
503
507 return ans;
508}
509
510/**
511 * Scatter pData across ranks in chunks of len(pData)/num_ranks
512 */
513template <class T> T Comm::Scatter(const int rootProc, T &pData)
514{
516 "Scatter only valid with Array or vector arguments.");
517
518 bool amRoot = (GetRank() == rootProc);
519 unsigned nEl = CommDataTypeTraits<T>::GetCount(pData) / GetSize();
520
521 void *sendbuf = amRoot ? CommDataTypeTraits<T>::GetPointer(pData) : nullptr;
522 T ans(nEl);
523
527 return ans;
528}
529
530/**
531 * This replaces the current MPI communicator with a new one that also holds
532 * the distributed graph topology information. If reordering is enabled using
533 * this might break code where process/rank numbers are assumed to remain
534 * constant. This also assumes that the graph is bi-directional, so all
535 * sources are also destinations with equal weighting.
536 *
537 * @param sources Ranks of processes for which the calling process is the
538 * destination/source
539 * @param sourceweights Weights of the corresponding edges into the calling
540 * process
541 * @param reorder Ranks may be reordered (true) or not (false)
542 */
543template <class T>
544void Comm::DistGraphCreateAdjacent(T &sources, T &sourceweights, int reorder)
545{
546 static_assert(
548 "DistGraphCreateAdjacent only valid with Array or vector arguments.");
549
551 CommDataTypeTraits<T>::GetCount(sourceweights),
552 "Sources and weights array sizes don't match");
553
554 int indegree = CommDataTypeTraits<T>::GetCount(sources);
555
557 indegree, (const int *)CommDataTypeTraits<T>::GetPointer(sources),
558 (const int *)CommDataTypeTraits<T>::GetPointer(sourceweights), reorder);
559}
560
561/**
562 * Sends data to neighboring processes in a virtual topology communicator. All
563 * processes send different amounts of data to, and receive different amounts
564 * of data from, all neighbors
565 *
566 * @param pSendData Array/vector to send to neighbors
567 * @param pSendDataSizeMap Array/vector where entry i specifies the number
568 * of elements to send to neighbor i
569 * @param pSendDataOffsetMap Array/vector where entry i specifies the
570 * displacement (offset from pSendData) from which to
571 * send data to neighbor i
572 * @param pRecvData Array/vector to place incoming data in to
573 * @param pRecvDataSizeMap Array/vector where entry i specifies the number
574 * of elements to receive from neighbor i
575 * @param pRecvDataOffsetMap Array/vector where entry i specifies the
576 * displacement (offset from pRecvData) from which to
577 * receive data from neighbor i
578 */
579template <class T1, class T2>
580void Comm::NeighborAlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap,
581 T2 &pSendDataOffsetMap, T1 &pRecvData,
582 T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
583{
584 static_assert(
586 "NeighbourAlltoAllv only valid with Array or vector arguments.");
587 static_assert(
588 std::is_same<T2, std::vector<int>>::value ||
589 std::is_same<T2, Array<OneD, int>>::value,
590 "NeighborAllToAllv size and offset maps should be integer vectors.");
593 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataSizeMap),
594 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataOffsetMap),
597 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataSizeMap),
598 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataOffsetMap),
600}
601
602/**
603 * Starts a ready-mode nonblocking send
604 *
605 * @param pProc Rank of destination
606 * @param pData Array/vector to send
607 * @param count Number of elements to send in pData
608 * @param request Communication request object
609 * @param loc Location in request to use
610 */
611template <class T>
612void Comm::Irsend(int pProc, T &pData, int count,
613 const CommRequestSharedPtr &request, int loc)
614{
616 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
617}
618
619/**
620 * Starts a nonblocking send
621 *
622 * @param pProc Rank of destination
623 * @param pData Array/vector to send
624 * @param count Number of elements to send in pData
625 * @param request Communication request object
626 * @param loc Location in request to use
627 */
628template <class T>
629void Comm::Isend(int pProc, T &pData, int count,
630 const CommRequestSharedPtr &request, int loc)
631{
633 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
634}
635
636/**
637 * Creates a persistent request for a send
638 *
639 * @param pProc Rank of destination
640 * @param pData Array/vector to send
641 * @param count Number of elements to send in pData
642 * @param request Communication request object
643 * @param loc Location in request to use
644 */
645template <class T>
646void Comm::SendInit(int pProc, T &pData, int count,
647 const CommRequestSharedPtr &request, int loc)
648{
650 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
651}
652
653/**
654 * Begins a nonblocking receive
655 *
656 * @param pProc Rank of source
657 * @param pData Array/vector to place incoming data in to
658 * @param count Number of elements to receive in to pData
659 * @param request Communication request object
660 * @param loc Location in request to use
661 */
662template <class T>
663void Comm::Irecv(int pProc, T &pData, int count,
664 const CommRequestSharedPtr &request, int loc)
665{
667 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
668}
669
670/**
671 * Create a persistent request for a receive
672 *
673 * @param pProc Rank of source
674 * @param pData Array/vector to place incoming data in to
675 * @param count Number of elements to receive in to pData
676 * @param request Communication request object
677 * @param loc Location in request to use
678 */
679template <class T>
680void Comm::RecvInit(int pProc, T &pData, int count,
681 const CommRequestSharedPtr &request, int loc)
682{
684 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
685}
686
687/**
688 * Starts a collection of persistent requests
689 *
690 * @param request Communication request object
691 */
692inline void Comm::StartAll(const CommRequestSharedPtr &request)
693{
694 v_StartAll(request);
695}
696
697/**
698 * Waits for all CommRequests in the request object to complete.
699 *
700 * @param request Communication request object
701 */
702inline void Comm::WaitAll(const CommRequestSharedPtr &request)
703{
704 v_WaitAll(request);
705}
706
707/**
708 * Creates a number of CommRequests.
709 *
710 * @param num Number of requests to generate in the communication request object
711 *
712 * @return Communication request object
713 */
715{
716 return v_CreateRequest(num);
717}
718
719/**
720 * @brief If the flag is non-zero create a new communicator.
721 */
723{
724 return v_CommCreateIf(flag);
725}
726
727/**
728 * @brief Splits this communicator into a grid of size pRows*pColumns
729 * and creates row and column communicators. By default the communicator
730 * is a single row.
731 */
732inline void Comm::SplitComm(int pRows, int pColumns, int pTime)
733{
734 v_SplitComm(pRows, pColumns, pTime);
735}
736
737/**
738 * @brief Retrieve the row communicator to which this process belongs.
739 */
741{
742 if (!m_commRow.get())
743 {
744 return shared_from_this();
745 }
746 else
747 {
748 return m_commRow;
749 }
750}
751
752/**
753 * @brief Retrieve the column communicator to which this process
754 * belongs.
755 */
757{
758 if (!m_commColumn.get())
759 {
760 return shared_from_this();
761 }
762 else
763 {
764 return m_commColumn;
765 }
766}
767
768/**
769 * @brief Retrieve the time communicator to which this process
770 * belongs.
771 */
773{
774 if (!m_commTime.get())
775 {
776 return shared_from_this();
777 }
778 else
779 {
780 return m_commTime;
781 }
782}
783
784/**
785 * @brief Retrieve the space communicator to which this process
786 * belongs.
787 */
789{
790 if (!m_commSpace.get())
791 {
792 return shared_from_this();
793 }
794 else
795 {
796 return m_commSpace;
797 }
798}
799
800/**
801 *
802 */
804{
805 return true;
806}
807
808/**
809 *
810 */
811std::pair<CommSharedPtr, CommSharedPtr> Comm::SplitCommNode()
812{
813 return v_SplitCommNode();
814}
815
816} // namespace Nektar::LibUtilities
817
818#endif
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
#define LIB_UTILITIES_EXPORT
Base communications class.
Definition: Comm.h:88
void SendRecv(int pSendProc, T &pSendData, int pRecvProc, T &pRecvData)
Definition: Comm.h:357
void AllGather(T &pSendData, T &pRecvData)
Definition: Comm.h:425
virtual CommSharedPtr v_CommCreateIf(int flag)=0
void AlltoAll(T &pSendData, T &pRecvData)
Definition: Comm.h:380
CommSharedPtr GetSpaceComm()
Retrieve the space communicator to which this process belongs.
Definition: Comm.h:788
void Isend(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition: Comm.h:629
virtual std::pair< CommSharedPtr, CommSharedPtr > v_SplitCommNode()
CommSharedPtr m_commColumn
Column communicator.
Definition: Comm.h:178
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:722
CommSharedPtr GetColumnComm()
Retrieve the column communicator to which this process belongs.
Definition: Comm.h:756
bool RemoveExistingFiles()
Definition: Comm.h:803
T Gather(int rootProc, T &val)
Definition: Comm.h:493
void Block()
Block execution until all processes reach this point.
Definition: Comm.h:320
CommSharedPtr GetRowComm()
Retrieve the row communicator to which this process belongs.
Definition: Comm.h:740
CommRequestSharedPtr CreateRequest(int num)
Definition: Comm.h:714
NekDouble Wtime()
Return the time in seconds.
Definition: Comm.h:328
void StartAll(const CommRequestSharedPtr &request)
Definition: Comm.h:692
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:177
const std::string & GetType() const
Definition: Comm.h:280
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:482
int GetSize() const
Returns number of processes.
Definition: Comm.h:264
void SendInit(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition: Comm.h:646
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:732
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:179
void AllGatherv(T &pSendData, T &pRecvData, Array< OneD, int > &pRecvDataSizeMap, Array< OneD, int > &pRecvDataOffsetMap)
Definition: Comm.h:446
void Send(int pProc, T &pData)
Definition: Comm.h:336
int m_size
Number of processes.
Definition: Comm.h:175
std::string m_type
Type of communication.
Definition: Comm.h:176
void Recv(int pProc, T &pData)
Definition: Comm.h:346
void WaitAll(const CommRequestSharedPtr &request)
Definition: Comm.h:702
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:370
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:811
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:680
virtual void v_Block()=0
std::tuple< int, int, int > GetVersion()
Definition: Comm.h:312
void Irecv(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition: Comm.h:663
virtual void v_Finalise()=0
CommSharedPtr GetTimeComm()
Retrieve the time communicator to which this process belongs.
Definition: Comm.h:772
void AlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap, T2 &pSendDataOffsetMap, T1 &pRecvData, T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
Definition: Comm.h:403
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:544
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:612
T Scatter(int rootProc, T &pData)
Definition: Comm.h:513
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:180
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:580
virtual void v_SplitComm(int pRows, int pColumns, int pTime)=0
Class for communicator request type.
Definition: Comm.h:76
virtual ~CommRequest()=default
Default destructor.
CommRequest()=default
Default constructor.
Provides a generic Factory class.
array buffer
Definition: GsLib.hpp:81
LibUtilities::NekFactory< std::string, Comm, int, char ** > CommFactory
Datatype of the NekFactory used to instantiate classes derived from the EquationSystem class.
Definition: Comm.h:59
const char *const ReduceOperatorMap[]
Definition: Comm.h:72
unsigned int CommDataType
Definition: CommDataType.h:65
std::shared_ptr< CommRequest > CommRequestSharedPtr
Definition: Comm.h:84
CommFactory & GetCommFactory()
ReduceOperator
Type of operation to perform in AllReduce.
Definition: Comm.h:65
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:55
double NekDouble