// @HEADER // ***************************************************************************** // Tpetra: Templated Linear Algebra Services Package // // Copyright 2008 NTESS and the Tpetra contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef TPETRA_DETAILS_EXECUTIONSPACESUSER_HPP #define TPETRA_DETAILS_EXECUTIONSPACESUSER_HPP #include #include #include #include #include "Teuchos_RCP.hpp" #include "Tpetra_Details_ExecutionSpacesSlot.hpp" namespace Tpetra { namespace Details { namespace Spaces { /*! @brief A class can inherit from this if it wants to use Tpetra managed * spaces Adds a Tpetra::Details::SpaceSlot for each enabled Kokkos execution space, and provides a ::space_instance() member function that class members can call to retrieve the owned spaces, if they want to use them. */ class User { public: #ifdef KOKKOS_ENABLE_CUDA /** * @brief Returns a const smart pointer to an execution space instance. * * @tparam ExecSpace the execution space type * @tparam priority the execution space priority, default value: medium * * @return a const smart pointer to an execution space instance */ template = true> Teuchos::RCP space_instance() const { return cudaSlot.space_instance(); } /** * @brief Returns a const smart pointer to an execution space instance with a * specific priority. * * @tparam ExecSpace the execution space type * @param priority the execution space priority * * @return a const smart pointer to an execution space instance */ template = true> Teuchos::RCP space_instance(const Spaces::Priority &priority) const { return cudaSlot.space_instance(priority); } #endif // KOKKOS_ENABLE_CUDA #ifdef KOKKOS_ENABLE_SERIAL template = true> Teuchos::RCP space_instance() const { return serialSlot.space_instance(); } template = true> Teuchos::RCP space_instance(const Spaces::Priority &priority) const { return serialSlot.space_instance(priority); } #endif // KOKKOS_ENABLE_SERIAL #ifdef KOKKOS_ENABLE_OPENMP template = true> Teuchos::RCP space_instance() const { return openMPSlot.space_instance(); } template = true> Teuchos::RCP space_instance(const Spaces::Priority &priority) const { return openMPSlot.space_instance(priority); } #endif // KOKKOS_ENABLE_OPENMP #ifdef KOKKOS_ENABLE_HIP template = true> Teuchos::RCP space_instance() const { return HIPSlot.space_instance(); } template = true> Teuchos::RCP space_instance(const Spaces::Priority &priority) const { return HIPSlot.space_instance(priority); } #endif // KOKKOS_ENABLE_HIP #ifdef KOKKOS_ENABLE_SYCL template = true> Teuchos::RCP space_instance() const { return SYCLSlot.space_instance(); } template = true> Teuchos::RCP space_instance(const Spaces::Priority &priority) const { return SYCLSlot.space_instance(priority); } #endif // KOKKOS_ENABLE_SYCL #ifdef KOKKOS_ENABLE_SERIAL Slot serialSlot; #endif #ifdef KOKKOS_ENABLE_OPENMP Slot openMPSlot; #endif #ifdef KOKKOS_ENABLE_CUDA Slot cudaSlot; #endif #ifdef KOKKOS_ENABLE_HIP Slot HIPSlot; #endif #ifdef KOKKOS_ENABLE_SYCL Slot SYCLSlot; #endif }; // User } // namespace Spaces } // namespace Details } // namespace Tpetra #endif // TPETRA_DETAILS_EXECUTIONSPACESUSER_HPP