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

Interface for LAPACK geqrf() #2205

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions lapack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,10 @@ KOKKOSKERNELS_GENERATE_ETI(Lapack_svd svd
SOURCE_LIST SOURCES
TYPE_LISTS FLOATS LAYOUTS DEVICES
)

KOKKOSKERNELS_GENERATE_ETI(Lapack_geqrf geqrf
COMPONENTS lapack
HEADER_LIST ETI_HEADERS
SOURCE_LIST SOURCES
TYPE_LISTS FLOATS LAYOUTS DEVICES
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//@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

#define KOKKOSKERNELS_IMPL_COMPILE_LIBRARY true
#include "KokkosKernels_config.h"
#include "KokkosLapack_geqrf_spec.hpp"

namespace KokkosLapack {
namespace Impl {
@LAPACK_GEQRF_ETI_INST_BLOCK@
} // namespace Impl
} // namespace KokkosLapack
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@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 KOKKOSLAPACK_GEQRF_ETI_SPEC_AVAIL_HPP_
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_AVAIL_HPP_
namespace KokkosLapack {
namespace Impl {
@LAPACK_GEQRF_ETI_AVAIL_BLOCK@
} // namespace Impl
} // namespace KokkosLapack
#endif
34 changes: 34 additions & 0 deletions lapack/impl/KokkosLapack_geqrf_impl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//@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 KOKKOSLAPACK_IMPL_GEQRF_HPP_
#define KOKKOSLAPACK_IMPL_GEQRF_HPP_

/// \file KokkosLapack_geqrf_impl.hpp
/// \brief Implementation(s) of dense linear solve.

#include <KokkosKernels_config.h>
#include <Kokkos_ArithTraits.hpp>

namespace KokkosLapack {
namespace Impl {

// NOTE: Might add the implementation of KokkosLapack::geqrf later

} // namespace Impl
} // namespace KokkosLapack

#endif // KOKKOSLAPACK_IMPL_GEQRF_HPP
139 changes: 139 additions & 0 deletions lapack/impl/KokkosLapack_geqrf_spec.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//@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 KOKKOSLAPACK_IMPL_GEQRF_SPEC_HPP_
#define KOKKOSLAPACK_IMPL_GEQRF_SPEC_HPP_

#include <KokkosKernels_config.h>
#include <Kokkos_Core.hpp>
#include <Kokkos_ArithTraits.hpp>

// Include the actual functors
#if !defined(KOKKOSKERNELS_ETI_ONLY) || KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
#include <KokkosLapack_geqrf_impl.hpp>
#endif

namespace KokkosLapack {
namespace Impl {
// Specialization struct which defines whether a specialization exists
template <class ExecutionSpace, class AVT, class TWVT, class RT>
struct geqrf_eti_spec_avail {
enum : bool { value = false };
};
} // namespace Impl
} // namespace KokkosLapack

//
// Macro for declaration of full specialization availability
// KokkosLapack::Impl::GEQRF. This is NOT for users!!! All
// the declarations of full specializations go in this header file.
// We may spread out definitions (see _INST macro below) across one or
// more .cpp files.
//
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_AVAIL(SCALAR_TYPE, LAYOUT_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE) \
template <> \
struct geqrf_eti_spec_avail< \
EXEC_SPACE_TYPE, \
Kokkos::View<SCALAR_TYPE **, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<int *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>> { \
enum : bool { value = true }; \
};

// Include the actual specialization declarations
#include <KokkosLapack_geqrf_tpl_spec_avail.hpp>
#include <generated_specializations_hpp/KokkosLapack_geqrf_eti_spec_avail.hpp>

namespace KokkosLapack {
namespace Impl {

// Unification layer
template <
class ExecutionSpace, class AMatrix, class TWArray, class RType,
bool tpl_spec_avail =
geqrf_tpl_spec_avail<ExecutionSpace, AMatrix, TWArray, RType>::value,
bool eti_spec_avail =
geqrf_eti_spec_avail<ExecutionSpace, AMatrix, TWArray, RType>::value>
struct GEQRF {
static void geqrf(const ExecutionSpace &space, const AMatrix &A,
const TWArray &Tau, const TWArray &Work, const RType &R);
};

#if !defined(KOKKOSKERNELS_ETI_ONLY) || KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
// Unification layer
template <class ExecutionSpace, class AMatrix, class TWArray, class RType>
struct GEQRF<ExecutionSpace, AMatrix, TWArray, RType, false,
KOKKOSKERNELS_IMPL_COMPILE_LIBRARY> {
static void geqrf(const ExecutionSpace & /* space */, const AMatrix & /* A */,
const TWArray & /* Tau */, const TWArray & /* Work */,
const RType & /* R */) {
// NOTE: Might add the implementation of KokkosLapack::geqrf later
throw std::runtime_error(
"No fallback implementation of GEQRF (general QR factorization) "
"exists. Enable LAPACK, CUSOLVER, ROCSOLVER or MAGMA TPL.");
}
};

#endif
} // namespace Impl
} // namespace KokkosLapack

//
// Macro for declaration of full specialization of
// KokkosLapack::Impl::GEQRF. This is NOT for users!!! All
// the declarations of full specializations go in this header file.
// We may spread out definitions (see _DEF macro below) across one or
// more .cpp files.
//
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_DECL(SCALAR_TYPE, LAYOUT_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE) \
extern template struct GEQRF< \
EXEC_SPACE_TYPE, \
Kokkos::View<SCALAR_TYPE **, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<int *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
false, true>;

#define KOKKOSLAPACK_GEQRF_ETI_SPEC_INST(SCALAR_TYPE, LAYOUT_TYPE, \
EXEC_SPACE_TYPE, MEM_SPACE_TYPE) \
template struct GEQRF< \
EXEC_SPACE_TYPE, \
Kokkos::View<SCALAR_TYPE **, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<SCALAR_TYPE *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
Kokkos::View<int *, LAYOUT_TYPE, \
Kokkos::Device<EXEC_SPACE_TYPE, MEM_SPACE_TYPE>, \
Kokkos::MemoryTraits<Kokkos::Unmanaged>>, \
false, true>;

#include <KokkosLapack_geqrf_tpl_spec_decl.hpp>

#endif // KOKKOSLAPACK_IMPL_GEQRF_SPEC_HPP_
Loading
Loading