Skip to content

Commit

Permalink
Add newlines in matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Dec 1, 2023
1 parent d0e74b8 commit c62b4fb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
14 changes: 14 additions & 0 deletions include/ddc/kernels/splines/matrix.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#include <algorithm>
#include <cassert>
#include <iomanip>
Expand All @@ -12,14 +13,20 @@
#include "view.hpp"

namespace ddc::detail {

class Matrix
{
public:
Matrix(const int mat_size) : n(mat_size) {}

virtual ~Matrix() = default;

int n;

virtual double get_element(int i, int j) const = 0;

virtual void set_element(int i, int j, double aij) = 0;

virtual void factorize()
{
int const info = factorize_method();
Expand All @@ -37,6 +44,7 @@ class Matrix
// TODO: Add LOG_FATAL_ERROR
}
}

virtual ddc::DSpan1D solve_inplace(ddc::DSpan1D const b) const
{
assert(int(b.extent(0)) == n);
Expand All @@ -48,6 +56,7 @@ class Matrix
}
return b;
}

virtual ddc::DSpan1D solve_transpose_inplace(ddc::DSpan1D const b) const
{
assert(int(b.extent(0)) == n);
Expand All @@ -59,6 +68,7 @@ class Matrix
}
return b;
}

virtual ddc::DSpan2D solve_multiple_inplace(ddc::DSpan2D const bx) const
{
assert(int(bx.extent(1)) == n);
Expand All @@ -70,6 +80,7 @@ class Matrix
}
return bx;
}

template <class... Args>
Kokkos::View<double**, Args...> solve_batch_inplace(
Kokkos::View<double**, Args...> const bx) const
Expand All @@ -83,6 +94,7 @@ class Matrix
}
return bx;
}

int get_size() const
{
return n;
Expand All @@ -102,6 +114,8 @@ class Matrix

protected:
virtual int factorize_method() = 0;

virtual int solve_inplace_method(double* b, char transpose, int n_equations) const = 0;
};

} // namespace ddc::detail
4 changes: 3 additions & 1 deletion include/ddc/kernels/splines/matrix_maker.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#pragma once

#include <memory>

#include "matrix_sparse.hpp"


namespace ddc::detail {

class MatrixMaker
{
public:
Expand All @@ -22,4 +23,5 @@ class MatrixMaker
preconditionner_max_block_size);
}
};

} // namespace ddc::detail
7 changes: 7 additions & 0 deletions include/ddc/kernels/splines/matrix_sparse.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#include <algorithm>
#include <cassert>
#include <iomanip>
Expand All @@ -25,9 +26,13 @@ class Matrix_Sparse : public Matrix
{
private:
const int m_m;

const int m_n;

Kokkos::View<int*, Kokkos::HostSpace> m_rows;

Kokkos::View<int*, Kokkos::HostSpace> m_cols;

Kokkos::View<double*, Kokkos::HostSpace> m_data;

std::unique_ptr<
Expand All @@ -36,7 +41,9 @@ class Matrix_Sparse : public Matrix
m_solver_factory;

int m_cols_per_par_chunk; // Maximum number of columns of B to be passed to a Ginkgo solver

int m_par_chunks_per_seq_chunk; // Maximum number of teams to be executed in parallel

int m_preconditionner_max_block_size; // Maximum size of Jacobi-block preconditionner

public:
Expand Down

0 comments on commit c62b4fb

Please sign in to comment.