15#include <dr/detail/matrix_io.hpp>
16#include <dr/views/csr_matrix_view.hpp>
20template <
typename T,
typename I>
22 const matrix_partition &partition) {
25 std::vector<dr::views::csr_matrix_view<T, I>> views;
26 std::vector<sycl::event> events;
27 views.reserve(a.grid_shape()[0] * a.grid_shape()[1]);
29 for (I i = 0; i < a.grid_shape()[0]; i++) {
30 for (I j = 0; j < a.grid_shape()[1]; j++) {
31 auto &&tile = a.tile({i, j});
33 i * a.tile_shape()[0] + tile.shape()[0]);
35 j * a.tile_shape()[1] + tile.shape()[1]);
37 auto local_submat = local_mat.submatrix(row_bounds, column_bounds);
39 auto submatrix_shape =
dr::index<I>(row_bounds[1] - row_bounds[0],
40 column_bounds[1] - column_bounds[0]);
42 auto copied_submat = dr::__detail::convert_to_csr(
43 local_submat, submatrix_shape, rng::distance(local_submat),
46 auto e = a.copy_tile_async({i, j}, copied_submat);
48 views.push_back(copied_submat);
52 __detail::wait(events);
54 for (
auto &&view : views) {
55 dr::__detail::destroy_csr_matrix_view(view, std::allocator<T>{});
61template <
typename T,
typename I>
63 return create_distributed(
65 {dr::sp::nprocs(), 1}));
68template <
typename T,
typename I = std::
size_t>
69auto mmread(std::string file_path,
const matrix_partition &partition,
70 bool one_indexed =
true) {
71 auto local_mat = read_csr<T, I>(file_path, one_indexed);
73 auto a = create_distributed(local_mat, partition);
75 dr::__detail::destroy_csr_matrix_view(local_mat, std::allocator<T>{});
80template <
typename T,
typename I = std::
size_t>
81auto mmread(std::string file_path,
bool one_indexed =
true) {
82 return mmread<T, I>(file_path, dr::sp::row_cyclic(), one_indexed);
Definition: matrix_partition.hpp:34
Definition: sparse_matrix.hpp:135
Definition: csr_matrix_view.hpp:126