Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cwpearson committed Aug 11, 2022
1 parent fd7f321 commit 2978175
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 82 deletions.
44 changes: 20 additions & 24 deletions src/sparse/KokkosSparse_Utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ enum class SparseMatrixFormat {
namespace Impl {

/* create a block-sparse version of a CrsMatrix
*/
*/
template <typename in_row_view_t, typename in_nnz_view_t,
typename in_val_view_t, typename out_row_view_t,
typename out_nnz_view_t, typename out_val_view_t>
void kk_create_bsr_formated_point_crsmatrix(
int block_size, size_t num_rows, size_t num_cols, in_row_view_t in_xadj,
in_nnz_view_t in_adj, in_val_view_t in_vals,
size_t &out_num_rows, size_t &out_num_cols, out_row_view_t &out_xadj,
out_nnz_view_t &out_adj, out_val_view_t &out_vals) {
in_nnz_view_t in_adj, in_val_view_t in_vals, size_t &out_num_rows,
size_t &out_num_cols, out_row_view_t &out_xadj, out_nnz_view_t &out_adj,
out_val_view_t &out_vals) {
typedef typename in_nnz_view_t::non_const_value_type lno_t;
typedef typename in_row_view_t::non_const_value_type size_type;
typedef typename in_val_view_t::non_const_value_type scalar_t;
Expand Down Expand Up @@ -222,38 +222,34 @@ template <typename in_row_view_t, typename in_nnz_view_t,
typename in_val_view_t, typename out_row_view_t,
typename out_nnz_view_t, typename out_val_view_t>
void kk_create_bsr_from_bsr_formatted_point_crs(
int block_size, size_t num_rows, size_t num_cols,
in_row_view_t in_xadj, // row pointer (CrsMatrix::graph.row_map)
in_nnz_view_t in_adj, // col index (CrsMatrix::graph.entries)
in_val_view_t in_vals, // values CrsMatrix::values
size_t &out_num_rows, // rows of blocks in output
size_t &out_num_cols, // cols of blocks in output
out_row_view_t &out_xadj,
out_nnz_view_t &out_adj,
out_val_view_t &out_vals
) {


int block_size, size_t num_rows, size_t num_cols,
in_row_view_t in_xadj, // row pointer (CrsMatrix::graph.row_map)
in_nnz_view_t in_adj, // col index (CrsMatrix::graph.entries)
in_val_view_t in_vals, // values CrsMatrix::values
size_t &out_num_rows, // rows of blocks in output
size_t &out_num_cols, // cols of blocks in output
out_row_view_t &out_xadj, out_nnz_view_t &out_adj,
out_val_view_t &out_vals) {
// reconstruct CrsMatrix
typedef typename in_nnz_view_t::non_const_value_type in_ordinal_type;
typedef typename in_val_view_t::non_const_value_type in_scalar_type;
typedef typename in_nnz_view_t::device_type in_device_type;
typedef KokkosSparse::CrsMatrix<in_scalar_type, in_ordinal_type, in_device_type> InMatrix;
typedef KokkosSparse::CrsMatrix<in_scalar_type, in_ordinal_type,
in_device_type>
InMatrix;
InMatrix in("", num_rows, num_cols, in_vals.size(), in_vals, in_xadj, in_adj);

// convert to BsrMatrix
typedef typename out_nnz_view_t::non_const_value_type out_ordinal_type;
typedef typename out_val_view_t::non_const_value_type out_scalar_type;
typedef typename out_nnz_view_t::device_type out_device_type;
typedef KokkosSparse::Experimental::BsrMatrix<
out_scalar_type,
out_ordinal_type,
out_device_type
> OutMatrix;
out_scalar_type, out_ordinal_type, out_device_type>
OutMatrix;
OutMatrix out(in, block_size);

out_xadj = out.graph.row_map;
out_adj = out.graph.entries;
out_adj = out.graph.entries;
out_vals = out.values;
}

Expand Down Expand Up @@ -1950,7 +1946,6 @@ class RowIndexBase {
lno_t row_size;
};


/* The only use of this is in Sparse Gauss Seidel, which is only implemented
for BSR and CRS, which are identical when block size is 1
Expand All @@ -1960,7 +1955,8 @@ class MatrixRowIndex;

/* CWP August 11 2022
This is pretty much the old BlockCRS one, but
Should be able to create a specialized version of this for CRS because block size is 1
Should be able to create a specialized version of this for CRS because block
size is 1
*/
template <typename lno_t, typename size_type>
class MatrixRowIndex<SparseMatrixFormat::CRS, lno_t, size_type>
Expand Down
27 changes: 18 additions & 9 deletions src/sparse/KokkosSparse_gauss_seidel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ void block_gauss_seidel_symbolic(
is_graph_symmetric);
}

template <KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::CRS,
template <KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::CRS,
typename KernelHandle, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_>
void gauss_seidel_numeric(KernelHandle *handle,
Expand Down Expand Up @@ -207,7 +208,8 @@ void gauss_seidel_numeric(KernelHandle *handle,
is_graph_symmetric);
}

template <KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::CRS,
template <KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::CRS,
typename KernelHandle, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_>
void gauss_seidel_numeric(KernelHandle *handle,
Expand Down Expand Up @@ -286,7 +288,8 @@ void gauss_seidel_numeric(KernelHandle *handle,
is_graph_symmetric);
}

template <KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::BSR,
template <KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::BSR,
typename KernelHandle, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_>
void block_gauss_seidel_numeric(
Expand All @@ -307,7 +310,8 @@ void block_gauss_seidel_numeric(
values, is_graph_symmetric);
}

template <KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::CRS,
template <KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::CRS,
typename KernelHandle, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_,
typename x_scalar_view_t, typename y_scalar_view_t>
Expand Down Expand Up @@ -437,7 +441,8 @@ void symmetric_gauss_seidel_apply(
update_y_vector, omega, numIter, true, true);
}

template <KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::BSR,
template <KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::BSR,
typename KernelHandle, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_,
typename x_scalar_view_t, typename y_scalar_view_t>
Expand Down Expand Up @@ -471,7 +476,8 @@ void symmetric_block_gauss_seidel_apply(
handle, num_rows, num_cols, row_map, entries, values, x_lhs_output_vec,
y_rhs_input_vec, init_zero_x_vector, update_y_vector, omega, numIter);
}
template <KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::CRS,
template <KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::CRS,
class KernelHandle, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_,
typename x_scalar_view_t, typename y_scalar_view_t>
Expand Down Expand Up @@ -603,7 +609,8 @@ void forward_sweep_gauss_seidel_apply(
update_y_vector, omega, numIter, true, false);
}

template <KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::BSR,
template <KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::BSR,
typename KernelHandle, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_,
typename x_scalar_view_t, typename y_scalar_view_t>
Expand Down Expand Up @@ -637,7 +644,8 @@ void forward_sweep_block_gauss_seidel_apply(
handle, num_rows, num_cols, row_map, entries, values, x_lhs_output_vec,
y_rhs_input_vec, init_zero_x_vector, update_y_vector, omega, numIter);
}
template <KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::CRS,
template <KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::CRS,
class KernelHandle, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_,
typename x_scalar_view_t, typename y_scalar_view_t>
Expand Down Expand Up @@ -769,7 +777,8 @@ void backward_sweep_gauss_seidel_apply(
update_y_vector, omega, numIter, false, true);
}

template <KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::BSR,
template <KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::BSR,
typename KernelHandle, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_,
typename x_scalar_view_t, typename y_scalar_view_t>
Expand Down
25 changes: 12 additions & 13 deletions src/sparse/KokkosSparse_spmv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ struct SPMV2D1D<AlphaType, AMatrix, XVector, BetaType, YVector,

/// \brief Tag-dispatch sparse matrix-vector multiply on multivectors
///
/// \tparam AMatrix A KokkosSparse::CrsMatrix, KokkosSparse::Experimental::BsrMatrix
/// \tparam AMatrix A KokkosSparse::CrsMatrix,
/// KokkosSparse::Experimental::BsrMatrix
///
/// \param controls [in] kokkos-kernels control structure.
/// \param mode [in] \c "N" for no transpose
Expand Down Expand Up @@ -870,7 +871,6 @@ void spmv(KokkosKernels::Experimental::Controls controls, const char mode[],
}
}


/// \brief Public interface to local sparse matrix-vector multiply.
///
/// Compute y = beta*y + alpha*Op(A)*x, where x and y are either both
Expand All @@ -896,7 +896,8 @@ void spmv(KokkosKernels::Experimental::Controls controls, const char mode[],
/// enabled for Kokkos::CrsMatrix and Kokkos::Experimental::BsrMatrix on a
/// single vector, or for Kokkos::Experimental::BsrMatrix with a multivector.
///
/// \tparam AMatrix KokkosSparse::CrsMatrix or KokkosSparse::Experimental::BsrMatrix
/// \tparam AMatrix KokkosSparse::CrsMatrix or
/// KokkosSparse::Experimental::BsrMatrix
///
/// \param controls [in] kokkos-kernels control structure
/// \param mode [in] "N" for no transpose, "T" for transpose, or "C"
Expand Down Expand Up @@ -980,22 +981,20 @@ void spmv(KokkosKernels::Experimental::Controls controls, const char mode[],
/// This is a catch-all interfaceace that throws a compile-time error if \c
/// AMatrix is not a CrsMatrix, or BsrMatrix
///
template <
class AlphaType, class AMatrix, class XVector, class BetaType,
class YVector,
typename std::enable_if<
!KokkosSparse::Experimental::is_bsr_matrix<AMatrix>::value &&
!KokkosSparse::is_crs_matrix<AMatrix>::value>::type* = nullptr>
template <class AlphaType, class AMatrix, class XVector, class BetaType,
class YVector,
typename std::enable_if<
!KokkosSparse::Experimental::is_bsr_matrix<AMatrix>::value &&
!KokkosSparse::is_crs_matrix<AMatrix>::value>::type* = nullptr>
void spmv(KokkosKernels::Experimental::Controls /*controls*/,
const char[] /*mode*/, const AlphaType& /*alpha*/,
const AMatrix& /*A*/, const XVector& /*x*/, const BetaType& /*beta*/,
const YVector& /*y*/) {
// have to arrange this so that the compiler can't tell this is false until
// instantiation
static_assert(
KokkosSparse::is_crs_matrix<AMatrix>::value ||
KokkosSparse::Experimental::is_bsr_matrix<AMatrix>::value,
"SpMV: AMatrix must be CrsMatrix or BsrMatrix");
static_assert(KokkosSparse::is_crs_matrix<AMatrix>::value ||
KokkosSparse::Experimental::is_bsr_matrix<AMatrix>::value,
"SpMV: AMatrix must be CrsMatrix or BsrMatrix");
}

// Overload for backward compatibility and also just simpler
Expand Down
3 changes: 2 additions & 1 deletion src/sparse/impl/KokkosSparse_gauss_seidel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ namespace Impl {

template <typename HandleType, typename lno_row_view_t_,
typename lno_nnz_view_t_, typename scalar_nnz_view_t_,
KokkosSparse::SparseMatrixFormat format = KokkosSparse::SparseMatrixFormat::CRS>
KokkosSparse::SparseMatrixFormat format =
KokkosSparse::SparseMatrixFormat::CRS>
class PointGaussSeidel {
public:
typedef lno_row_view_t_ in_lno_row_view_t;
Expand Down
25 changes: 12 additions & 13 deletions src/sparse/impl/KokkosSparse_gauss_seidel_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ struct GAUSS_SEIDEL_APPLY<KernelHandle, format, a_size_view_t_, a_lno_view_t,
KokkosKernels::Experimental::KokkosKernelsHandle< \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, SLOW_MEM_SPACE>, \
KokkosSparse::SparseMatrixFormat::BSR, \
KokkosSparse::SparseMatrixFormat::BSR, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand All @@ -393,12 +393,12 @@ struct GAUSS_SEIDEL_APPLY<KernelHandle, format, a_size_view_t_, a_lno_view_t,
Kokkos::View<const SCALAR_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
false, true>; \
false, true>; \
extern template struct GAUSS_SEIDEL_NUMERIC< \
KokkosKernels::Experimental::KokkosKernelsHandle< \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, SLOW_MEM_SPACE>, \
KokkosSparse::SparseMatrixFormat::CRS, \
KokkosSparse::SparseMatrixFormat::CRS, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand All @@ -417,7 +417,7 @@ struct GAUSS_SEIDEL_APPLY<KernelHandle, format, a_size_view_t_, a_lno_view_t,
KokkosKernels::Experimental::KokkosKernelsHandle< \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, SLOW_MEM_SPACE>, \
KokkosSparse::SparseMatrixFormat::BSR, \
KokkosSparse::SparseMatrixFormat::BSR, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand All @@ -432,7 +432,7 @@ struct GAUSS_SEIDEL_APPLY<KernelHandle, format, a_size_view_t_, a_lno_view_t,
KokkosKernels::Experimental::KokkosKernelsHandle< \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, SLOW_MEM_SPACE>, \
KokkosSparse::SparseMatrixFormat::CRS, \
KokkosSparse::SparseMatrixFormat::CRS, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand All @@ -451,7 +451,7 @@ struct GAUSS_SEIDEL_APPLY<KernelHandle, format, a_size_view_t_, a_lno_view_t,
KokkosKernels::Experimental::KokkosKernelsHandle< \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, SLOW_MEM_SPACE>, \
KokkosSparse::SparseMatrixFormat::BSR, \
KokkosSparse::SparseMatrixFormat::BSR, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand All @@ -467,12 +467,12 @@ struct GAUSS_SEIDEL_APPLY<KernelHandle, format, a_size_view_t_, a_lno_view_t,
Kokkos::View<const SCALAR_TYPE **, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
false, true>; \
false, true>; \
extern template struct GAUSS_SEIDEL_APPLY< \
KokkosKernels::Experimental::KokkosKernelsHandle< \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, SLOW_MEM_SPACE>, \
KokkosSparse::SparseMatrixFormat::CRS, \
KokkosSparse::SparseMatrixFormat::CRS, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand All @@ -488,8 +488,7 @@ struct GAUSS_SEIDEL_APPLY<KernelHandle, format, a_size_view_t_, a_lno_view_t,
Kokkos::View<const SCALAR_TYPE **, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
false, true>; \

false, true>;

#define KOKKOSSPARSE_GAUSS_SEIDEL_APPLY_ETI_SPEC_INST( \
SCALAR_TYPE, ORDINAL_TYPE, OFFSET_TYPE, LAYOUT_TYPE, EXEC_SPACE_TYPE, \
Expand All @@ -498,7 +497,7 @@ struct GAUSS_SEIDEL_APPLY<KernelHandle, format, a_size_view_t_, a_lno_view_t,
KokkosKernels::Experimental::KokkosKernelsHandle< \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, SLOW_MEM_SPACE>, \
KokkosSparse::SparseMatrixFormat::BSR, \
KokkosSparse::SparseMatrixFormat::BSR, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand All @@ -514,12 +513,12 @@ struct GAUSS_SEIDEL_APPLY<KernelHandle, format, a_size_view_t_, a_lno_view_t,
Kokkos::View<const SCALAR_TYPE **, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
false, true>; \
false, true>; \
template struct GAUSS_SEIDEL_APPLY< \
KokkosKernels::Experimental::KokkosKernelsHandle< \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, SLOW_MEM_SPACE>, \
KokkosSparse::SparseMatrixFormat::CRS, \
KokkosSparse::SparseMatrixFormat::CRS, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand Down
Loading

0 comments on commit 2978175

Please sign in to comment.