Loading...
Searching...
No Matches
KokkosWorkspace.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3#pragma once
4
5// The workspace is one shared_ptr. It is a member of BackendContext, which
6// every public model includes, so this header stays free of Kokkos headers
7// and of the GPR_LINALG_KOKKOS / GPR_KOKKOS_* macros. A consumer that omits
8// those macros has the same BackendContext layout as the library.
9
10#include <Eigen/Core>
11#include <memory>
12#include <mutex>
13
15
16namespace gpr::linalg {
17
24
38public:
39 KokkosWorkspace() = default;
40 ~KokkosWorkspace() = default;
43
45 EigenMatrix forward(const EigenMatrix& factor, const EigenMatrix& rhs);
47 EigenMatrix backward(const EigenMatrix& factor, const EigenMatrix& rhs);
49 EigenMatrix solve(const EigenMatrix& factor, const EigenMatrix& rhs);
51 Eigen::VectorXd squaredNorms(const EigenMatrix& factor,
52 const EigenMatrix& rhs);
54 EigenMatrix inverse(const EigenMatrix& factor);
55
58 void resetTransferStats();
60 void clear();
61
62private:
63 friend class KokkosFactor;
64 struct Impl;
65 Impl& ensureState() const;
66 mutable std::shared_ptr<Impl> impl_;
67 mutable std::once_flag impl_once_;
68};
69
73[[nodiscard]] bool kokkosHostExecutionMemory() noexcept;
74
75} // namespace gpr::linalg
EigenMatrix forward(const EigenMatrix &factor, const EigenMatrix &rhs)
L X = B.
EigenMatrix inverse(const EigenMatrix &factor)
(L L^T)^{-1}, formed on the device from the resident factor.
void resetTransferStats()
Zeroes the counters; the resident factor is kept.
EigenMatrix solve(const EigenMatrix &factor, const EigenMatrix &rhs)
L L^T X = B with one right-hand-side upload and one result download.
KokkosTransferStats transferStats() const
KokkosWorkspace & operator=(const KokkosWorkspace &)=delete
KokkosWorkspace(const KokkosWorkspace &)=delete
void clear()
Releases the resident factor and all device buffers; counters are kept.
Eigen::VectorXd squaredNorms(const EigenMatrix &factor, const EigenMatrix &rhs)
Squared column norms of L^{-1} B; only the norms are downloaded.
EigenMatrix backward(const EigenMatrix &factor, const EigenMatrix &rhs)
L^T X = B.
Dense and structured linear algebra behind the GP: Cholesky and eigen solvers, linear operators,...
bool kokkosHostExecutionMemory() noexcept
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Definition Macros.h:20