Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
BEllPackStructInfo.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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
8
9#pragma once
10
11#include <vector>
12
13#include <algorithm>
14#include <alien/kernels/sycl/SYCLPrecomp.h>
15
16/*---------------------------------------------------------------------------*/
17
18namespace Alien
19{
20namespace SYCLInternal
21{
22 template <int EllPackSize, typename IndexT>
23 struct StructInfoInternal;
24
25}
26
27class BaseBEllPackStructInfo
28{
29 public:
30 BaseBEllPackStructInfo(std::size_t nrows,
31 std::size_t nnz)
32 : m_nrows(nrows)
33 , m_nnz(nnz)
34 {}
35
36 virtual ~BaseBEllPackStructInfo() {}
37
38 std::size_t getNRows() const { return m_nrows; }
39
40 std::size_t getNnz() const { return m_nnz; }
41
42 Arccore::Int64 timestamp() const { return m_timestamp; }
43
44 void setTimestamp(Arccore::Int64 value) { m_timestamp = value; }
45
46 protected:
47 // clang-format off
48 std::size_t m_nrows = 0 ;
49 std::size_t m_nnz = 0 ;
50 Arccore::Int64 m_timestamp = -1;
51 // clang-format on
52};
53/*---------------------------------------------------------------------------*/
54
55template <int EllPackSize, typename IndexT = int>
56class ALIEN_EXPORT BEllPackStructInfo
57: public BaseBEllPackStructInfo
58{
59 public:
60 // clang-format off
61 using index_type = IndexT;
62 using IndexType = IndexT;
64 static const int ellpack_size = EllPackSize ;
65
66 // clang-format on
67
68 static std::size_t nbBlocks(std::size_t nrows)
69 {
70 return (nrows + ellpack_size - 1) / ellpack_size;
71 }
72
73 static std::size_t roundUp(std::size_t nrows)
74 {
75 return nbBlocks(nrows) * ellpack_size;
76 }
77
78 static void computeBlockRowOffset(std::vector<int>& block_row_offset,
79 std::size_t nrows,
80 int const* kcol);
81
82 BEllPackStructInfo(std::size_t nrows,
83 int const* kcol,
84 int const* cols,
85 int const* h_block_row_offset,
86 int const* h_local_row_size);
87
88 virtual ~BEllPackStructInfo() ;
89
90 const BaseBEllPackStructInfo& base() const
91 {
92 return *this;
93 }
94
95 InternalType const* internal() const
96 {
97 return m_internal;
98 }
99
100 std::size_t getBlockNnz() const { return m_block_nnz; }
101
102 Arccore::ConstArrayView<Integer> getRowOffset() const
103 {
104 return Arccore::ConstArrayView<Integer>((Integer)m_nrows + 1, kcol());
105 }
106
107 IndexType const* kcol() const;
108
109 IndexType const* cols() const;
110
111 IndexType const* dcol() const;
112
113 int const* localRowSize() const
114 {
115 return m_h_local_row_size;
116 }
117
118 void computeUpperDiagOffset() const
119 {
120 }
121
122 Integer computeBandeSize() const
123 {
124 return 0 ;
125 }
126
127 Integer computeUpperBandeSize() const
128 {
129 return 0;
130 }
131
132 Integer computeLowerBandeSize() const
133 {
134 return 0;
135 }
136
137 Integer computeMaxRowSize() const
138 {
139 m_max_row_size = 0;
140 return m_max_row_size;
141 }
142
143 Integer getMaxRowSize() const
144 {
145 if (m_max_row_size == -1)
146 computeMaxRowSize();
147 return m_max_row_size;
148 }
149
150
151 protected:
152 // clang-format off
153 std::size_t m_block_nrows = 0 ;
154 std::size_t m_block_nnz = 0 ;
155 mutable Integer m_max_row_size = -1 ;
156
157 InternalType* m_internal = nullptr;
158 int const* m_h_local_row_size = nullptr ;
159 // clang-format on
160};
161
162/*---------------------------------------------------------------------------*/
163
164} // namespace Alien
165
166/*---------------------------------------------------------------------------*/
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17