Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
SimpleCSRDistributor.h
1
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6
7#pragma once
8
9#include <alien/utils/Precomp.h>
11#include <alien/kernels/simple_csr/SimpleCSRMatrix.h>
12#include <alien/kernels/redistributor/RedistributorCommPlan.h>
13#include <arccore/message_passing/PointToPointMessageInfo.h>
14#include <arccore/base/Span.h>
15
16namespace Alien
17{
18
19class ALIEN_EXPORT SimpleCSRDistributor
20{
21 public:
22 SimpleCSRDistributor(const RedistributorCommPlan* commPlan, const VectorDistribution& source_distribution,
24
25 virtual ~SimpleCSRDistributor() = default;
26
27 template <typename NumT>
28 void distribute(const SimpleCSRMatrix<NumT>& src, SimpleCSRMatrix<NumT>& dst);
29
30 template <typename NumT>
31 void distribute(const SimpleCSRVector<NumT>& src, SimpleCSRVector<NumT>& dst);
32
33 [[nodiscard]] std::shared_ptr<const Alien::SimpleCSRInternal::CSRStructInfo> getDstProfile() const
34 {
35 return m_dst_profile;
36 }
37
38 private:
39 template <typename T>
40 std::optional<T> _owner(const std::vector<T>& offset, T global_row_id);
41 template <typename T>
42 void _distribute(const int bb, const T* src, T* dst);
43 template <typename T>
44 void _resizeBuffers(const int bb);
45 void _finishExchange();
46 std::optional<int> _dstMe(int) const;
47
48 struct CommInfo
49 {
50 public:
51 std::vector<Integer> m_row_list;
52 std::size_t m_n_item = 0;
53 std::vector<uint64_t> m_buffer;
54 Arccore::MessagePassing::PointToPointMessageInfo m_message_info;
55 Arccore::MessagePassing::Request m_request;
56 };
57
58 const RedistributorCommPlan* m_comm_plan = nullptr;
59
60 const Alien::SimpleCSRInternal::CSRStructInfo* m_src_profile = nullptr;
61 std::shared_ptr<Alien::SimpleCSRInternal::CSRStructInfo> m_dst_profile;
62
63 // map<processor id,<num item,row list>>
64 std::map<int, CommInfo> m_send_comm_info;
65 std::map<int, CommInfo> m_recv_comm_info;
66
67 // list of rows that can directly transferred from source matrix to destination matrix
68 std::vector<std::pair<Integer, Integer>> m_src2dst_row_list;
69};
70
71} // namespace Alien
MatrixDistribution.h.
Computes a vector distribution.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17