10#include <arccore/collections/Array2.h>
12#include <alien/kernels/sycl/data/SYCLSendRecvOp.h>
15namespace Alien::SYCLInternal
20template <
typename ValueT>
22: m_matrix_impl(matrix)
27template <
typename ValueT>
30 if (m_matrix_impl.m_is_parallel)
36template <
typename ValueT>
37void SYCLBEllPackMatrixMultT<ValueT>::addLMult(Real alpha,
const VectorType& x,
VectorType& y)
const
39#ifdef ALIEN_USE_PERF_TIMER
40 typename MatrixType::SentryType sentry(m_matrix_impl.timer(),
"SYCL-AddLMult");
47 m_matrix_impl.addLMult(alpha, x, y);
53template <
typename ValueT>
54void SYCLBEllPackMatrixMultT<ValueT>::addUMult(Real alpha,
const VectorType& x,
VectorType& y)
const
56#ifdef ALIEN_USE_PERF_TIMER
57 typename MatrixType::SentryType sentry(m_matrix_impl.timer(),
"SYCL-AddUMult");
62 m_matrix_impl.addUMult(alpha, x, y);
68template <
typename ValueT>
71#ifdef ALIEN_USE_PERF_TIMER
72 typename MatrixType::SentryType sentry(m_matrix_impl.timer(),
"SYCL-SPMV");
74 if (m_matrix_impl.m_is_parallel)
82template <
typename ValueT>
83void SYCLBEllPackMatrixMultT<ValueT>::_parallelMult(
84const VectorType& x_impl, VectorType& y_impl)
const
88 int block_size = m_matrix_impl.blockSize() ;
91 m_matrix_impl.m_matrix_dist_info.m_send_info,
92 m_matrix_impl.internal()->getSendIds(),
93 m_matrix_impl.m_send_policy,
94 x_impl.internal()->ghostValues(m_matrix_impl.getGhostSize()*block_size),
95 m_matrix_impl.m_matrix_dist_info.m_recv_info,
96 m_matrix_impl.internal()->getRecvIds(),
97 m_matrix_impl.m_recv_policy,
98 m_matrix_impl.m_parallel_mng,
99 m_matrix_impl.m_trace,
104 m_matrix_impl.mult(x_impl, y_impl);
108 m_matrix_impl.endDistMult(x_impl, y_impl);
114template <
typename ValueT>
115void SYCLBEllPackMatrixMultT<ValueT>::_parallelMult(
116[[maybe_unused]]
const UniqueArray<Real>& x_impl, [[maybe_unused]] UniqueArray<Real>& y_impl)
const
118#ifdef ENABLE_MPI_SYCL
119 Real* y_ptr = dataPtr(y_impl);
120 Real* x_ptr = (Real*)dataPtr(x_impl);
121 ConstArrayView<Real> matrix = m_matrix_impl.m_matrix.getValues();
122 ConstArrayView<Integer> cols = m_matrix_impl.getDistStructInfo().m_cols;
123 ConstArrayView<Integer> row_offset =
124 m_matrix_impl.m_matrix.getProfile().getRowOffset();
125 SendRecvOp<Real> op(x_ptr, m_matrix_impl.m_matrix_dist_info.m_send_info,
126 m_matrix_impl.m_send_policy, x_ptr, m_matrix_impl.m_matrix_dist_info.m_recv_info,
127 m_matrix_impl.m_recv_policy, m_matrix_impl.m_parallel_mng, m_matrix_impl.m_trace);
133#ifdef ENABLE_MPI_SYCL
136 Integer interface_nrow = m_matrix_impl.m_matrix_dist_info.m_interface_nrow;
137 ConstArrayView<Integer> row_ids = m_matrix_impl.m_matrix_dist_info.m_interface_rows;
138 for (Integer i = 0; i < interface_nrow; ++i) {
139 Integer irow = row_ids[i];
140 Integer off = row_offset[irow] + local_row_size[irow];
141 Integer off2 = row_offset[irow + 1];
143 for (Integer j = off; j < off2; ++j) {
144 tmpy += matrix[j] * x_ptr[cols[j]];
152template <
typename ValueT>
153void SYCLBEllPackMatrixMultT<ValueT>::_seqMult(
const VectorType& x_impl, VectorType& y_impl)
const
155 m_matrix_impl.mult(x_impl, y_impl);
158template <
typename ValueT>
159void SYCLBEllPackMatrixMultT<ValueT>::_seqMult([[maybe_unused]]
const UniqueArray<Real>& x_impl,
160 [[maybe_unused]] UniqueArray<Real>& y_impl)
const
164template <
typename ValueT>
165void SYCLBEllPackMatrixMultT<ValueT>::lowerUpperSynchronize(
const VectorType& x_impl, VectorType& y_impl)
const
167 int block_size = m_matrix_impl.blockSize() ;
168 alien_debug([&]{cout()<<
"BEGIN lowerUpperSynchronize "<<block_size;}) ;
171 m_matrix_impl.m_matrix_dist_info.m_send_info,
172 m_matrix_impl.internal()->getSendIds(),
173 m_matrix_impl.m_send_policy,
174 y_impl.internal()->ghostValues(m_matrix_impl.getGhostSize()*block_size),
175 m_matrix_impl.m_matrix_dist_info.m_recv_info,
176 m_matrix_impl.internal()->getRecvIds(),
177 m_matrix_impl.m_recv_policy,
178 m_matrix_impl.m_parallel_mng,
179 m_matrix_impl.m_trace,
184 alien_debug([&]{cout()<<
"AFTER lowerUpperSynchronize "<<block_size;}) ;
187template <
typename ValueT>
188void SYCLBEllPackMatrixMultT<ValueT>::upperLowerSynchronize(
const VectorType& x_impl, VectorType& y_impl)
const
190 int block_size = m_matrix_impl.blockSize() ;
191 alien_debug([&]{cout()<<
"BEGIN upperLowerSynchronize "<<block_size;}) ;
194 m_matrix_impl.m_matrix_dist_info.m_send_info,
195 m_matrix_impl.internal()->getSendIds(),
196 m_matrix_impl.m_send_policy,
197 y_impl.internal()->ghostValues(m_matrix_impl.getGhostSize()*block_size),
198 m_matrix_impl.m_matrix_dist_info.m_recv_info,
199 m_matrix_impl.internal()->getRecvIds(),
200 m_matrix_impl.m_recv_policy,
201 m_matrix_impl.m_parallel_mng,
202 m_matrix_impl.m_trace,
207 alien_debug([&]{cout()<<
"END upperLowerSynchronize "<<block_size;}) ;
212template <
typename ValueT>
213void SYCLBEllPackMatrixMultT<ValueT>::multDiag(VectorType
const& y, VectorType& z)
const
215 m_matrix_impl.multDiag(y,z);
218template <
typename ValueT>
219void SYCLBEllPackMatrixMultT<ValueT>::multDiag(VectorType& y)
const
221 m_matrix_impl.multDiag(y);
224template <
typename ValueT>
225void SYCLBEllPackMatrixMultT<ValueT>::computeDiag(VectorType& y)
const
227 m_matrix_impl.computeDiag(y);
230template <
typename ValueT>
231void SYCLBEllPackMatrixMultT<ValueT>::multInvDiag(VectorType& y)
const
233 m_matrix_impl.multInvDiag(y);
236template <
typename ValueT>
237void SYCLBEllPackMatrixMultT<ValueT>::computeInvDiag(VectorType& y)
const
239 m_matrix_impl.computeInvDiag(y);
void mult(const VectorType &x, VectorType &y) const
Matrix vector product.
SYCLBEllPackMatrixMultT(const MatrixType &matrix)
Constructeur de la classe.