Skip to content
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
3 changes: 2 additions & 1 deletion docs/source/API/lapack-index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ API: LAPACK
:maxdepth: 2
:hidden:

lapack/geqrf
lapack/gesv
lapack/gesvd
lapack/trtri
Expand Down Expand Up @@ -69,7 +70,7 @@ Below are tables summarizing the currently supported function calls and third pa
-
-
* - geqrf
-
- :doc:`geqrf <lapack/geqrf>`
-
-
-
Expand Down
59 changes: 59 additions & 0 deletions docs/source/API/lapack/geqrf.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
KokkosLapack::geqrf
###################

Defined in header: :code:`KokkosLapack_geqrf.hpp`

.. code:: c++

template <class ExecutionSpace, class AMatrix, class TauArray, class InfoArray>
void geqrf(const ExecutionSpace& space, const AMatrix& A, const TauArray& Tau, const InfoArray& Info);

template <class AMatrix, class TauArray, class InfoArray>
void geqrf(const AMatrix& A, const TauArray& Tau, const InfoArray& Info);

Performs the QR factorization of matrix :math:`A`

.. math::

A=Q*R

where :math:`A` is the input coefficient matrix on entry and the resulting :math:`R` factor and scaled Householder vectors on exit. :math:`Tau` stores the scaling factors associated with the Householder vectors.

1. Overwrites :math:`A` with the :math:`QR` factors using the resources of ``space``.
2. Same as 1. but uses the resources of the default execution space from ``AMatrix::execution_space``.

The function will throw a runtime exception if ``Tau.extent(0) < Kokkos::min(A.extent(0), A.extent(1))`` or if ``Info.extent(0) < 1``.

Parameters
==========

:space: execution space instance.

:A: The input matrix on entry and the :math:`QR` factors on return.

:Tau: rank-1 view of size min(M,N) that contains the scaling factors of the elementary reflectors.

:Info: rank-1 view of integers and of size 1: Info[0] = 0: successful exit; Info[0] < 0: if equal to '-i', the i-th argument had an illegal value.

Type Requirements
=================

- `ExecutionSpace` must be a Kokkos `execution space <https://kokkos.org/kokkos-core-wiki/API/core/execution_spaces.html>`_

- `AMatrix` must be a Kokkos `View <https://kokkos.org/kokkos-core-wiki/API/core/view/view.html>`_ of rank 2 that satisfies

- ``Kokkos::SpaceAccessibility<ExecutionSpace, typename AMatrix::memory_space>::accessible``

- `Tau` must be a Kokkos `View <https://kokkos.org/kokkos-core-wiki/API/core/view/view.html>`_ of rank 1 that satisfies

- ``Kokkos::SpaceAccessibility<ExecutionSpace, typename Tau::memory_space>::accessible``

- `Info` must be a Kokkos `View <https://kokkos.org/kokkos-core-wiki/API/core/view/view.html>`_ of rank 1 that satisfies

- ``Kokkos::SpaceAccessibility<ExecutionSpace, typename Info::memory_space>::accessible``

Example
=======

TBD

6 changes: 6 additions & 0 deletions lapack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ kokkoskernels_generate_eti(Lapack_svd svd
HEADER_LIST ETI_HEADERS
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright Contributors to the Kokkos project

#ifndef KOKKOSLAPACK_GEQRF_ETI_SPEC_DECL_HPP_
#define KOKKOSLAPACK_GEQRF_ETI_SPEC_DECL_HPP_
namespace KokkosLapack {
namespace Impl {
@LAPACK_GEQRF_ETI_DECL_BLOCK@
} // 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 QR factorization.

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

namespace KokkosLapack {
namespace Impl {

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

} // namespace Impl
} // namespace KokkosLapack

#endif // KOKKOSLAPACK_IMPL_GEQRF_HPP
120 changes: 120 additions & 0 deletions lapack/impl/KokkosLapack_geqrf_spec.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
//@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 <KokkosKernels_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 AMatrix, class TauArray, class InfoArray>
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 TauArray, class InfoArray,
bool tpl_spec_avail = geqrf_tpl_spec_avail<ExecutionSpace, AMatrix, TauArray, InfoArray>::value,
bool eti_spec_avail = geqrf_eti_spec_avail<ExecutionSpace, AMatrix, TauArray, InfoArray>::value>
struct GEQRF {
static void geqrf(const ExecutionSpace &space, const AMatrix &A, const TauArray &Tau, const InfoArray &info);
};

#if !defined(KOKKOSKERNELS_ETI_ONLY) || KOKKOSKERNELS_IMPL_COMPILE_LIBRARY
// Unification layer
template <class ExecutionSpace, class AMatrix, class TauArray, class InfoArray>
struct GEQRF<ExecutionSpace, AMatrix, TauArray, InfoArray, false, KOKKOSKERNELS_IMPL_COMPILE_LIBRARY> {
static void geqrf(const ExecutionSpace & /* space */, const AMatrix & /* A */, const TauArray & /* Tau */,
const InfoArray & /* Info */) {
// 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