GPRidge v1.0.0
GPR-accelerated saddle point searches on potential energy surfaces
☾
Toggle main menu visibility
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
14
#include "
../../backend/Macros.h
"
15
16
namespace
gpr::linalg
{
17
20
struct
KokkosTransferStats
{
21
std::size_t
factor_uploads
= 0,
factor_upload_bytes
= 0,
22
rhs_upload_bytes
= 0,
result_download_bytes
= 0;
23
};
24
37
class
KokkosWorkspace
{
38
public
:
39
KokkosWorkspace
() =
default
;
40
~KokkosWorkspace
() =
default
;
41
KokkosWorkspace
(
const
KokkosWorkspace
&) =
delete
;
42
KokkosWorkspace
&
operator=
(
const
KokkosWorkspace
&) =
delete
;
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
56
KokkosTransferStats
transferStats
()
const
;
58
void
resetTransferStats
();
60
void
clear
();
61
62
private
:
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
Macros.h
gpr::linalg::KokkosWorkspace::forward
EigenMatrix forward(const EigenMatrix &factor, const EigenMatrix &rhs)
L X = B.
Definition
KokkosBackend.cpp:556
gpr::linalg::KokkosWorkspace::inverse
EigenMatrix inverse(const EigenMatrix &factor)
(L L^T)^{-1}, formed on the device from the resident factor.
Definition
KokkosBackend.cpp:612
gpr::linalg::KokkosWorkspace::resetTransferStats
void resetTransferStats()
Zeroes the counters; the resident factor is kept.
Definition
KokkosBackend.cpp:639
gpr::linalg::KokkosWorkspace::solve
EigenMatrix solve(const EigenMatrix &factor, const EigenMatrix &rhs)
L L^T X = B with one right-hand-side upload and one result download.
Definition
KokkosBackend.cpp:580
gpr::linalg::KokkosWorkspace::transferStats
KokkosTransferStats transferStats() const
Definition
KokkosBackend.cpp:632
gpr::linalg::KokkosWorkspace::operator=
KokkosWorkspace & operator=(const KokkosWorkspace &)=delete
gpr::linalg::KokkosWorkspace::KokkosWorkspace
KokkosWorkspace()=default
gpr::linalg::KokkosWorkspace::KokkosWorkspace
KokkosWorkspace(const KokkosWorkspace &)=delete
gpr::linalg::KokkosWorkspace::KokkosFactor
friend class KokkosFactor
Definition
KokkosWorkspace.h:63
gpr::linalg::KokkosWorkspace::clear
void clear()
Releases the resident factor and all device buffers; counters are kept.
Definition
KokkosBackend.cpp:646
gpr::linalg::KokkosWorkspace::squaredNorms
Eigen::VectorXd squaredNorms(const EigenMatrix &factor, const EigenMatrix &rhs)
Squared column norms of L^{-1} B; only the norms are downloaded.
Definition
KokkosBackend.cpp:593
gpr::linalg::KokkosWorkspace::backward
EigenMatrix backward(const EigenMatrix &factor, const EigenMatrix &rhs)
L^T X = B.
Definition
KokkosBackend.cpp:568
gpr::linalg::KokkosWorkspace::~KokkosWorkspace
~KokkosWorkspace()=default
gpr::linalg
Dense and structured linear algebra behind the GP: Cholesky and eigen solvers, linear operators,...
Definition
ConditionedKernel.h:14
gpr::linalg::kokkosHostExecutionMemory
bool kokkosHostExecutionMemory() noexcept
Definition
KokkosBackend.cpp:173
gpr::EigenMatrix
Eigen::Matrix< double, EigenDynamic, EigenDynamic, EigenMatrixStorage > EigenMatrix
Definition
Macros.h:20
gpr::linalg::KokkosTransferStats
Definition
KokkosWorkspace.h:20
gpr::linalg::KokkosTransferStats::rhs_upload_bytes
std::size_t rhs_upload_bytes
Definition
KokkosWorkspace.h:22
gpr::linalg::KokkosTransferStats::result_download_bytes
std::size_t result_download_bytes
Definition
KokkosWorkspace.h:22
gpr::linalg::KokkosTransferStats::factor_uploads
std::size_t factor_uploads
Definition
KokkosWorkspace.h:21
gpr::linalg::KokkosTransferStats::factor_upload_bytes
std::size_t factor_upload_bytes
Definition
KokkosWorkspace.h:21
gpr::linalg::KokkosWorkspace::Impl
Definition
KokkosBackend.cpp:433
gpr
linalg
KokkosWorkspace.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf