-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add KokkosKernels::eager_initialize() to common
- Loading branch information
1 parent
d4c2511
commit 0ec7cfc
Showing
7 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
//@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 | ||
|
||
#include "KokkosKernels_EagerInitialize.hpp" | ||
#include "KokkosKernels_config.h" | ||
#include "Kokkos_Core.hpp" | ||
|
||
// Include the minimal set of headers that declare all TPL singletons | ||
#ifdef KOKKOSKERNELS_ENABLE_COMPONENT_BLAS | ||
#include "KokkosBlas_tpl_spec.hpp" //cuBLAS, rocBLAS | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_MAGMA | ||
#include "KokkosBlas_Magma_tpl.hpp" | ||
#endif | ||
#endif | ||
|
||
#ifdef KOKKOSKERNELS_ENABLE_COMPONENT_SPARSE | ||
//note: this file declares both cuSPARSE and rocSPARSE singletons | ||
#include "KokkosKernels_tpl_handles_decl.hpp" | ||
#endif | ||
|
||
#ifdef KOKKOSKERNELS_ENABLE_COMPONENT_LAPACK | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_CUSOLVER | ||
#include "KokkosLapack_cusolver.hpp" | ||
#endif | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_MAGMA | ||
#include "KokkosLapack_magma.hpp" | ||
#endif | ||
#endif | ||
|
||
namespace KokkosKernels | ||
{ | ||
void eager_initialize() | ||
{ | ||
if(!Kokkos::is_initialized()) | ||
{ | ||
throw std::runtime_error("Kokkos::intialize must be called before KokkosKernels::eager_initialize"); | ||
} | ||
#ifdef KOKKOSKERNELS_ENABLE_COMPONENT_BLAS | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_CUBLAS | ||
(void) KokkosBlas::Impl::CudaBlasSingleton::singleton(); | ||
#endif | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_ROCBLAS | ||
(void) KokkosBlas::Impl::RocBlasSingleton::singleton(); | ||
#endif | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_MAGMA | ||
#include "KokkosBlas_Magma_tpl.hpp" | ||
(void) KokkosBlas::Impl::MagmaSingleton::singleton(); | ||
#endif | ||
#endif | ||
|
||
#ifdef KOKKOSKERNELS_ENABLE_COMPONENT_SPARSE | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_CUSPARSE | ||
(void) KokkosKernels::Impl::CusparseSingleton::singleton(); | ||
#endif | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_ROCSPARSE | ||
(void) KokkosKernels::Impl::RocsparseSingleton::singleton(); | ||
#endif | ||
#endif | ||
|
||
#ifdef KOKKOSKERNELS_ENABLE_COMPONENT_LAPACK | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_CUSOLVER | ||
(void) KokkosLapack::Impl::CudaLapackSingleton::singleton(); | ||
#endif | ||
#ifdef KOKKOSKERNELS_ENABLE_TPL_MAGMA | ||
(void) KokkosLapack::Impl::MagmaSingleton::singleton(); | ||
#endif | ||
#endif | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//@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 KOKKOKERNELS_EAGER_INITIALIZE_HPP | ||
#define KOKKOKERNELS_EAGER_INITIALIZE_HPP | ||
|
||
namespace KokkosKernels | ||
{ | ||
// \brief Eagerly initialize handles for all enabled TPLs, as well | ||
// as any other globally shared resources that would otherwise be lazily initialized. | ||
// | ||
// Eagerly initializing a TPL means that it doesn't have to be | ||
// lazily initialized when first calling a kernel that uses it. | ||
// For example, \c eager_initialize() will call \c cusparseCreate() upfront | ||
// so that the first call to \c KokkosSparse::spmv doesn't have to. | ||
// This can add a significant amount of apparent runtime to that first kernel | ||
// call, even though the added time isn't really spent in the kernel. | ||
// | ||
// Calling this before using any kernels/TPLs is optional. | ||
// This function is idempotent (any calls after the first have no effect). | ||
// | ||
// \pre \c Kokkos::initialize() has been called. | ||
void eager_initialize(); | ||
} | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//@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 KK_EAGERINIT_TEST_HPP | ||
#define KK_EAGERINIT_TEST_HPP | ||
|
||
#include "KokkosKernels_EagerInitialize.hpp" | ||
|
||
TEST_F(TestCategory, common_eager_initialize) | ||
{ | ||
KokkosKernels::eager_initialize(); | ||
KokkosKernels::eager_initialize(); | ||
}; | ||
|
||
#endif |