Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
DoKDistributorComm.h
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19#pragma once
20
21#include <arccore/base/FatalErrorException.h>
22#include <arccore/base/TraceInfo.h>
23
24#include <alien/kernels/redistributor/Utils.h>
25
26#include <alien/kernels/dok/DoKReverseIndexer.h>
27
28namespace Alien
29{
30
32
33class ALIEN_EXPORT DoKDistributorComm
34{
35 public:
36 typedef IReverseIndexer::Index Index;
37
38 public:
45 explicit DoKDistributorComm(const RedistributorCommPlan* commPlan);
46
47 virtual ~DoKDistributorComm() = default;
48
49 DoKDistributorComm(const DoKDistributorComm& src) = delete;
50 DoKDistributorComm& operator=(const DoKDistributorComm& src) = delete;
51 DoKDistributorComm(const DoKDistributorComm&& src) = delete;
52 DoKDistributorComm& operator=(DoKDistributorComm&& src) = delete;
53
54 void computeCommPlan(IReverseIndexer* rev_index);
55
56 void computeCommPlan(Arccore::Span<Int32>);
57
58 template <typename T>
59 void exchange(ConstArrayView<T> snd, ArrayView<T> rcv)
60 {
61 Alien::RedistributionTools::exchange(
62 m_pm_super, snd, m_snd_offset.constView(), rcv, m_rcv_offset.constView());
63 }
64
65 Int32 rcvSize() const { return m_rcv_offset[m_rcv_offset.size() - 1]; }
66
67 Index getCoordinates(Int32 offset) const
68 {
69 if ((offset < 0) || (m_rcv_rows.size() <= offset))
70 throw FatalErrorException("Invalid offset in DoKDistributorComm");
71 return { m_rcv_rows[offset], m_rcv_cols[offset] };
72 }
73
74 private:
75 const RedistributorCommPlan* m_comm_plan;
76 IMessagePassingMng* m_pm_super;
77 IMessagePassingMng* m_pm_dst;
78
79 // Prepare communication buffer
80 UniqueArray<Int32> m_snd_offset;
81 UniqueArray<Int32> m_rcv_offset;
82 UniqueArray<Int32> m_rcv_rows;
83 UniqueArray<Int32> m_rcv_cols;
84};
85
86} // namespace Alien
DoKDistributorComm(const RedistributorCommPlan *commPlan)
Construct a DoKDistributorComm object over parallelMng:
Reverse indexer: associates an Index (i,j) to an offset.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17