Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparse MKL: changing the location of the MKL_SAFE_CALL macro #2134

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
#include "KokkosSparse_spmv_bsrmatrix_spec.hpp"

namespace KokkosSparse {
namespace Experimental {
namespace Impl {
// clang-format off
@SPARSE_SPMV_BSRMATRIX_ETI_INST_BLOCK@
// clang-format on
} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse
} // namespace KokkosSparse
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
#include "KokkosSparse_spmv_bsrmatrix_spec.hpp"

namespace KokkosSparse {
namespace Experimental {
namespace Impl {
// clang-format off
@SPARSE_SPMV_MV_BSRMATRIX_ETI_INST_BLOCK@
/// // clang-format on
} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
#ifndef KOKKOSSPARSE_SPMV_BSRMATRIX_ETI_SPEC_AVAIL_HPP_
#define KOKKOSSPARSE_SPMV_BSRMATRIX_ETI_SPEC_AVAIL_HPP_
namespace KokkosSparse {
namespace Experimental {
namespace Impl {
// clang-format off
@SPARSE_SPMV_BSRMATRIX_ETI_AVAIL_BLOCK@
// clang-format on
} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
#define KOKKOSSPARSE_SPMV_MV_BSRMATRIX_ETI_SPEC_AVAIL_HPP_

namespace KokkosSparse {
namespace Experimental {
namespace Impl {
// clang-format off
@SPARSE_SPMV_MV_BSRMATRIX_ETI_AVAIL_BLOCK@
// clang-format on
} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse
#endif
5 changes: 0 additions & 5 deletions sparse/impl/KokkosSparse_spmv_bsrmatrix_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <mma.h>

namespace KokkosSparse {
namespace Experimental {
namespace Impl {

struct BsrMatrixSpMVTensorCoreFunctorParams {
Expand Down Expand Up @@ -519,7 +518,6 @@ struct BsrMatrixSpMVTensorCoreDispatcher {
};

} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse

#endif // #if CUDA && (VOLTA || AMPERE)
Expand All @@ -537,7 +535,6 @@ struct BsrMatrixSpMVTensorCoreDispatcher {
#include "KokkosKernels_ExecSpaceUtils.hpp"

namespace KokkosSparse {
namespace Experimental {
namespace Impl {
namespace Bsr {

Expand Down Expand Up @@ -1735,9 +1732,7 @@ void spMatMultiVec_transpose(const execution_space &exec, Handle *handle,
/* ******************* */

} // namespace Bsr

} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse

#endif // KOKKOSSPARSE_IMPL_SPMV_BSRMATRIX_IMPL_HPP_
14 changes: 5 additions & 9 deletions sparse/impl/KokkosSparse_spmv_bsrmatrix_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#endif

namespace KokkosSparse {
namespace Experimental {
namespace Impl {

// default is no eti available
Expand All @@ -47,10 +46,6 @@ struct spmv_mv_bsrmatrix_eti_spec_avail {
enum : bool { value = false };
};

} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse

#define KOKKOSSPARSE_SPMV_BSRMATRIX_ETI_SPEC_AVAIL( \
SCALAR_TYPE, ORDINAL_TYPE, OFFSET_TYPE, LAYOUT_TYPE, EXEC_SPACE_TYPE, \
MEM_SPACE_TYPE) \
Expand Down Expand Up @@ -97,13 +92,15 @@ struct spmv_mv_bsrmatrix_eti_spec_avail {
enum : bool { value = true }; \
};

} // namespace Impl
} // namespace KokkosSparse

// Include which ETIs are available
#include <KokkosSparse_spmv_bsrmatrix_tpl_spec_avail.hpp>
#include <generated_specializations_hpp/KokkosSparse_spmv_bsrmatrix_eti_spec_avail.hpp>
#include <generated_specializations_hpp/KokkosSparse_spmv_mv_bsrmatrix_eti_spec_avail.hpp>

namespace KokkosSparse {
namespace Experimental {
namespace Impl {

// declaration
Expand Down Expand Up @@ -218,8 +215,8 @@ struct SPMV_MV_BSRMATRIX<ExecutionSpace, Handle, AMatrix, XVector, YVector,
{
// try to use tensor cores if requested
if (handle->algo == SPMV_BSR_TC) method = Method::TensorCores;
if (!KokkosSparse::Experimental::Impl::TensorCoresAvailable<
ExecutionSpace, AMatrix, XVector, YVector>::value) {
if (!KokkosSparse::Impl::TensorCoresAvailable<ExecutionSpace, AMatrix,
XVector, YVector>::value) {
method = Method::Fallback;
}
// can't use tensor cores unless mode is no-transpose
Expand Down Expand Up @@ -365,7 +362,6 @@ struct SPMV_MV_BSRMATRIX<ExecutionSpace, Handle, AMatrix, XVector, YVector,
#endif // !defined(KOKKOSKERNELS_ETI_ONLY) ||
// KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse

// declare / instantiate the vector version
Expand Down
6 changes: 6 additions & 0 deletions sparse/src/KokkosSparse_Utils_mkl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ inline void mkl_internal_safe_call(sparse_status_t mkl_status, const char *name,
}
}

} // namespace Impl
} // namespace KokkosSparse

brian-kelley marked this conversation as resolved.
Show resolved Hide resolved
#define KOKKOSKERNELS_MKL_SAFE_CALL(call) \
KokkosSparse::Impl::mkl_internal_safe_call(call, #call, __FILE__, __LINE__)

namespace KokkosSparse {
namespace Impl {

inline sparse_operation_t mode_kk_to_mkl(char mode_kk) {
switch (toupper(mode_kk)) {
case 'N': return SPARSE_OPERATION_NON_TRANSPOSE;
Expand Down
21 changes: 11 additions & 10 deletions sparse/src/KokkosSparse_spmv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,17 @@ void spmv(const ExecutionSpace& space, Handle* handle, const char mode[],
typename AMatrix_Internal::non_const_value_type>::name() +
"]";
Kokkos::Profiling::pushRegion(label);
Experimental::Impl::SPMV_BSRMATRIX<
ExecutionSpace, HandleImpl, AMatrix_Internal, XVector_Internal,
YVector_Internal, false>::spmv_bsrmatrix(space, handle, mode, alpha,
A_i, x_i, beta, y_i);
Impl::SPMV_BSRMATRIX<ExecutionSpace, HandleImpl, AMatrix_Internal,
XVector_Internal, YVector_Internal,
false>::spmv_bsrmatrix(space, handle, mode, alpha,
A_i, x_i, beta, y_i);
Kokkos::Profiling::popRegion();
} else {
Experimental::Impl::SPMV_BSRMATRIX<
ExecutionSpace, HandleImpl, AMatrix_Internal, XVector_Internal,
YVector_Internal>::spmv_bsrmatrix(space, handle, mode, alpha, A_i,
x_i, beta, y_i);
Impl::SPMV_BSRMATRIX<ExecutionSpace, HandleImpl, AMatrix_Internal,
XVector_Internal,
YVector_Internal>::spmv_bsrmatrix(space, handle,
mode, alpha, A_i,
x_i, beta, y_i);
}
} else {
/////////////////
Expand Down Expand Up @@ -376,7 +377,7 @@ void spmv(const ExecutionSpace& space, Handle* handle, const char mode[],
typename AMatrix_Internal::non_const_value_type>::name() +
"]";
Kokkos::Profiling::pushRegion(label);
Experimental::Impl::SPMV_MV_BSRMATRIX<
Impl::SPMV_MV_BSRMATRIX<
ExecutionSpace, HandleImpl, AMatrix_Internal, XVector_Internal,
YVector_Internal,
std::is_integral<
Expand All @@ -385,7 +386,7 @@ void spmv(const ExecutionSpace& space, Handle* handle, const char mode[],
beta, y_i);
Kokkos::Profiling::popRegion();
} else {
Experimental::Impl::SPMV_MV_BSRMATRIX<
Impl::SPMV_MV_BSRMATRIX<
ExecutionSpace, HandleImpl, AMatrix_Internal, XVector_Internal,
YVector_Internal,
std::is_integral<typename AMatrix_Internal::const_value_type>::
Expand Down
2 changes: 0 additions & 2 deletions sparse/tpls/KokkosSparse_spmv_bsrmatrix_tpl_spec_avail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#endif

namespace KokkosSparse {
namespace Experimental {
namespace Impl {
// Specialization struct which defines whether a specialization exists
template <class ExecutionSpace, class Handle, class AMatrix, class XVector,
Expand Down Expand Up @@ -348,7 +347,6 @@ KOKKOSSPARSE_SPMV_BSRMATRIX_TPL_SPEC_AVAIL_ROCSPARSE(Kokkos::complex<double>,
#endif // defined(KOKKOSKERNELS_ENABLE_TPL_ROCSPARSE)

} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse

#endif // KOKKOSPARSE_SPMV_BSRMATRIX_TPL_SPEC_AVAIL_HPP_
8 changes: 0 additions & 8 deletions sparse/tpls/KokkosSparse_spmv_bsrmatrix_tpl_spec_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@
#include <mkl.h>

namespace KokkosSparse {
brian-kelley marked this conversation as resolved.
Show resolved Hide resolved
namespace Experimental {
namespace Impl {

// MKL 2018 and above: use new interface: sparse_matrix_t and mkl_sparse_?_mv()

using KokkosSparse::Impl::mode_kk_to_mkl;

// Note: Scalar here is the Kokkos type, not the MKL type
template <typename Scalar, typename Handle>
inline void spmv_bsr_mkl(Handle* handle, sparse_operation_t op, Scalar alpha,
Expand Down Expand Up @@ -338,7 +335,6 @@ KOKKOSSPARSE_SPMV_MV_MKL(Kokkos::complex<double>, Kokkos::OpenMP,
#undef KOKKOSSPARSE_SPMV_MV_MKL

} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse

#endif // defined(KOKKOSKERNELS_ENABLE_TPL_MKL) && (__INTEL_MKL__ > 2017)
Expand All @@ -359,7 +355,6 @@ KOKKOSSPARSE_SPMV_MV_MKL(Kokkos::complex<double>, Kokkos::OpenMP,
#include "KokkosSparse_Utils_cusparse.hpp"

namespace KokkosSparse {
namespace Experimental {
namespace Impl {

template <class Handle, class AMatrix, class XVector, class YVector>
Expand Down Expand Up @@ -765,7 +760,6 @@ KOKKOSSPARSE_SPMV_MV_CUSPARSE(Kokkos::complex<float>, int, int,
#undef KOKKOSSPARSE_SPMV_MV_CUSPARSE

} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse
#endif // (9000 <= CUDA_VERSION)

Expand All @@ -781,7 +775,6 @@ KOKKOSSPARSE_SPMV_MV_CUSPARSE(Kokkos::complex<float>, int, int,
#include "KokkosSparse_Utils_rocsparse.hpp"

namespace KokkosSparse {
namespace Experimental {
namespace Impl {

template <class Handle, class AMatrix, class XVector, class YVector>
Expand Down Expand Up @@ -1101,7 +1094,6 @@ KOKKOSSPARSE_SPMV_ROCSPARSE(Kokkos::complex<double>, rocsparse_int,
#undef KOKKOSSPARSE_SPMV_ROCSPARSE

} // namespace Impl
} // namespace Experimental
} // namespace KokkosSparse

#endif // defined(KOKKOSKERNELS_ENABLE_TPL_ROCSPARSE)
Expand Down