Nektar++
Loading...
Searching...
No Matches
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.
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 = 0);
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(const void *buf, int count, CommDataType dt,
192 int dest) = 0;
193 virtual void v_Recv(void *buf, int count, CommDataType dt, int source) = 0;
194 virtual void v_SendRecv(const void *sendbuf, int sendcount,
195 CommDataType sendtype, int dest, void *recvbuf,
196 int recvcount, CommDataType recvtype,
197 int source) = 0;
198 virtual void v_AllReduce(void *buf, int count, CommDataType dt,
199 enum ReduceOperator pOp) = 0;
200 virtual void v_AlltoAll(const void *sendbuf, int sendcount,
201 CommDataType sendtype, void *recvbuf, int recvcount,
202 CommDataType recvtype) = 0;
203 virtual void v_AlltoAllv(const void *sendbuf, const int *sendcounts,
204 const int *senddispls, CommDataType sendtype,
205 void *recvbuf, const int *recvcounts,
206 const int *recvdispls, CommDataType recvtype) = 0;
207 virtual void v_AllGather(const void *sendbuf, int sendcount,
208 CommDataType sendtype, void *recvbuf,
209 int recvcount, CommDataType recvtype) = 0;
210 virtual void v_AllGatherv(const void *sendbuf, int sendcount,
211 CommDataType sendtype, void *recvbuf,
212 const int *recvcounts, const int *recvdispls,
213 CommDataType recvtype) = 0;
214 virtual void v_AllGatherv(void *recvbuf, const int *recvcounts,
215 const int *recvdispls, CommDataType recvtype) = 0;
216 virtual void v_Bcast(void *buffer, int count, CommDataType dt,
217 int root) = 0;
218 virtual void v_Gather(const void *sendbuf, int sendcount,
219 CommDataType sendtype, void *recvbuf, int recvcount,
220 CommDataType recvtype, int root) = 0;
221 virtual void v_Scatter(const void *sendbuf, int sendcount,
222 CommDataType sendtype, void *recvbuf, int recvcount,
223 CommDataType recvtype, int root) = 0;
224
225 virtual void v_DistGraphCreateAdjacent(int indegree, const int *sources,
226 const int *sourceweights,
227 int reorder) = 0;
228
229 virtual void v_NeighborAlltoAllv(const void *sendbuf, const int *sendcounts,
230 const int *senddispls,
231 CommDataType sendtype, void *recvbuf,
232 const int *recvcounts,
233 const int *recvdispls,
234 CommDataType recvtype) = 0;
235
236 virtual void v_Irsend(const void *buf, int count, CommDataType dt, int dest,
237 CommRequestSharedPtr request, int loc) = 0;
238 virtual void v_Isend(const void *buf, int count, CommDataType dt, int dest,
239 CommRequestSharedPtr request, int loc) = 0;
240 virtual void v_SendInit(const void *buf, int count, CommDataType dt,
241 int dest, CommRequestSharedPtr request,
242 int loc) = 0;
243 virtual void v_Irecv(void *buf, int count, CommDataType dt, int source,
244 CommRequestSharedPtr request, int loc) = 0;
245 virtual void v_RecvInit(void *buf, int count, CommDataType dt, int source,
246 CommRequestSharedPtr request, int loc) = 0;
247 virtual void v_StartAll(CommRequestSharedPtr request) = 0;
248 virtual void v_WaitAll(CommRequestSharedPtr request) = 0;
250
251 virtual void v_SplitComm(int pRows, int pColumns, int pTime) = 0;
252
253 virtual CommSharedPtr v_CommCreateIf(int flag) = 0;
254 LIB_UTILITIES_EXPORT virtual std::pair<CommSharedPtr, CommSharedPtr>
256};
257
258/**
259 *
260 */
261inline void Comm::Finalise()
262{
263 v_Finalise();
264}
265
266/**
267 *
268 */
269inline int Comm::GetSize() const
270{
271 return m_size;
272}
273
274/**
275 *
276 */
277inline int Comm::GetRank()
278{
279 return v_GetRank();
280}
281
282/**
283 *
284 */
285inline const std::string &Comm::GetType() const
286{
287 return m_type;
288}
289
290/**
291 *
292 */
294{
295 return v_TreatAsRankZero();
296}
297
298/**
299 *
300 */
301inline bool Comm::IsSerial()
302{
303 return v_IsSerial();
304}
305
306/**
307 *
308 */
310{
311 return m_commTime.get();
312}
313
314/**
315 * @return tuple of {major, minor, patch} version numbers
316 */
317inline std::tuple<int, int, int> Comm::GetVersion()
318{
319 return v_GetVersion();
320}
321
322/**
323 *
324 */
325inline void Comm::Block()
326{
327 v_Block();
328}
329
330/**
331 *
332 */
333inline double Comm::Wtime()
334{
335 return v_Wtime();
336}
337
338/**
339 *
340 */
341template <class T> void Comm::Send(int pProc, T &pData)
342{
346}
347
348/**
349 *
350 */
351template <class T> void Comm::Recv(int pProc, T &pData)
352{
356}
357
358/**
359 *
360 */
361template <class T>
362void Comm::SendRecv(int pSendProc, T &pSendData, int pRecvProc, T &pRecvData)
363{
370}
371
372/**
373 *
374 */
375template <class T> void Comm::AllReduce(T &pData, enum ReduceOperator pOp)
376{
380}
381
382/**
383 *
384 */
385template <class T> void Comm::AlltoAll(T &pSendData, T &pRecvData)
386{
388 "AlltoAll only valid with Array or vector arguments.");
389 int sendSize = CommDataTypeTraits<T>::GetCount(pSendData);
390 int recvSize = CommDataTypeTraits<T>::GetCount(pRecvData);
391 ASSERTL0(sendSize == recvSize,
392 "Send and Recv arrays have incompatible sizes in AlltoAll");
393
394 int count = sendSize / GetSize();
395 ASSERTL0(count * GetSize() == sendSize,
396 "Array size incompatible with size of communicator");
397
400 CommDataTypeTraits<T>::GetPointer(pRecvData), count,
402}
403
404/**
405 *
406 */
407template <class T1, class T2>
408void Comm::AlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap,
409 T2 &pSendDataOffsetMap, T1 &pRecvData,
410 T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
411{
413 "AlltoAllv only valid with Array or vector arguments.");
414 static_assert(std::is_same_v<T2, std::vector<int>> ||
415 std::is_same_v<T2, Array<OneD, int>>,
416 "Alltoallv size and offset maps should be integer vectors.");
418 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataSizeMap),
419 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataOffsetMap),
422 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataSizeMap),
423 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataOffsetMap),
425}
426
427/**
428 *
429 */
430template <class T> void Comm::AllGather(T &pSendData, T &pRecvData)
431{
432 BOOST_STATIC_ASSERT_MSG(
434 "AllGather only valid with Array or vector arguments.");
435
436 int sendSize = CommDataTypeTraits<T>::GetCount(pSendData);
437 int recvSize = sendSize;
438
439 pRecvData = T(recvSize * GetSize());
440
443 CommDataTypeTraits<T>::GetPointer(pRecvData), recvSize,
445}
446
447/**
448 *
449 */
450template <class T>
451void Comm::AllGatherv(T &pSendData, T &pRecvData,
452 Array<OneD, int> &pRecvDataSizeMap,
453 Array<OneD, int> &pRecvDataOffsetMap)
454{
455 BOOST_STATIC_ASSERT_MSG(
457 "AllGatherv only valid with Array or vector arguments.");
458
459 int sendSize = CommDataTypeTraits<T>::GetCount(pSendData);
460
464 pRecvDataSizeMap.data(), pRecvDataOffsetMap.data(),
466}
467
468/**
469 *
470 */
471template <class T>
472void Comm::AllGatherv(T &pRecvData, Array<OneD, int> &pRecvDataSizeMap,
473 Array<OneD, int> &pRecvDataOffsetMap)
474{
475 BOOST_STATIC_ASSERT_MSG(
477 "AllGatherv only valid with Array or vector arguments.");
478
480 pRecvDataSizeMap.data(), pRecvDataOffsetMap.data(),
482}
483
484/**
485 *
486 */
487template <class T> void Comm::Bcast(T &pData, int pRoot)
488{
492}
493
494/**
495 * Concatenate all the input arrays, in rank order, onto the process with rank
496 * == rootProc
497 */
498template <class T> T Comm::Gather(const int rootProc, T &val)
499{
501 "Gather only valid with Array or vector arguments.");
502 bool amRoot = (GetRank() == rootProc);
503 unsigned nEl = CommDataTypeTraits<T>::GetCount(val);
504
505 unsigned nOut = amRoot ? GetSize() * nEl : 0;
506 T ans(nOut);
507 void *recvbuf = amRoot ? CommDataTypeTraits<T>::GetPointer(ans) : nullptr;
508
512 return ans;
513}
514
515/**
516 * Scatter pData across ranks in chunks of len(pData)/num_ranks
517 */
518template <class T> T Comm::Scatter(const int rootProc, T &pData)
519{
521 "Scatter only valid with Array or vector arguments.");
522
523 bool amRoot = (GetRank() == rootProc);
524 unsigned nEl = CommDataTypeTraits<T>::GetCount(pData) / GetSize();
525
526 const void *sendbuf =
527 amRoot ? CommDataTypeTraits<T>::GetPointer(pData) : nullptr;
528 T ans(nEl);
529
533 return ans;
534}
535
536/**
537 * This replaces the current MPI communicator with a new one that also holds
538 * the distributed graph topology information. If reordering is enabled using
539 * this might break code where process/rank numbers are assumed to remain
540 * constant. This also assumes that the graph is bi-directional, so all
541 * sources are also destinations with equal weighting.
542 *
543 * @param sources Ranks of processes for which the calling process is the
544 * destination/source
545 * @param sourceweights Weights of the corresponding edges into the calling
546 * process
547 * @param reorder Ranks may be reordered (true) or not (false)
548 */
549template <class T>
550void Comm::DistGraphCreateAdjacent(T &sources, T &sourceweights, int reorder)
551{
552 static_assert(
554 "DistGraphCreateAdjacent only valid with Array or vector arguments.");
555
557 CommDataTypeTraits<T>::GetCount(sourceweights),
558 "Sources and weights array sizes don't match");
559
560 int indegree = CommDataTypeTraits<T>::GetCount(sources);
561
563 indegree, (const int *)CommDataTypeTraits<T>::GetPointer(sources),
564 (const int *)CommDataTypeTraits<T>::GetPointer(sourceweights), reorder);
565}
566
567/**
568 * Sends data to neighboring processes in a virtual topology communicator. All
569 * processes send different amounts of data to, and receive different amounts
570 * of data from, all neighbors
571 *
572 * @param pSendData Array/vector to send to neighbors
573 * @param pSendDataSizeMap Array/vector where entry i specifies the number
574 * of elements to send to neighbor i
575 * @param pSendDataOffsetMap Array/vector where entry i specifies the
576 * displacement (offset from pSendData) from which to
577 * send data to neighbor i
578 * @param pRecvData Array/vector to place incoming data in to
579 * @param pRecvDataSizeMap Array/vector where entry i specifies the number
580 * of elements to receive from neighbor i
581 * @param pRecvDataOffsetMap Array/vector where entry i specifies the
582 * displacement (offset from pRecvData) from which to
583 * receive data from neighbor i
584 */
585template <class T1, class T2>
586void Comm::NeighborAlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap,
587 T2 &pSendDataOffsetMap, T1 &pRecvData,
588 T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
589{
590 static_assert(
592 "NeighbourAlltoAllv only valid with Array or vector arguments.");
593 static_assert(
594 std::is_same_v<T2, std::vector<int>> ||
595 std::is_same_v<T2, Array<OneD, int>>,
596 "NeighborAllToAllv size and offset maps should be integer vectors.");
599 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataSizeMap),
600 (int *)CommDataTypeTraits<T2>::GetPointer(pSendDataOffsetMap),
603 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataSizeMap),
604 (int *)CommDataTypeTraits<T2>::GetPointer(pRecvDataOffsetMap),
606}
607
608/**
609 * Starts a ready-mode nonblocking send
610 *
611 * @param pProc Rank of destination
612 * @param pData Array/vector to send
613 * @param count Number of elements to send in pData
614 * @param request Communication request object
615 * @param loc Location in request to use
616 */
617template <class T>
618void Comm::Irsend(int pProc, T &pData, int count,
619 const CommRequestSharedPtr &request, int loc)
620{
622 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
623}
624
625/**
626 * Starts a nonblocking send
627 *
628 * @param pProc Rank of destination
629 * @param pData Array/vector to send
630 * @param count Number of elements to send in pData
631 * @param request Communication request object
632 * @param loc Location in request to use
633 */
634template <class T>
635void Comm::Isend(int pProc, T &pData, int count,
636 const CommRequestSharedPtr &request, int loc)
637{
639 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
640}
641
642/**
643 * Creates a persistent request for a send
644 *
645 * @param pProc Rank of destination
646 * @param pData Array/vector to send
647 * @param count Number of elements to send in pData
648 * @param request Communication request object
649 * @param loc Location in request to use
650 */
651template <class T>
652void Comm::SendInit(int pProc, T &pData, int count,
653 const CommRequestSharedPtr &request, int loc)
654{
656 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
657}
658
659/**
660 * Begins a nonblocking receive
661 *
662 * @param pProc Rank of source
663 * @param pData Array/vector to place incoming data in to
664 * @param count Number of elements to receive in to pData
665 * @param request Communication request object
666 * @param loc Location in request to use
667 */
668template <class T>
669void Comm::Irecv(int pProc, T &pData, int count,
670 const CommRequestSharedPtr &request, int loc)
671{
673 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
674}
675
676/**
677 * Create a persistent request for a receive
678 *
679 * @param pProc Rank of source
680 * @param pData Array/vector to place incoming data in to
681 * @param count Number of elements to receive in to pData
682 * @param request Communication request object
683 * @param loc Location in request to use
684 */
685template <class T>
686void Comm::RecvInit(int pProc, T &pData, int count,
687 const CommRequestSharedPtr &request, int loc)
688{
690 CommDataTypeTraits<T>::GetDataType(), pProc, request, loc);
691}
692
693/**
694 * Starts a collection of persistent requests
695 *
696 * @param request Communication request object
697 */
698inline void Comm::StartAll(const CommRequestSharedPtr &request)
699{
700 v_StartAll(request);
701}
702
703/**
704 * Waits for all CommRequests in the request object to complete.
705 *
706 * @param request Communication request object
707 */
708inline void Comm::WaitAll(const CommRequestSharedPtr &request)
709{
710 v_WaitAll(request);
711}
712
713/**
714 * Creates a number of CommRequests.
715 *
716 * @param num Number of requests to generate in the communication request object
717 *
718 * @return Communication request object
719 */
721{
722 return v_CreateRequest(num);
723}
724
725/**
726 * @brief If the flag is non-zero create a new communicator.
727 */
729{
730 return v_CommCreateIf(flag);
731}
732
733/**
734 * @brief Splits this communicator into a grid of size pRows*pColumns
735 * and creates row and column communicators. By default the communicator
736 * is a single row.
737 */
738inline void Comm::SplitComm(int pRows, int pColumns, int pTime)
739{
740 v_SplitComm(pRows, pColumns, pTime);
741}
742
743/**
744 * @brief Retrieve the row communicator to which this process belongs.
745 */
747{
748 if (!m_commRow.get())
749 {
750 return shared_from_this();
751 }
752 else
753 {
754 return m_commRow;
755 }
756}
757
758/**
759 * @brief Retrieve the column communicator to which this process
760 * belongs.
761 */
763{
764 if (!m_commColumn.get())
765 {
766 return shared_from_this();
767 }
768 else
769 {
770 return m_commColumn;
771 }
772}
773
774/**
775 * @brief Retrieve the time communicator to which this process
776 * belongs.
777 */
779{
780 if (!m_commTime.get())
781 {
782 return shared_from_this();
783 }
784 else
785 {
786 return m_commTime;
787 }
788}
789
790/**
791 * @brief Retrieve the space communicator to which this process
792 * belongs.
793 */
795{
796 if (!m_commSpace.get())
797 {
798 return shared_from_this();
799 }
800 else
801 {
802 return m_commSpace;
803 }
804}
805
806/**
807 *
808 */
810{
811 return true;
812}
813
814/**
815 *
816 */
817std::pair<CommSharedPtr, CommSharedPtr> Comm::SplitCommNode()
818{
819 return v_SplitCommNode();
820}
821
822} // namespace Nektar::LibUtilities
823
824#endif
#define ASSERTL0(condition, msg)
#define LIB_UTILITIES_EXPORT
Base communications class.
Definition Comm.h:88
void SendRecv(int pSendProc, T &pSendData, int pRecvProc, T &pRecvData)
Definition Comm.h:362
virtual void v_NeighborAlltoAllv(const void *sendbuf, const int *sendcounts, const int *senddispls, CommDataType sendtype, void *recvbuf, const int *recvcounts, const int *recvdispls, CommDataType recvtype)=0
void AllGather(T &pSendData, T &pRecvData)
Definition Comm.h:430
virtual CommSharedPtr v_CommCreateIf(int flag)=0
void AlltoAll(T &pSendData, T &pRecvData)
Definition Comm.h:385
CommSharedPtr GetSpaceComm()
Retrieve the space communicator to which this process belongs.
Definition Comm.h:794
void Isend(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition Comm.h:635
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_DistGraphCreateAdjacent(int indegree, const int *sources, const int *sourceweights, int reorder)=0
virtual void v_AlltoAll(const void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)=0
CommSharedPtr CommCreateIf(int flag)
If the flag is non-zero create a new communicator.
Definition Comm.h:728
CommSharedPtr GetColumnComm()
Retrieve the column communicator to which this process belongs.
Definition Comm.h:762
T Gather(int rootProc, T &val)
Definition Comm.h:498
void Block()
Block execution until all processes reach this point.
Definition Comm.h:325
CommSharedPtr GetRowComm()
Retrieve the row communicator to which this process belongs.
Definition Comm.h:746
CommRequestSharedPtr CreateRequest(int num)
Definition Comm.h:720
NekDouble Wtime()
Return the time in seconds.
Definition Comm.h:333
void StartAll(const CommRequestSharedPtr &request)
Definition Comm.h:698
CommSharedPtr m_commRow
Row communicator.
Definition Comm.h:177
virtual void v_Irsend(const void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc)=0
void SplitComm(int pRows, int pColumns, int pTime=0)
Splits this communicator into a grid of size pRows*pColumns and creates row and column communicators....
Definition Comm.h:738
const std::string & GetType() const
Definition Comm.h:285
virtual void v_WaitAll(CommRequestSharedPtr request)=0
void Bcast(T &pData, int pRoot)
Definition Comm.h:487
int GetSize() const
Returns number of processes.
Definition Comm.h:269
void SendInit(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition Comm.h:652
virtual void v_SendRecv(const void *sendbuf, int sendcount, CommDataType sendtype, int dest, void *recvbuf, int recvcount, CommDataType recvtype, int source)=0
virtual void v_Gather(const void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)=0
virtual void v_AllGatherv(const void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, const int *recvcounts, const int *recvdispls, CommDataType recvtype)=0
virtual void v_SendInit(const void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc)=0
virtual void v_Scatter(const void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype, int root)=0
virtual void v_Recv(void *buf, int count, CommDataType dt, int source)=0
virtual int v_GetRank()=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:451
virtual void v_AlltoAllv(const void *sendbuf, const int *sendcounts, const int *senddispls, CommDataType sendtype, void *recvbuf, const int *recvcounts, const int *recvdispls, CommDataType recvtype)=0
void Send(int pProc, T &pData)
Definition Comm.h:341
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:351
void WaitAll(const CommRequestSharedPtr &request)
Definition Comm.h:708
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
virtual void v_AllGather(const void *sendbuf, int sendcount, CommDataType sendtype, void *recvbuf, int recvcount, CommDataType recvtype)=0
void AllReduce(T &pData, enum ReduceOperator pOp)
Definition Comm.h:375
std::pair< CommSharedPtr, CommSharedPtr > SplitCommNode()
Definition Comm.h:817
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:686
virtual void v_Block()=0
std::tuple< int, int, int > GetVersion()
Definition Comm.h:317
void Irecv(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition Comm.h:669
virtual void v_Isend(const void *buf, int count, CommDataType dt, int dest, CommRequestSharedPtr request, int loc)=0
virtual void v_Finalise()=0
CommSharedPtr GetTimeComm()
Retrieve the time communicator to which this process belongs.
Definition Comm.h:778
void AlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap, T2 &pSendDataOffsetMap, T1 &pRecvData, T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
Definition Comm.h:408
virtual void v_AllGatherv(void *recvbuf, const int *recvcounts, const int *recvdispls, CommDataType recvtype)=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:550
virtual void v_StartAll(CommRequestSharedPtr request)=0
void Irsend(int pProc, T &pData, int count, const CommRequestSharedPtr &request, int loc)
Definition Comm.h:618
T Scatter(int rootProc, T &pData)
Definition Comm.h:518
virtual bool v_TreatAsRankZero()=0
virtual void v_Irecv(void *buf, int count, CommDataType dt, int source, CommRequestSharedPtr request, int loc)=0
virtual void v_Send(const void *buf, int count, CommDataType dt, int dest)=0
virtual bool v_IsSerial()=0
CommSharedPtr m_commSpace
Definition Comm.h:180
void NeighborAlltoAllv(T1 &pSendData, T2 &pSendDataSizeMap, T2 &pSendDataOffsetMap, T1 &pRecvData, T2 &pRecvDataSizeMap, T2 &pRecvDataOffsetMap)
Definition Comm.h:586
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.
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
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