Skip to content

Commit

Permalink
Changes to enable OneAPI usage with Trilinos build (kokkos#2185)
Browse files Browse the repository at this point in the history
- Get rid of SYCL_OVERRIDE setting
- Add MKL_PROVIDES_BLAS_LAPACK cmake variable and define so that
  code knows whether to use int, or MKL_INT
  - Trilinos builds might link with OneAPI for GPU but standard
    BLAS/LAPACK on CPU
  • Loading branch information
brian-kelley authored Apr 25, 2024
1 parent bac0b1a commit b87dc95
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 29 deletions.
3 changes: 1 addition & 2 deletions blas/tpls/KokkosBlas1_nrm1_tpl_spec_avail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ KOKKOSBLAS1_NRM1_TPL_SPEC_AVAIL_ROCBLAS(Kokkos::complex<float>,
// oneMKL
#ifdef KOKKOSKERNELS_ENABLE_TPL_MKL

#if defined(KOKKOS_ENABLE_SYCL) && \
!defined(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE)
#if defined(KOKKOS_ENABLE_SYCL)

#define KOKKOSBLAS1_NRM1_TPL_SPEC_AVAIL_MKL_SYCL(SCALAR, LAYOUT, MEMSPACE) \
template <class ExecSpace> \
Expand Down
3 changes: 1 addition & 2 deletions blas/tpls/KokkosBlas1_nrm1_tpl_spec_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ KOKKOSBLAS1_NRM1_TPL_SPEC_DECL_ROCBLAS(Kokkos::complex<double>,
// oneMKL
#ifdef KOKKOSKERNELS_ENABLE_TPL_MKL

#if defined(KOKKOS_ENABLE_SYCL) && \
!defined(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE)
#if defined(KOKKOS_ENABLE_SYCL)

#include <KokkosBlas_tpl_spec.hpp>
#include <oneapi/mkl/blas.hpp>
Expand Down
4 changes: 1 addition & 3 deletions blas/tpls/KokkosBlas1_nrm2_tpl_spec_avail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL(Kokkos::LayoutLeft, Kokkos::HIP,
Kokkos::HIPSpace)
#endif

#if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) && \
!defined(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE) && \
defined(KOKKOS_ENABLE_SYCL)
#if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) && defined(KOKKOS_ENABLE_SYCL)
KOKKOSBLAS1_NRM2_TPL_SPEC_AVAIL(Kokkos::LayoutLeft, Kokkos::Experimental::SYCL,
Kokkos::Experimental::SYCLDeviceUSMSpace)
#endif
Expand Down
4 changes: 1 addition & 3 deletions blas/tpls/KokkosBlas1_nrm2_tpl_spec_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@ KOKKOSBLAS1_NRM2_TPL_SPEC_DECL_ROCBLAS_EXT(false)

#endif

#if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) && \
!defined(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE) && \
defined(KOKKOS_ENABLE_SYCL)
#if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) && defined(KOKKOS_ENABLE_SYCL)
#include <mkl.h>
#include <oneapi/mkl/blas.hpp>
#include <KokkosBlas_tpl_spec.hpp>
Expand Down
3 changes: 1 addition & 2 deletions blas/tpls/KokkosBlas2_gemv_tpl_spec_avail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ KOKKOSBLAS2_GEMV_TPL_SPEC_AVAIL_ROCBLAS(Kokkos::complex<float>,

#ifdef KOKKOSKERNELS_ENABLE_TPL_MKL

#if defined(KOKKOS_ENABLE_SYCL) && \
!defined(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE)
#if defined(KOKKOS_ENABLE_SYCL)

#define KOKKOSBLAS2_GEMV_TPL_SPEC_AVAIL_ONEMKL(SCALAR, LAYOUT) \
template <class ExecSpace> \
Expand Down
4 changes: 1 addition & 3 deletions blas/tpls/KokkosBlas2_gemv_tpl_spec_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,7 @@ KOKKOSBLAS2_CGEMV_ROCBLAS(Kokkos::LayoutRight, Kokkos::HIPSpace, false)
#endif // KOKKOSKERNELS_ENABLE_TPL_ROCBLAS

// ONEMKL
#if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) && \
!defined(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE) && \
defined(KOKKOS_ENABLE_SYCL)
#if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) && defined(KOKKOS_ENABLE_SYCL)
#include <mkl.h>
#include <oneapi/mkl/blas.hpp>
#include <KokkosBlas_tpl_spec.hpp>
Expand Down
2 changes: 1 addition & 1 deletion blas/tpls/KokkosBlas_Host_tpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
namespace KokkosBlas {
namespace Impl {

#if defined(KOKKOSKERNELS_ENABLE_TPL_MKL)
#if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) && defined(MKL_PROVIDES_BLAS_LAPACK)
using KK_INT = MKL_INT;
#else
using KK_INT = int;
Expand Down
4 changes: 3 additions & 1 deletion cmake/KokkosKernels_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
requires (a) header file(s) as well, and may use functions other
than just BLAS and LAPACK functions. */
#cmakedefine HAVE_KOKKOSKERNELS_MKL
#cmakedefine KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE

#cmakedefine KOKKOSKERNELS_ENABLE_TESTS_AND_PERFSUITE
#cmakedefine KOKKOSKERNELS_ENABLE_BENCHMARK
Expand Down Expand Up @@ -154,6 +153,9 @@
#endif
#endif

/* Whether MKL is providing the BLAS and LAPACK implementation */
#cmakedefine MKL_PROVIDES_BLAS_LAPACK

#if !defined(KOKKOS_ENABLE_CUDA) && !defined(KOKKOS_ENABLE_HIP) && \
!defined(KOKKOS_ENABLE_SYCL) && !defined(KOKKOS_ENABLE_OPENMPTARGET)
#define KOKKOSKERNELS_ENABLE_HOST_ONLY
Expand Down
1 change: 0 additions & 1 deletion cmake/Modules/FindTPLBLAS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ ELSE()
FIND_PACKAGE(BLAS REQUIRED)
KOKKOSKERNELS_CREATE_IMPORTED_TPL(BLAS INTERFACE LINK_LIBRARIES ${BLAS_LIBRARIES})
ENDIF()

1 change: 0 additions & 1 deletion cmake/Modules/FindTPLLAPACK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ ELSE()
FIND_PACKAGE(LAPACK REQUIRED)
KOKKOSKERNELS_CREATE_IMPORTED_TPL(LAPACK INTERFACE LINK_LIBRARIES ${LAPACK_LIBRARIES})
ENDIF()

4 changes: 4 additions & 0 deletions cmake/Modules/FindTPLMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ ELSE()
)
ENDIF()
ENDIF()
# This logic to find MKL is only used in non-Trilinos builds.
# In this case, MKL can always be used as the host BLAS/LAPACK implementation
# (whether MKL_INT is 32- or 64-bit).
set (MKL_PROVIDES_BLAS_LAPACK ON INTERNAL)
4 changes: 0 additions & 4 deletions cmake/kokkoskernels_tpls.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ MACRO(KOKKOSKERNELS_ADD_TPL_OPTION NAME DEFAULT_VALUE DOCSTRING)
SET(ROOT_DEFAULT $ENV{${_NAME_ORIG}_ROOT})
KOKKOSKERNELS_ADD_OPTION(${_NAME_ORIG}_ROOT "${ROOT_DEFAULT}" PATH "Location of ${_NAME} install root. Default: None or the value of the environment variable ${_NAME}_ROOT if set")
IF (DEFINED TPL_ENABLE_${_NAME})
IF (${_NAME} STREQUAL MKL AND KOKKOSKERNELS_HAS_TRILINOS)
MESSAGE("Trilinos has enabled MKL and SYCL but it does not detect oneMKL correctly so we disable it!")
SET(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE ON)
ENDIF ()
IF (TPL_ENABLE_${_NAME} AND NOT KOKKOSKERNELS_ENABLE_TPL_${_NAME})
MESSAGE("Overriding KOKKOSKERNELS_ENABLE_TPL_${_NAME_ORIG}=OFF with TPL_ENABLE_${_NAME}=ON")
SET(KOKKOSKERNELS_ENABLE_TPL_${_NAME_ORIG} ON)
Expand Down
3 changes: 1 addition & 2 deletions sparse/src/KokkosSparse_spmv_handle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ struct MKL_SpMV_Data : public TPL_SpMV_Data<ExecutionSpace> {
};
#endif

#if defined(KOKKOS_ENABLE_SYCL) && \
!defined(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE)
#if defined(KOKKOS_ENABLE_SYCL)
struct OneMKL_SpMV_Data : public TPL_SpMV_Data<Kokkos::Experimental::SYCL> {
OneMKL_SpMV_Data(const Kokkos::Experimental::SYCL& exec_)
: TPL_SpMV_Data(exec_) {}
Expand Down
3 changes: 1 addition & 2 deletions sparse/tpls/KokkosSparse_spmv_tpl_spec_avail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ KOKKOSSPARSE_SPMV_TPL_SPEC_AVAIL_MKL(Kokkos::complex<float>, Kokkos::OpenMP)
KOKKOSSPARSE_SPMV_TPL_SPEC_AVAIL_MKL(Kokkos::complex<double>, Kokkos::OpenMP)
#endif

#if defined(KOKKOS_ENABLE_SYCL) && \
!defined(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE)
#if defined(KOKKOS_ENABLE_SYCL)
#define KOKKOSSPARSE_SPMV_TPL_SPEC_AVAIL_ONEMKL(SCALAR, ORDINAL, MEMSPACE) \
template <> \
struct spmv_tpl_spec_avail< \
Expand Down
3 changes: 1 addition & 2 deletions sparse/tpls/KokkosSparse_spmv_tpl_spec_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,7 @@ KOKKOSSPARSE_SPMV_MKL(Kokkos::complex<double>, Kokkos::OpenMP)
#undef KOKKOSSPARSE_SPMV_MKL
#endif

#if defined(KOKKOS_ENABLE_SYCL) && \
!defined(KOKKOSKERNELS_ENABLE_TPL_MKL_SYCL_OVERRIDE)
#if defined(KOKKOS_ENABLE_SYCL)
inline oneapi::mkl::transpose mode_kk_to_onemkl(char mode_kk) {
switch (toupper(mode_kk)) {
case 'N': return oneapi::mkl::transpose::nontrans;
Expand Down

0 comments on commit b87dc95

Please sign in to comment.