46 static const bool on_host_only = false ;
48 typedef ValueT ValueType;
49 typedef ValueT value_type ;
57 typedef typename ProfileType::IndexType IndexType ;
74 void setTraceMng(ITraceMng* trace_mng) { m_trace = trace_mng; }
78 CSRStructInfo& getCSRProfile() {
return *m_profile; }
80 const CSRStructInfo& getCSRProfile()
const {
return *m_profile; }
82 const CSRStructInfo& getProfile()
const {
return *m_profile; }
84 const DistStructInfo& getDistStructInfo()
const {
return m_matrix_dist_info; }
86 IMessagePassingMng* getParallelMng()
88 return m_parallel_mng;
92 void sequentialStart()
95 m_local_size = getCSRProfile().getNRows();
96 m_global_size = m_local_size;
99 m_is_parallel =
false;
100 m_matrix_dist_info.m_local_row_size.resize(m_local_size);
101 auto& profile = internal()->getCSRProfile();
102 ConstArrayView<Integer> offset = profile.getRowOffset();
103 for (Integer i = 0; i < m_local_size; ++i)
104 m_matrix_dist_info.m_local_row_size[i] = offset[i + 1] - offset[i];
107 void parallelStart(ConstArrayView<Integer> offset, IMessagePassingMng* parallel_mng,
108 bool need_sort_ghost_col =
false)
110 m_local_size = getCSRProfile().getNRows();
111 m_parallel_mng = parallel_mng;
113 if (m_parallel_mng == NULL) {
115 m_global_size = m_local_size;
118 m_is_parallel =
false;
121 m_myrank = m_parallel_mng->commRank();
122 m_nproc = m_parallel_mng->commSize();
123 m_local_offset = offset[m_myrank];
124 m_global_size = offset[m_nproc];
125 m_is_parallel = (m_nproc > 1);
128 if (need_sort_ghost_col)
129 sortGhostCols(offset);
130 m_matrix_dist_info.compute(
131 m_nproc, offset, m_myrank, m_parallel_mng, getCSRProfile(), m_trace);
133 m_ghost_size = m_matrix_dist_info.m_ghost_nrow;
138 bool initMatrix(Arccore::MessagePassing::IMessagePassingMng* parallel_mng,
139 Integer local_offset,
144 SimpleCSRInternal::DistStructInfo
const& matrix_dist_info);
146 HCSRMatrix* cloneTo(
const MultiMatrixImpl* multi)
const;
148 bool isParallel()
const {
return m_is_parallel; }
150 Integer getLocalSize()
const {
return m_local_size; }
152 Integer getLocalOffset()
const {
return m_local_offset; }
154 Integer getGlobalSize()
const {
return m_global_size; }
156 Integer getGhostSize()
const {
return m_ghost_size; }
158 Integer getAllocSize()
const {
return m_local_size + m_ghost_size; }
160 bool setMatrixValues(Arccore::Real
const* values,
bool only_host);
162 void notifyChanges();
165 MatrixInternal* internal() {
return m_internal.get(); }
167 MatrixInternal
const* internal()
const {
return m_internal.get(); }
169 void allocateDevicePointers(std::size_t nrows,
174 ValueType** values)
const ;
176 void initDevicePointers(IndexType** ncols,
179 ValueType** values)
const ;
181 void freeDevicePointers(IndexType* ncols,
184 ValueType* values)
const ;
186 void copyDevicePointers(std::size_t nrows,
191 ValueType* values)
const ;
193 HCSRView hcsrView(BackEnd::Memory::eType memory,
int nrows,
int nnz)
const;
195 void initCOODevicePointers(
int** dof_uids,
int** rows,
int** cols, ValueType** values)
const ;
196 void freeCOODevicePointers(
int* dof_uids,
int* rows,
int* cols, ValueType* values)
const ;
202 IsLocal(
const ConstArrayView<Integer> offset,
const Integer myrank)
206 bool operator()(Arccore::Integer col)
const
208 return (col >= m_offset[m_myrank]) && (col < m_offset[m_myrank + 1]);
212 const ConstArrayView<Integer> m_offset;
213 const Integer m_myrank;
217 void sortGhostCols([[maybe_unused]] ConstArrayView<Integer> offset)
271 Alien::BackEnd::Memory::eType m_mem_kind = Alien::BackEnd::Memory::Device;
272 std::unique_ptr<ProfileType> m_profile;
273 std::unique_ptr<InternalType> m_internal;
277 bool m_is_parallel =
false;
278 IMessagePassingMng* m_parallel_mng =
nullptr;
280 Integer m_myrank = 0;
282 Integer m_local_size = 0;
283 Integer m_local_offset = 0;
284 Integer m_global_size = 0;
285 Integer m_ghost_size = 0;
288 DistStructInfo m_matrix_dist_info;
289 ITraceMng* m_trace =
nullptr;