//@HEADER // ************************************************************************ // // Kokkos v. 4.0 // Copyright (2022) National Technology & Engineering // Solutions of Sandia, LLC (NTESS). // // Under the terms of Contract DE-NA0003525 with NTESS, // the U.S. Government retains certain rights in this software. // // Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. // See https://kokkos.org/LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //@HEADER #ifndef KOKKOSKERNELS_KOKKOSBATCHED_KERNEL_HEADER_HPP #define KOKKOSKERNELS_KOKKOSBATCHED_KERNEL_HEADER_HPP #include #include "KokkosKernels_Error.hpp" #if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) #include #endif // KOKKOSKERNELS_ENABLE_TPL_MKL #if defined(KOKKOSKERNELS_ENABLE_TPL_ARMPL) #include "armpl.h" #endif // KOKKOSKERNELS_ENABLE_TPL_ARMPL #if defined(KOKKOSKERNELS_ENABLE_TPL_CUBLAS) #include "cuda_runtime.h" #include "cublas_v2.h" #endif // KOKKOSKERNELS_ENABLE_TPL_CUBLAS #if defined(KOKKOSKERNELS_ENABLE_TPL_MAGMA) #include #include #endif // KOKKOSKERNELS_ENABLE_TPL_MAGMA namespace KokkosBatched { /// \brief Heuristic algorithm types. See BatchedKernelHandle for details. namespace BaseHeuristicAlgos { enum BASE_HEURISTIC_ALGOS : int { SQUARE = 0, TALL, WIDE, N }; } /// \brief Tpl algorithm types. See BatchedKernelHandle for details. namespace BaseTplAlgos { enum BASE_TPL_ALGOS : int { ARMPL = BaseHeuristicAlgos::N, MKL, N }; } /// \brief KokkosBatched algorithm types. See BatchedKernelHandle for details. namespace BaseKokkosBatchedAlgos { enum BASE_KOKKOS_BATCHED_ALGOS : int { KK_SERIAL = BaseTplAlgos::N, N }; } #define N_BASE_ALGOS BaseKokkosBatchedAlgos::N #define BASE_ALGO_STRS \ "BaseHeuristicAlgos::SQUARE", "BaseHeuristicAlgos::TALL", "BaseHeuristicAlgos::WIDE", "BaseTplAlgos::ARMPL", \ "BaseTplAlgosMKL", "BaseKokkosBatchedAlgos::KK_SERIAL" /// \brief TplParams abstracts underlying handle or execution queue type. struct TplParams { union { #if defined(KOKKOSKERNELS_ENABLE_TPL_MKL) // queue mkl_queue; // TODO: Add queue header? Cannot find any declarations in intel-18, let // alone oneAPI 2021 #endif // KOKKOSKERNELS_ENABLE_TPL_MKL #if defined(KOKKOSKERNELS_ENABLE_TPL_ARMPL) armpl_int_t ninter = 1; #endif // KOKKOSKERNELS_ENABLE_TPL_ARMPL #if defined(KOKKOSKERNELS_ENABLE_TPL_CUBLAS) cublasHandle_t *cublas_handle; #endif // KOKKOSKERNELS_ENABLE_TPL_CUBLAS #if defined(KOKKOSKERNELS_ENABLE_TPL_MAGMA) magma_queue_t *magma_queue; #endif // KOKKOSKERNELS_ENABLE_TPL_MAGMA uint8_t empty_union; // suppress empty union build warning }; }; // clang-format off /// \brief Handle for selecting runtime behavior of the BatchedGemm interface. /// /// \param kernelAlgoType Specifies which algorithm to use for invocation (default, SQUARE). /// /// Specifies whether to select optimal invocations based on inputs and /// heuristics: /// SQUARE select invocations based on square matrix heuristics where M=N /// TALL select invocations based on tall matrix heuristics where M>N /// WIDE select invocations based on wide matrix heuristics where M