73 IndexType* ghost_uids)
75 , m_ncols(ncols,nrows)
78 mutable IndexBufferType m_rows;
79 mutable IndexBufferType m_ncols;
85 MatrixInternal(ProfileType* profile)
87 , m_values(sycl::range<1>(profile->getNnz()+1))
88 , m_kcol(profile->kcol(),profile->getNRows()+1)
89 , m_cols(profile->cols(),profile->getNnz())
91 m_values.set_final_data(
nullptr);
94 virtual ~MatrixInternal() {}
97 ProfileType& getCSRProfile() {
102 ProfileType
const& getCSRProfile()
const {
107 void setValues(ValueT value)
109 auto env = SYCLEnv::instance() ;
110 env->internal()->queue().submit([&](sycl::handler& cgh)
112 auto access_x = m_values.template get_access<sycl::access::mode::read_write>(cgh);
113 cgh.fill(access_x,value) ;
128 ValueBufferType& values()
133 ValueBufferType& values()
const
138 IndexBufferType& kcol() {
142 IndexBufferType
const& kcol()
const {
146 IndexBufferType& cols() {
150 IndexBufferType
const& cols()
const {
154 HypreProfile& getHypreProfile(IndexType local_offset)
const
156 if(m_hypre_profile.get()==
nullptr)
159 auto nrows = m_profile->getNRow();
160 auto kcol = m_profile->kcol() ;
161 m_global_rows_ids.resize(nrows) ;
162 m_row_sizes.resize(nrows) ;
163 for(IndexType irow=0;irow<nrows;++irow)
165 m_global_rows_ids[irow] = local_offset + irow;
166 m_row_sizes[irow] = kcol[irow+1] - kcol[irow];
168 m_hypre_profile.reset(
new HypreProfile(nrows,m_global_rows_ids.data(),m_row_sizes.data()));
170 return *m_hypre_profile ;
173 COOProfile& getCOOProfile(IndexType local_offset,
174 std::size_t ghost_size=0,
175 const int* ghost_uids=
nullptr)
const
178 cout() <<
"create COOProfile "<<m_coo_profile.get()<<
" "<<m_profile->getNRow()<<
" "<< m_profile->getNnz()<<
" "<<ghost_size<<
" "<<ghost_uids;
180 if(m_coo_profile.get()==
nullptr)
183 auto nrows = m_profile->getNRow();
184 auto nnz = m_profile->getNnz();
185 auto kcol = m_profile->kcol() ;
186 m_global_rows_ids.resize(nnz) ;
187 m_row_sizes.resize(nrows) ;
188 for(IndexType irow=0;irow<nrows;++irow)
190 auto row_uid = local_offset + irow;
191 m_row_sizes[irow] = kcol[irow+1] - kcol[irow];
192 for(std::size_t k=kcol[irow];k<kcol[irow+1];++k)
193 m_global_rows_ids[k] = row_uid ;
195 IndexType* ghost_uids_ptr = ghost_uids ? (IndexType*)ghost_uids : (IndexType*)&m_empty_ghost_uids ;
200 m_global_rows_ids.data(),
205 cout() <<
"create COOProfile OK";
207 return *m_coo_profile ;
212 void copyValuesToHost(std::size_t nnz, ValueT* ptr)
214 auto h_values = m_values.get_host_access();
215 for (std::size_t i = 0; i < nnz; ++i)
216 ptr[i] = h_values[i];
218 ProfileType* m_profile = nullptr ;
220 mutable ValueBufferType m_values;
221 mutable IndexBufferType m_kcol;
222 mutable IndexBufferType m_cols;
223 mutable std::vector<IndexType> m_global_rows_ids;
224 mutable std::vector<IndexType> m_row_sizes;
225 mutable std::unique_ptr<HypreProfile> m_hypre_profile ;
226 mutable std::unique_ptr<COOProfile> m_coo_profile ;
227 Integer m_empty_ghost_uids = 0 ;
234 template <
typename ValueT>
239 m_profile.reset(
new ProfileType()) ;
243 template <
typename ValueT>
248 m_profile.reset(
new ProfileType()) ;
252 template <
typename ValueT>