Skip to content

Commit

Permalink
SpAdd ETI: change Handle to use const values
Browse files Browse the repository at this point in the history
(to match other sparse kernels)
  • Loading branch information
brian-kelley committed May 6, 2022
1 parent cd37d79 commit 458c3cb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 28 deletions.
54 changes: 38 additions & 16 deletions src/sparse/KokkosSparse_spadd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,18 @@ void spadd_symbolic(
{
typedef typename KernelHandle::HandleExecSpace ExecSpace;
typedef typename KernelHandle::HandleTempMemorySpace MemSpace;
typedef typename KernelHandle::HandlePersistentMemorySpace PersistentMemSpace;
typedef typename Kokkos::Device<ExecSpace, MemSpace> DeviceType;

typedef typename KernelHandle::const_size_type c_size_t;
typedef typename KernelHandle::const_nnz_lno_t c_lno_t;
typedef typename KernelHandle::const_nnz_scalar_t c_scalar_t;

typedef typename KokkosKernels::Experimental::KokkosKernelsHandle<
c_size_t, c_lno_t, c_scalar_t, ExecSpace, MemSpace, PersistentMemSpace>
ConstKernelHandle;
ConstKernelHandle tmp_handle(*handle);

typedef Kokkos::View<typename alno_row_view_t_::const_value_type*,
typename KokkosKernels::Impl::GetUnifiedLayout<
alno_row_view_t_>::array_layout,
Expand All @@ -95,10 +105,10 @@ void spadd_symbolic(
clno_row_view_t_>::array_layout,
DeviceType, Kokkos::MemoryTraits<Kokkos::Unmanaged> >
Internal_c_rowmap;
KokkosSparse::Impl::SPADD_SYMBOLIC<KernelHandle, Internal_a_rowmap,
KokkosSparse::Impl::SPADD_SYMBOLIC<ConstKernelHandle, Internal_a_rowmap,
Internal_a_entries, Internal_b_rowmap,
Internal_b_entries, Internal_c_rowmap>::
spadd_symbolic(handle,
spadd_symbolic(&tmp_handle,
Internal_a_rowmap(a_rowmap.data(), a_rowmap.extent(0)),
Internal_a_entries(a_entries.data(), a_entries.extent(0)),
Internal_b_rowmap(b_rowmap.data(), b_rowmap.extent(0)),
Expand All @@ -122,8 +132,18 @@ void spadd_numeric(KernelHandle* handle, const alno_row_view_t_ a_rowmap,
cscalar_nnz_view_t_ c_values) {
typedef typename KernelHandle::HandleExecSpace ExecSpace;
typedef typename KernelHandle::HandleTempMemorySpace MemSpace;
typedef typename KernelHandle::HandlePersistentMemorySpace PersistentMemSpace;
typedef typename Kokkos::Device<ExecSpace, MemSpace> DeviceType;

typedef typename KernelHandle::const_size_type c_size_t;
typedef typename KernelHandle::const_nnz_lno_t c_lno_t;
typedef typename KernelHandle::const_nnz_scalar_t c_scalar_t;

typedef typename KokkosKernels::Experimental::KokkosKernelsHandle<
c_size_t, c_lno_t, c_scalar_t, ExecSpace, MemSpace, PersistentMemSpace>
ConstKernelHandle;
ConstKernelHandle tmp_handle(*handle);

typedef Kokkos::View<typename alno_row_view_t_::const_value_type*,
typename KokkosKernels::Impl::GetUnifiedLayout<
alno_row_view_t_>::array_layout,
Expand Down Expand Up @@ -169,20 +189,22 @@ void spadd_numeric(KernelHandle* handle, const alno_row_view_t_ a_rowmap,
cscalar_nnz_view_t_>::array_layout,
DeviceType, Kokkos::MemoryTraits<Kokkos::Unmanaged> >
Internal_c_values;
KokkosSparse::Impl::SPADD_NUMERIC<
KernelHandle, Internal_a_rowmap, Internal_a_entries, Internal_a_values,
Internal_b_rowmap, Internal_b_entries, Internal_b_values,
Internal_c_rowmap, Internal_c_entries, Internal_c_values>::
spadd_numeric(
handle, alpha, Internal_a_rowmap(a_rowmap.data(), a_rowmap.extent(0)),
Internal_a_entries(a_entries.data(), a_entries.extent(0)),
Internal_a_values(a_values.data(), a_values.extent(0)), beta,
Internal_b_rowmap(b_rowmap.data(), b_rowmap.extent(0)),
Internal_b_entries(b_entries.data(), b_entries.extent(0)),
Internal_b_values(b_values.data(), b_values.extent(0)),
Internal_c_rowmap(c_rowmap.data(), c_rowmap.extent(0)),
Internal_c_entries(c_entries.data(), c_entries.extent(0)),
Internal_c_values(c_values.data(), c_values.extent(0)));
KokkosSparse::Impl::SPADD_NUMERIC<ConstKernelHandle, Internal_a_rowmap,
Internal_a_entries, Internal_a_values,
Internal_b_rowmap, Internal_b_entries,
Internal_b_values, Internal_c_rowmap,
Internal_c_entries, Internal_c_values>::
spadd_numeric(&tmp_handle, alpha,
Internal_a_rowmap(a_rowmap.data(), a_rowmap.extent(0)),
Internal_a_entries(a_entries.data(), a_entries.extent(0)),
Internal_a_values(a_values.data(), a_values.extent(0)),
beta,
Internal_b_rowmap(b_rowmap.data(), b_rowmap.extent(0)),
Internal_b_entries(b_entries.data(), b_entries.extent(0)),
Internal_b_values(b_values.data(), b_values.extent(0)),
Internal_c_rowmap(c_rowmap.data(), c_rowmap.extent(0)),
Internal_c_entries(c_entries.data(), c_entries.extent(0)),
Internal_c_values(c_values.data(), c_values.extent(0)));
}
} // namespace Experimental

Expand Down
12 changes: 6 additions & 6 deletions src/sparse/impl/KokkosSparse_spadd_numeric_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ struct spadd_numeric_eti_spec_avail {
template <> \
struct spadd_numeric_eti_spec_avail< \
KokkosKernels::Experimental::KokkosKernelsHandle< \
OFFSET_TYPE, ORDINAL_TYPE, SCALAR_TYPE, EXEC_SPACE_TYPE, \
MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand Down Expand Up @@ -171,8 +171,8 @@ struct SPADD_NUMERIC<KernelHandle, a_size_view_t, a_lno_view_t, a_scalar_view_t,
MEM_SPACE_TYPE) \
extern template struct SPADD_NUMERIC< \
typename KokkosKernels::Experimental::KokkosKernelsHandle< \
OFFSET_TYPE, ORDINAL_TYPE, SCALAR_TYPE, EXEC_SPACE_TYPE, \
MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand Down Expand Up @@ -207,8 +207,8 @@ struct SPADD_NUMERIC<KernelHandle, a_size_view_t, a_lno_view_t, a_scalar_view_t,
MEM_SPACE_TYPE) \
template struct SPADD_NUMERIC< \
KokkosKernels::Experimental::KokkosKernelsHandle< \
OFFSET_TYPE, ORDINAL_TYPE, SCALAR_TYPE, EXEC_SPACE_TYPE, \
MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand Down
12 changes: 6 additions & 6 deletions src/sparse/impl/KokkosSparse_spadd_symbolic_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ struct spadd_symbolic_eti_spec_avail {
template <> \
struct spadd_symbolic_eti_spec_avail< \
KokkosKernels::Experimental::KokkosKernelsHandle< \
OFFSET_TYPE, ORDINAL_TYPE, SCALAR_TYPE, EXEC_SPACE_TYPE, \
MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand Down Expand Up @@ -140,8 +140,8 @@ struct SPADD_SYMBOLIC<KernelHandle, a_size_view_t, a_lno_view_t, b_size_view_t,
MEM_SPACE_TYPE) \
extern template struct SPADD_SYMBOLIC< \
typename KokkosKernels::Experimental::KokkosKernelsHandle< \
OFFSET_TYPE, ORDINAL_TYPE, SCALAR_TYPE, EXEC_SPACE_TYPE, \
MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand All @@ -164,8 +164,8 @@ struct SPADD_SYMBOLIC<KernelHandle, a_size_view_t, a_lno_view_t, b_size_view_t,
MEM_SPACE_TYPE) \
template struct SPADD_SYMBOLIC< \
KokkosKernels::Experimental::KokkosKernelsHandle< \
OFFSET_TYPE, ORDINAL_TYPE, SCALAR_TYPE, EXEC_SPACE_TYPE, \
MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
const OFFSET_TYPE, const ORDINAL_TYPE, const SCALAR_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::View<const OFFSET_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged> >, \
Expand Down

0 comments on commit 458c3cb

Please sign in to comment.