Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
DistStructInfo.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
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
10#include "SendRecvOp.h" // FIXME: remove
11#include "SimpleCSRPrecomp.h"
12#include <cstdlib>
13#include <unordered_set>
14
15namespace Alien
16{
17
18class VBlock;
19
20}
21
22/*---------------------------------------------------------------------------*/
23
24namespace Alien::SimpleCSRInternal
25{
26
27class CSRStructInfo;
28
29/*---------------------------------------------------------------------------*/
30
31class ALIEN_EXPORT DistStructInfo
32{
33 public:
34 DistStructInfo() {}
35
36 ~DistStructInfo() {}
37
38 DistStructInfo(const DistStructInfo& src) { copy(src); }
39
40 DistStructInfo& operator=(const DistStructInfo& src)
41 {
42 copy(src);
43 return *this;
44 }
45
46 void compute(Integer nproc, ConstArrayView<Integer> offset, Integer my_rank,
47 IMessagePassingMng* parallel_mng, const CSRStructInfo& profile,
48 ITraceMng* trace = NULL);
49
50 void compute(Integer nproc, ConstArrayView<Integer> offset, Integer my_rank,
51 IMessagePassingMng* parallel_mng, const CSRStructInfo& profile,
52 const VBlock* block_sizes, const MatrixDistribution& dist, ITraceMng* trace = NULL);
53
54 Integer domainId(Integer nproc, ConstArrayView<Integer> offset, Integer id)
55 {
56 for (Integer ip = 0; ip < nproc; ++ip) {
57 if (id < offset[ip + 1])
58 return ip;
59 }
60 return -1;
61 }
62
63 bool isInterfaceRow(Arccore::Integer row_id) const
64 {
65 return m_interface_row_set.find(row_id) != m_interface_row_set.end();
66 }
67
68 void copy(const DistStructInfo& distStructInfo);
69
70 void computeUpperDiagOffset(const CSRStructInfo& profile) const
71 {
72 auto nrows = profile.getNRows();
73 auto row_offset = profile.getRowOffset();
74 m_upper_diag_offset.resize(nrows);
75 for (int irow = 0; irow < nrows; ++irow) {
76 int index = row_offset[irow];
77 for (int k = row_offset[irow]; k < row_offset[irow] + m_local_row_size[irow]; ++k) {
78 if (m_cols[k] < irow)
79 ++index;
80 else
81 break;
82 }
83 m_upper_diag_offset[irow] = index;
84 }
85 }
86
87 ConstArrayView<Integer> getUpperDiagOffset(const CSRStructInfo& profile) const
88 {
89 if (m_upper_diag_offset.size() == 0)
90 computeUpperDiagOffset(profile);
91 return m_upper_diag_offset.constView();
92 }
93
94 int const* dcol(const CSRStructInfo& profile) const
95 {
96 getUpperDiagOffset(profile);
97 return m_upper_diag_offset.data();
98 }
99
100 void computeBlock2DSizesAndOffsets(Integer const* kcol, Integer const* dcol, Integer const* bcol) const;
101
102 // clang-format off
103 Arccore::UniqueArray<Arccore::Integer> m_local_row_size;
104 Arccore::Integer m_ghost_nrow = 0;
105 Arccore::Integer m_interface_nrow = 0;
106 Arccore::Integer m_first_upper_ghost_index = 0;
107 Arccore::UniqueArray<Arccore::Integer> m_interface_rows;
108 std::unordered_set<int> m_interface_row_set;
109 Arccore::UniqueArray<Arccore::Integer> m_cols;
110 mutable
111 Arccore::UniqueArray<Arccore::Integer> m_upper_diag_offset;
112 mutable
113 CommInfo m_recv_info;
114 mutable
115 CommInfo m_send_info;
116 Arccore::UniqueArray<Arccore::Integer> m_block_sizes;
117 Arccore::UniqueArray<Arccore::Integer> m_block_offsets;
118 mutable
119 Arccore::UniqueArray<Arccore::Integer> m_block2d_sizes;
120 mutable
121 Arccore::UniqueArray<Arccore::Integer> m_block2d_offsets;
122 // clang-format on
123};
124
125/*---------------------------------------------------------------------------*/
126
127} // namespace Alien::SimpleCSRInternal
128
129/*---------------------------------------------------------------------------*/
MatrixDistribution.h.
Computes a matrix distribution.
Variable size block elements for block matrices.
Definition VBlock.h:46
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17