namespace gpr::linalg¶
Overview¶
Dense and structured linear algebra behind the GP: Cholesky and eigen solvers, linear operators, backend selection. More…
namespace linalg {
// namespaces
namespace gpr::linalg::backend;
namespace gpr::linalg::canonical;
namespace gpr::linalg::cutlass;
namespace gpr::linalg::fixed;
namespace gpr::linalg::kokkos_joint;
namespace gpr::linalg::linop;
namespace gpr::linalg::portable_tiles;
namespace gpr::linalg::schemeii;
// typedefs
typedef backend::EigenTag ActiveBackend;
typedef BackendTraits<ActiveBackend> ActiveBackendTraits;
typedef std::optional<std::int64_t> AvailableMemory;
typedef int MpiCommType;
typedef DistributedState ScalapackState;
typedef Eigen::Ref<const Eigen::MatrixXd, 0, Eigen::OuterStride<>> ConstProductMatrix;
typedef Eigen::Ref<Eigen::MatrixXd, 0, Eigen::OuterStride<>> ProductMatrix;
// enums
enum ArithmeticClass;
enum DistributedBackendKind;
enum DistributedFactorization;
enum ExecutionKind;
enum Lp64DescriptorField;
enum MemoryKind;
enum ProductMode;
// structs
template <class Backend>
struct BackendTraits;
template <>
struct BackendTraits<backend::ScalapackTag>;
template <>
struct BackendTraits<backend::StdParTag>;
template <>
struct BackendTraits<backend::KokkosTag>;
template <>
struct BackendTraits<backend::SlateTag>;
template <>
struct BackendTraits<backend::CusolverTag>;
template <>
struct BackendTraits<backend::EigenTag>;
template <>
struct BackendTraits<backend::CholmodTag>;
struct CompensatedSum;
struct ConstTileView;
struct DistributedShape;
struct ExactProductAccumulator;
struct KokkosMolecularStats;
struct KokkosTransferAuditStats;
struct KokkosTransferDirectionStats;
struct KokkosTransferStats;
struct MpiContext;
struct PCGResult;
struct PCGSettings;
struct ProviderTraits;
struct RayleighRitzOptions;
struct RayleighRitzResult;
struct SchemeIIIntegers;
struct SchemeIIWide;
struct SchemeISlices;
struct StoredProduct;
struct ThreadBudget;
struct TileView;
// classes
class BackendContext;
class CholeskyPanels;
class CovarianceEquilibration;
class CusolverEighLib;
class CusolverInverse;
class DenseLLTInverse;
class DistributedKernelProvider;
class DistributedState;
class EnvironmentGpuExecutor;
class ExactSum;
class KernelInverse;
class KernelWall;
class KokkosFactor;
class KokkosMolecularPosterior;
class KokkosWorkspace;
class LocalExecutor;
class MpiCommunicator;
class PredictProduct;
class ProbeExecutor;
class ScalapackLib;
class ScopedLp64IndexLimit;
class ScopedSerialEigenThreads;
class ScopedSolveThreads;
class ScopedTileKernelThreads;
class StableVarianceError;
class TileBackground;
class TileCholesky;
class TilePool;
class TwoStageEigenLib;
// global variables
const char* kPredictSumOption = “–predict-sum<compensated|scheme1|scheme2|kernel_float>”;
const char* kPredictSumHelp = “Predict product. compensated sums each TwoProductFMA expansion and “ “rounds once, and is the default. scheme1 is Ozaki Scheme I, scheme2 is “ “Ozaki Scheme II, and kernel_float is the Scheme II product formed with “ “kernel_float vectors.”;
std::atomic_bool stable_posterior_variance {false};
int kStablePosteriorVarianceRoundoffUlps = 4;
std::int64_t kLp64IndexLimit = std::numeric_limits<std::int32_t>::max();
MpiCommType kMpiCommNull = 0;
int kSchemeIIModulusCount = 8;
int kSchemeIIMaxShift = 120;
Eigen::Index kMinDistributedGemmOrder = 512;
Eigen::Index kMinDistributedSymmetricEigenOrder = 1;
// global functions
bool arrowheadEigenRankOne(const Eigen::VectorXd& d, const Eigen::VectorXd& z, double alpha, Eigen::VectorXd& evals_asc, Eigen::MatrixXd& evecs);
bool arrowheadEigen(const Eigen::VectorXd& d, const Eigen::MatrixXd& B, const Eigen::MatrixXd& A, Eigen::VectorXd& evals_asc, Eigen::MatrixXd& evecs);
bool cholesky(const EigenMatrix& C, EigenMatrix& L);
Eigen::VectorXd forward_solve(const EigenMatrix& L, const Eigen::VectorXd& b);
Eigen::VectorXd back_solve(const EigenMatrix& L, const Eigen::VectorXd& b);
EigenMatrix forward_solve_mat(const EigenMatrix& L, const EigenMatrix& B);
EigenMatrix back_solve_mat(const EigenMatrix& L, const EigenMatrix& B);
Eigen::VectorXd forward_solve_mat_colwise_squared_norm(const EigenMatrix& L, const EigenMatrix& B);
Eigen::VectorXd bordered_cholesky_diagonal(const EigenMatrix& L, const EigenMatrix& B, const Eigen::VectorXd& prior);
EigenMatrix cholesky_inverse(const EigenMatrix& L);
double trace_product(const EigenMatrix& A, const EigenMatrix& B);
double log_det_cholesky(const EigenMatrix& L);
bool hostAccessible(MemoryKind kind);
const char* memoryKindName(MemoryKind kind);
const char* executionKindName(ExecutionKind kind);
const char* arithmeticClassName(ArithmeticClass cls);
bool satisfies(ArithmeticClass provided, ArithmeticClass required);
double symmetricBackwardError(Eigen::Index n, double scale);
bool curvatureIsNegative(double lambda, double scale, Eigen::Index n);
void canonicalizeEigenvectorSign(Eigen::Ref<Eigen::VectorXd> vector, double tolerance);
bool signedEigenvectorLess(const Eigen::Ref<const Eigen::VectorXd>& left, const Eigen::Ref<const Eigen::VectorXd>& right);
void canonicalizeEigenpairs(Eigen::Ref<Eigen::VectorXd> evals, Eigen::Ref<Eigen::MatrixXd> evecs);
Eigen::Index resolvedSingularRank(const Eigen::VectorXd& singular, double cutoff);
double twoSumResidual(double a, double b, double rounded);
bool tryCertifiedProduct(const double* left, const double* right, int length, double& result);
bool rank_one_update_lower(EigenMatrix& lower, const Eigen::VectorXd& vector);
bool cholesky_rank_update(EigenMatrix& lower, const Eigen::VectorXd& vector);
template <class Matrices, class Body>
void assembleCollectively(const MpiContext& context, Matrices& result, const Body& body);
ProductMode productMode();
bool kernelFloatProductAvailable();
bool selectPredictProduct(const char* value);
double evaluateStoredProduct(const double* left, const double* right, int length, ProductMode mode);
void contractPredictionMatrix(const double* column_major, int rows, int cols, const double* coefficients, double* output, ProductMode mode);
void evaluateStoredProducts(const StoredProduct* products, int count, ProductMode mode, double* values);
double trace_solve_product(const EigenMatrix& L, const EigenMatrix& A);
double dense_factor_inverse_trace(const EigenMatrix& L);
DistributedBackendKind compiled_distributed_backend();
const char* distributed_backend_name(DistributedBackendKind backend);
void configureEnvironmentGpu(const std::string& library);
std::shared_ptr<const EnvironmentGpuExecutor> configuredEnvironmentGpu();
void configureStablePosteriorVariance(bool enabled);
bool stablePosteriorVarianceEnabled();
bool acceptStablePosteriorVariance(double& variance, double signal_variance, double relative_allowance);
bool acceptStablePosteriorVariance(double& variance, double signal_variance);
bool acceptStablePosteriorVariance(Eigen::VectorXd& variance, const Eigen::VectorXd& signal);
void requireStablePosteriorVariance(double& variance, double signal_variance, double relative_allowance);
void requireStablePosteriorVariance(double& variance, double signal_variance);
void requireStablePosteriorVariance(Eigen::VectorXd& variance, const Eigen::VectorXd& signal);
template <typename RelativeError>
void requireStableSchurDiagonal(Eigen::VectorXd& variance, const Eigen::VectorXd& signal, RelativeError&& relative_error);
template <typename Solve, typename SolveTranspose>
double estimateLowerInverseNorm1(Eigen::Index order, Solve&& solve, SolveTranspose&& solve_transpose);
double choleskySchurRelativeError(Eigen::Index order, double factor_frobenius_norm, double inverse_norm1);
double upperInverseNorm1FromComputed(double computed_norm, Eigen::Index order);
double upperInverseNorm1FromResidual(double computed_norm, double residual_norm, double factor_abs_norm, Eigen::Index order);
template <typename Derived>
double upperInverseNorm1(const Eigen::MatrixBase<Derived>& factor);
template <typename Derived>
double denseCholeskySchurRelativeError(const Eigen::MatrixBase<Derived>& factor);
template <typename Backend, typename Derived>
double subsetFactorSchurRelativeError(Backend& backend, const Eigen::MatrixBase<Derived>& factor, int order);
template <typename Derived, typename RelativeError>
Eigen::VectorXd borderedCholeskyDiagonalWith(const Eigen::VectorXd& prior, const Eigen::MatrixBase<Derived>& whitened, RelativeError&& relative_error);
template <typename Derived>
Eigen::VectorXd borderedCholeskyDiagonal(const Eigen::VectorXd& prior, const Eigen::MatrixBase<Derived>& whitened);
template <typename Derived, typename FactorDerived>
Eigen::VectorXd borderedCholeskyDiagonal(const Eigen::VectorXd& prior, const Eigen::MatrixBase<Derived>& whitened, const Eigen::MatrixBase<FactorDerived>& factor);
template <typename PriorDerived, typename WeightDerived, typename SolvedDerived, typename RelativeError>
double borderedCholeskyActionVarianceWith(const Eigen::MatrixBase<PriorDerived>& prior, const Eigen::MatrixBase<WeightDerived>& weights, const Eigen::MatrixBase<SolvedDerived>& whitened_action, RelativeError&& relative_error);
template <typename PriorDerived, typename WeightDerived, typename SolvedDerived>
double borderedCholeskyActionVariance(const Eigen::MatrixBase<PriorDerived>& prior, const Eigen::MatrixBase<WeightDerived>& weights, const Eigen::MatrixBase<SolvedDerived>& whitened_action);
template <typename PriorDerived, typename WeightDerived, typename SolvedDerived, typename FactorDerived>
double borderedCholeskyActionVariance(const Eigen::MatrixBase<PriorDerived>& prior, const Eigen::MatrixBase<WeightDerived>& weights, const Eigen::MatrixBase<SolvedDerived>& whitened_action, const Eigen::MatrixBase<FactorDerived>& factor);
double pcg_dot(const Eigen::VectorXd& a, const Eigen::VectorXd& b);
PCGResult preconditioned_cg(const std::function<Eigen::VectorXd(const Eigen::VectorXd&)>& apply_A, const std::function<Eigen::VectorXd(const Eigen::VectorXd&)>& apply_M_inv, const Eigen::VectorXd& b, const PCGSettings& settings = {});
void resetKokkosTransferAuditStats();
KokkosTransferAuditStats kokkosTransferAuditStats();
bool kokkosHostExecutionMemory();
DistributedFactorization distributedFactorization();
std::uint64_t distributedFactorizationGeneration();
void configureDistributedFactorization(DistributedFactorization mode);
const char* distributedFactorizationName(DistributedFactorization mode);
std::optional<DistributedFactorization> parseDistributedFactorization(std::string_view name);
int configuredLinalgThreads();
void configureLinalgThreads(int threads);
void configureProductThreads(int threads);
void configureLibrarySerialKernels(bool enabled);
bool librarySerialKernels();
void configureUnconstrainedLibraryReductions(bool enabled);
bool unconstrainedLibraryReductions();
void configureTileThreads(int threads);
int affinityCpuCount();
int blasThreadCount();
bool teamPanelKernels();
void configureKernelThreads(int threads);
void refreshKernelTeam();
std::int64_t blockCyclicLocalExtent(std::int64_t n, std::int64_t nb, std::int64_t iproc, std::int64_t isrc, std::int64_t nprocs);
std::int64_t largestLocalEntries(std::int64_t m, std::int64_t n, std::int64_t mb, std::int64_t nb, std::int64_t rsrc, std::int64_t csrc, std::int64_t nprow, std::int64_t npcol);
std::int64_t largestLocalEntries(const int* desc, int nprow, int npcol);
std::atomic<std::int64_t>& lp64IndexLimitStore();
std::int64_t lp64IndexLimit();
bool exceedsLp64(const int* desc, int nprow, int npcol);
bool exceedsLp64(std::int64_t count);
AvailableMemory availableHostBudget();
std::int64_t availableHostBytes();
bool fitsRankShare(std::int64_t needed, AvailableMemory available, int node_ranks);
bool fitsRankShare(std::int64_t needed, std::int64_t available, int node_ranks);
void requireRankShare(const char* what, std::int64_t needed, AvailableMemory available, int node_ranks);
void requireRankShare(const char* what, std::int64_t needed, std::int64_t available, int node_ranks);
void replicate_owned_values(double* data, std::size_t count, const MpiContext& context);
void disjoint_sum_bcast(double* data, int count, const MpiContext& context);
void ordered_sum_bcast(double* data, int count, const MpiContext& context);
void compensated_sum_bcast(CompensatedSum* data, int count, const MpiContext& context);
void exact_sum_bcast(ExactSum* sums, int count, const MpiContext& context);
int schemeISliceBits(Eigen::Index length);
SchemeISlices splitSchemeI(const Eigen::Ref<const Eigen::VectorXd>& values);
double accumulateSchemeI(const SchemeISlices& left, const SchemeISlices& right);
double scheme_i_trunc(double value);
int scheme_i_slice_bits(int length);
int scheme_i_split(const double* values, int length, int bits, double* slices, int cap);
int scheme_i_slice_cap(const double* values, int length, int bits);
double schemeIProductRaw(const double* left, const double* right, int length);
template <typename Left, typename Right>
double schemeIProduct(const Eigen::MatrixBase<Left>& left, const Eigen::MatrixBase<Right>& right);
uint32_t schemeIIModulus(int index);
const uint32_t* schemeIIModuli();
bool scaleSchemeII(const double* left, const double* right, int length, SchemeIIIntegers* scaled);
uint32_t modularProductSchemeII(const SchemeIIIntegers& scaled, uint32_t modulus);
bool takeSchemeIIWindow(const SchemeIIIntegers& scaled, char* consumed, SchemeIIIntegers* window);
SchemeIIWide crtSchemeII(const uint32_t* residues);
double unscaleSchemeII(const SchemeIIWide& coefficient, int exponent);
double schemeIIProductRaw(const double* left, const double* right, int length);
bool jacobiDavidsonCorrection(const Eigen::MatrixXd& A, const double theta, const Eigen::VectorXd& residual, const Eigen::VectorXd& ritz_vector, Eigen::VectorXd& correction, double* alpha = nullptr);
template <class Apply>
RayleighRitzResult lowestEigenpairRayleighRitz(const Eigen::Index dimension, Apply&& apply, const Eigen::VectorXd& seed, RayleighRitzOptions options);
void requireRebuildableDenseL(const EigenMatrix& L, int m, const char* fn, DistributedState& st = DistributedState::instance());
void ordered_sum_bcast(double* data, int count, DistributedState& st = DistributedState::instance());
void exact_sum_bcast(ExactSum* sums, int count, DistributedState& st = DistributedState::instance());
void disjoint_sum_bcast(double* data, int count, DistributedState& st = DistributedState::instance());
bool distributed_gemm_nn(const EigenMatrix& A, const EigenMatrix& B, EigenMatrix& C, DistributedState& st = DistributedState::instance());
int lp64Workspace(double query, const char* routine, const DistributedState& st);
void cached_trsm_left_lower(int m, int ncols, double* b_buf, const int* desc_b, bool transpose, const char* fn, DistributedState& st = DistributedState::instance());
void transformDistributedLower(std::vector<double>& buffer, const int* desc, int n, const CovarianceEquilibration& scaling, bool restore_factor, DistributedState& st);
bool equilibrateDistributedLower(std::vector<double>& buffer, const int* desc, int n, CovarianceEquilibration& scaling, DistributedState& st);
bool cholesky(const EigenMatrix& C, EigenMatrix& L, DistributedState& st = DistributedState::instance());
bool cholesky_distributed(std::vector<double> C_dist, const int* desc, int n, EigenMatrix& L, DistributedState& st = DistributedState::instance());
EigenMatrix forward_solve_mat(const EigenMatrix& L, const EigenMatrix& B, DistributedState& st = DistributedState::instance());
bool distributed_thin_svd(const EigenMatrix& A, EigenMatrix& U, Eigen::VectorXd& S, EigenMatrix& V, DistributedState& st = DistributedState::instance());
bool distributed_symmetric_eigen(const EigenMatrix& A, Eigen::VectorXd& eigenvalues, EigenMatrix& eigenvectors, const char** driver_name = nullptr, DistributedState& st = DistributedState::instance());
bool distributed_thin_svd_colblock(const EigenMatrix& A_local, int m, int n, EigenMatrix& U, Eigen::VectorXd& S, EigenMatrix& V, DistributedState& st = DistributedState::instance());
bool distributed_thin_svd_tsqr(const EigenMatrix& A_local, int nobs, int N, EigenMatrix& U, Eigen::VectorXd& S, EigenMatrix& V, DistributedState& st = DistributedState::instance());
EigenMatrix back_solve_mat(const EigenMatrix& L, const EigenMatrix& B, DistributedState& st = DistributedState::instance());
Eigen::VectorXd columnSquaredNormsExact(const std::vector<double>& buf, const int* desc, int m, int ncols, DistributedState& st);
Eigen::VectorXd columnSchurComplementsExact(const std::vector<double>& buf, const int* desc, int m, int ncols, const Eigen::VectorXd& prior, DistributedState& st);
Eigen::VectorXd forward_solve_mat_colwise_squared_norm(const EigenMatrix& L, const EigenMatrix& B, DistributedState& st = DistributedState::instance());
double cachedFactorSchurRelativeError(int m, DistributedState& st = DistributedState::instance());
void requireCachedFactorSchurDiagonal(Eigen::VectorXd& diagonal, const Eigen::VectorXd& prior, int m, DistributedState& st);
Eigen::VectorXd bordered_cholesky_diagonal(const EigenMatrix& L, const EigenMatrix& B, const Eigen::VectorXd& prior, DistributedState& st = DistributedState::instance());
EigenMatrix forward_solve_mat_bilinear_distributed(const EigenMatrix& L, std::vector<double> b_buf, const int* desc_b, int m, int ncols, DistributedState& st = DistributedState::instance(), const Eigen::VectorXd* prior = nullptr, Eigen::VectorXd* posterior_diagonal = nullptr);
Eigen::VectorXd forward_solve_mat_colwise_squared_norm_distributed(const EigenMatrix& L, std::vector<double> b_buf, const int* desc_b, int m, int ncols, DistributedState& st = DistributedState::instance());
Eigen::VectorXd bordered_cholesky_diagonal_distributed(const EigenMatrix& L, std::vector<double> b_buf, const int* desc_b, int m, int ncols, const Eigen::VectorXd& prior, DistributedState& st = DistributedState::instance());
Eigen::VectorXd cholesky_inverse_diagonal_distributed(const EigenMatrix& L, int order, DistributedState& st = DistributedState::instance());
Eigen::VectorXd forward_solve(const EigenMatrix& L, const Eigen::VectorXd& b, DistributedState& st = DistributedState::instance());
Eigen::VectorXd back_solve(const EigenMatrix& L, const Eigen::VectorXd& b, DistributedState& st = DistributedState::instance());
double trace_cholesky_solve_scalapack(const EigenMatrix& L, const EigenMatrix& B, DistributedState& st = DistributedState::instance());
ExactSum trace_cholesky_solve_scalapack_distributed_local(const EigenMatrix& L, const double* B_dist, const int* desc_b, int m, int ncols, DistributedState& st = DistributedState::instance());
double trace_cholesky_solve_scalapack_distributed(const EigenMatrix& L, const double* B_dist, const int* desc_b, int m, int ncols, DistributedState& st = DistributedState::instance());
bool factor_inverse_lower(const EigenMatrix& L, int n, std::vector<double>& inverse, int* desc, DistributedState& st);
template <class Entry>
ExactSum trace_lower_symmetric_local(const double* A, int lda, int n, Entry&& b, DistributedState& st);
double trace_inverse_times_symmetric(const EigenMatrix& L, const EigenMatrix* B, int n, DistributedState& st = DistributedState::instance());
EigenMatrix cholesky_inverse(const EigenMatrix& L, DistributedState& st = DistributedState::instance());
void cache_cholesky_inverse(const EigenMatrix& L, DistributedState& st = DistributedState::instance());
double observation_tile_lower_trace_colmajor_unchecked(const double* lower_colmajor, int leading_dim, int n, const EigenMatrix& block, int row_component, int col_component, int tile_size, bool transpose_block = false);
double cached_inverse_observation_tile_trace_np1(const EigenMatrix& block, int row_component, int col_component, int tile_size, bool transpose_block = false, DistributedState& st = DistributedState::instance());
double trace_cached_inverse_times_symmetric_distributed(const double* B_dist, const int* desc_b, int n, DistributedState& st = DistributedState::instance());
EigenMatrix cholesky_inverse_root(const EigenMatrix& L, DistributedState& st = DistributedState::instance());
double trace_product(const EigenMatrix& A, const EigenMatrix& B, DistributedState& st = DistributedState::instance());
double log_det_cholesky(const EigenMatrix& L, DistributedState& st = DistributedState::instance());
bool teamDivideConquerEigen(const Eigen::MatrixXd& sym, Eigen::VectorXd& evals, Eigen::MatrixXd& evecs);
bool covarianceDsyevr(const Eigen::MatrixXd& sym, Eigen::VectorXd& evals, Eigen::MatrixXd& evecs);
std::int64_t teamPanelWidth();
bool teamPanelBitsIndependent();
double teamSolveWallSeconds();
void teamSolveWallReset();
void teamAddSolveWall(double seconds);
double teamFactorWallSeconds();
void teamFactorWallReset();
bool teamParallelPays(double flops);
bool teamCholeskyLower(double* lower, std::int64_t lda, std::int64_t n);
void teamSolveLower(const double* lower, std::int64_t lda, bool lower_factor, double* rhs, std::int64_t ldb, std::int64_t n, std::int64_t cols);
void teamSolveLowerVector(const double* lower, std::int64_t lda, bool lower_factor, double* rhs, std::int64_t n);
void teamSymmetricGram(const double* b, std::int64_t ldb, double* c, std::int64_t ldc, std::int64_t n);
bool teamCholeskyLower(Eigen::Ref<Eigen::MatrixXd> lower);
void teamSolveLower(const Eigen::Ref<const Eigen::MatrixXd>& lower, bool lower_factor, Eigen::Ref<Eigen::MatrixXd> rhs);
void teamSolveLowerVector(const Eigen::Ref<const Eigen::MatrixXd>& lower, bool lower_factor, Eigen::Ref<Eigen::VectorXd> rhs);
std::atomic<int>& tileThreadCount();
void setTileThreads(int threads);
template <class F>
void parallelFor(long count, F&& fn);
bool trainingCholeskySelected(Eigen::Index order);
bool trainingCholeskyDistributedSelected(Eigen::Index order);
bool trainingCholeskyLower(ProductMatrix lower);
std::shared_ptr<const schemeii::Context> schemeIIContext();
void configureTrainingProductLibrary(const std::string& library);
bool trainingProductConfigured();
bool trainingProductLibraryLoaded();
bool tryTrainingProduct(ConstProductMatrix a, ConstProductMatrix b, ProductMatrix c, bool transpose_a = false, bool transpose_b = false, double alpha = 1.0, double beta = 0.0, bool partitioned = false);
Eigen::MatrixXd trainingProduct(ConstProductMatrix a, ConstProductMatrix b, bool transpose_a, bool transpose_b);
} // namespace linalg
Detailed Documentation¶
Dense and structured linear algebra behind the GP: Cholesky and eigen solvers, linear operators, backend selection.
Two-stage symmetric eigensolver: full -> banded -> eigenpairs.
One-stage reduction (LAPACK dsytrd, reached through dsyevr) spends its time in dsymv, a matrix-VECTOR product. That is bandwidth-bound, and a live profile of a Baker cell put dsymv at 56% of the run once MPI wait was removed. The two-stage form exists to replace it: reducing to a BAND first can be done with matrix-MATRIX products, which are not bandwidth-bound.
Only stage one is written here. LAPACK already ships the rest and, unlike its *_2stage drivers, dsbevd supports JOBZ=’V’, so the band eigenproblem and its eigenvectors come from the library:
stage 1 full -> band, blocked Householder (this file, BLAS3) stage 2 band -> eigenpairs (dsbevd) stage 3 back-transform Z through stage 1 (dlarfb, BLAS3)
The trailing update applies the block reflector from both sides rather than using the symmetric dsyr2k form. That costs about twice the flops of the symmetry-exploiting update, and is still the right trade here because the point is to leave BLAS2 behind. The result is symmetrized explicitly, since applying the two sides separately leaves asymmetry at roundoff.
The reflector block is built with dlarft and applied with dlarfb directly, not through dormqr. dormqr takes its blocked path only when ILAENV’s block size is strictly smaller than the number of reflectors k; a panel k chosen to equal that block size sends every update to the unblocked dorm2r, which applies reflectors one at a time through dger. Calling dlarfb makes the panel width a property of this file rather than of a tuning table that can be equal to it.
Global Variables¶
std::atomic_bool stable_posterior_variance {false}
Process-wide switch for stable posterior variance reductions. Off by default; set through configureStablePosteriorVariance.
int kStablePosteriorVarianceRoundoffUlps = 4
Ulps of the signal variance that a compensated posterior variance may sit below zero.
Higham’s bound on compensated summation is about 2*eps*sum|terms|. A prior and the squares that cancel it are at most two copies of the signal variance, so a mathematical zero rounds no lower than -4*eps*sigma2. The constant does not grow with the number of training rows.
std::int64_t kLp64IndexLimit = std::numeric_limits<std::int32_t>::max()
Largest element offset an LP64 ScaLAPACK routine forms without overflow.
Global Functions¶
bool arrowheadEigenRankOne(const Eigen::VectorXd& d, const Eigen::VectorXd& z, double alpha, Eigen::VectorXd& evals_asc, Eigen::MatrixXd& evecs)
Single-border case, the primitive the block version iterates. M = [diag(d), z; z^T, alpha].
bool arrowheadEigen(const Eigen::VectorXd& d, const Eigen::MatrixXd& B, const Eigen::MatrixXd& A, Eigen::VectorXd& evals_asc, Eigen::MatrixXd& evecs)
- Eigenpairs of a symmetric diagonal-plus-border matrix. M = [ diag(d) B ] d in R^p, B in R^{p x k}, A in R^{k x k}
[ B^T A ]
This is the shape the HS-SVD append builds: the old basis already diagonalises the old kernel, so the leading block is diagonal and the appended observations are a narrow border. A dense eigensolver costs O((p+k)^3) on it; the structure costs O(k (p+k)^2), and k is one or two because that is how many rows an acquisition adds.
Accuracy is the whole difficulty, not speed. Two things are needed and both are done here:
the secular equation is solved in a SHIFTED variable, so the quantity that decides an eigenvector is a difference of nearby diagonal entries rather than a difference of a diagonal entry and a nearly equal eigenvalue;
the coupling vector is reconstructed from the computed eigenvalues through Lowner’s theorem before eigenvectors are formed. Forming them from the original coupling gives vectors that lose orthogonality when eigenvalues cluster, which is exactly what an eight-decade flat spectrum produces.
Deflation handles the two degenerate directions: a negligible border entry means its diagonal entry is already an eigenvalue, and two equal diagonal entries are rotated so that one coupling entry becomes zero and deflates. The zero block that the residual directions contribute deflates through the first of those by construction.
Returns false when the structure or the arguments do not hold, leaving the outputs untouched so a caller falls back to a dense solve.
Parameters:
d |
diagonal of the leading block, any order. |
B |
border, p x k. |
A |
trailing block, k x k, symmetrised internally. |
evals_asc |
ascending eigenvalues, size p + k. |
evecs |
matching eigenvectors as columns, (p+k) x (p+k). |
bool cholesky(const EigenMatrix& C, EigenMatrix& L)
Cholesky decomposition (LAPACK equivalent: dpotrf).
Decomposes a symmetric positive-definite matrix \(C = L L^T\).
Dense operations execute in the installed Kokkos execution space. GPU inputs and results cross the host interface as Eigen matrices.
Parameters:
C |
Symmetric positive-definite matrix. |
L |
Lower-triangular Cholesky factor. |
Returns:
true if C is positive-definite, false otherwise.
Eigen::VectorXd forward_solve(const EigenMatrix& L, const Eigen::VectorXd& b)
Forward triangular solve with vector RHS (BLAS equivalent: dtrsv).
Solves \(L\,x = b\) where L is lower-triangular.
Parameters:
L |
Lower-triangular matrix (e.g. from cholesky()). |
b |
Right-hand side vector. |
Returns:
Solution vector \(x = L^{-1} b\).
Eigen::VectorXd back_solve(const EigenMatrix& L, const Eigen::VectorXd& b)
Back triangular solve with vector RHS (BLAS equivalent: dtrsv).
Solves \(L^T x = b\) where L is lower-triangular.
Parameters:
L |
Lower-triangular matrix. |
b |
Right-hand side vector. |
Returns:
Solution vector \(x = L^{-T} b\).
EigenMatrix forward_solve_mat(const EigenMatrix& L, const EigenMatrix& B)
Forward triangular solve with matrix RHS (BLAS equivalent: dtrsm).
Solves \(L\,X = B\) where L is lower-triangular.
Parameters:
L |
Lower-triangular matrix. |
B |
Right-hand side matrix. |
Returns:
Solution matrix \(X = L^{-1} B\).
EigenMatrix back_solve_mat(const EigenMatrix& L, const EigenMatrix& B)
Back triangular solve with matrix RHS (BLAS equivalent: dtrsm with side=L, uplo=L, trans=T).
Solves \(L^T X = B\) where L is lower-triangular.
Parameters:
L |
Lower-triangular matrix. |
B |
Right-hand side matrix. |
Returns:
Solution matrix \(X = L^{-T} B\).
Eigen::VectorXd forward_solve_mat_colwise_squared_norm(const EigenMatrix& L, const EigenMatrix& B)
Forward triangular solve followed by columnwise squared norms.
Solves \(L\,X = B\) where L is lower-triangular and returns the vector with entries \(\sum_i X_{ij}^2\).
Parameters:
L |
Lower-triangular matrix. |
B |
Right-hand side matrix. |
Returns:
Columnwise squared norms of \(X = L^{-1} B\).
Eigen::VectorXd bordered_cholesky_diagonal(const EigenMatrix& L, const EigenMatrix& B, const Eigen::VectorXd& prior)
Posterior diagonal from bordered Cholesky pivots.
Solves \(L X=B\) and returns the correctly rounded Schur-complement diagonal \(D-\operatorname{diag}(X^T X)\). The prior and negative squares are accumulated together, so a small posterior pivot is not formed by subtracting two independently rounded signal-scale values.
Parameters:
L |
Lower-triangular training factor. |
B |
Training-query cross covariance. |
prior |
Query prior diagonal. |
Returns:
Squared final pivots of the bordered Cholesky factorizations.
EigenMatrix cholesky_inverse(const EigenMatrix& L)
Symmetric inverse from Cholesky factor (LAPACK equivalent: dpotri).
Computes \(C^{-1} = L^{-T} L^{-1}\) given the lower-triangular Cholesky factor L.
Parameters:
L |
Lower-triangular Cholesky factor. |
Returns:
The symmetric positive-definite inverse \(C^{-1}\).
double trace_product(const EigenMatrix& A, const EigenMatrix& B)
Frobenius inner product / trace of matrix product.
Computes \(\operatorname{tr}(A\,B) = \sum_{ij} A_{ij}\,B_{ij}\). Equivalent to the Frobenius inner product when one of the matrices is symmetric.
Parameters:
A |
First matrix. |
B |
Second matrix (same dimensions as |
Returns:
The scalar trace-product.
double log_det_cholesky(const EigenMatrix& L)
Half log-determinant from Cholesky factor.
Computes \(\sum_i \ln L_{ii} = \tfrac{1}{2}\ln|C|\).
Parameters:
L |
Lower-triangular Cholesky factor. |
Returns:
The half log-determinant.
bool satisfies(ArithmeticClass provided, ArithmeticClass required)
True when a provider of class provided meets the class required.
double symmetricBackwardError(Eigen::Index n, double scale)
Higham’s gamma_n times a scale: the backward error of a symmetric eigensolver on an n-by-n matrix of that scale.
bool curvatureIsNegative(double lambda, double scale, Eigen::Index n)
True when lambda is negative by more than the backward error of an n-dimensional symmetric solve at scale. A value inside that ball is unresolved, not a negative mode.
void canonicalizeEigenpairs(Eigen::Ref<Eigen::VectorXd> evals, Eigen::Ref<Eigen::MatrixXd> evecs)
evals has one entry per leading column of evecs. Both are rewritten.
Eigen::Index resolvedSingularRank(const Eigen::VectorXd& singular, double cutoff)
How many leading descending singular values clear cutoff. A value that the backward error cannot separate from the cutoff, or from its neighbour across the cutoff, is not a resolved component: the whole unresolved cluster is dropped, so two solvers that straddle the cutoff by an ulp keep the same rank.
bool rank_one_update_lower(EigenMatrix& lower, const Eigen::VectorXd& vector)
Factor L L^T + u u^T through orthogonal rotations of [L^T; u^T]. The base covariance and the update retain their separate rounding scales.
bool cholesky_rank_update(EigenMatrix& lower, const Eigen::VectorXd& vector)
Update the selected backend’s live Cholesky factor in its existing layout.
template <class Matrices, class Body>
void assembleCollectively(const MpiContext& context, Matrices& result, const Body& body)
Assemble disjoint entries, propagate failures within the owning group, and replicate the tensors. The body joins its workers before returning; only the calling thread enters MPI collectives.
double trace_solve_product(const EigenMatrix& L, const EigenMatrix& A)
tr(K^{-1} A) for a dense factor K = L L^T already in hand.
The solve is Eigen ‘s triangular solve on that matrix. It is not the backend solve: under ScaLAPACK and SLATE, forward_solve_mat scatters its factor into DistributedState::cache_L and runs a collective. A rank-local LLT, such as one SVGD particle, must not enter that path.
double dense_factor_inverse_trace(const EigenMatrix& L)
tr(K^{-1}) = ||L^{-1}||_F^2 for a dense factor already in hand. Same rank-local rule as trace_solve_product.
void configureEnvironmentGpu(const std::string& library)
Native entry points select the device before constructing model contexts. Existing models retain their execution context when this default changes.
void configureStablePosteriorVariance(bool enabled)
Turn stable posterior variance reductions on or off for the process.
Parameters:
enabled |
True selects ExactSum reductions and the checks of requireStablePosteriorVariance; false restores the default paths. |
bool stablePosteriorVarianceEnabled()
Whether stable posterior variance reductions are enabled.
bool acceptStablePosteriorVariance(double& variance, double signal_variance, double relative_allowance)
Accept one stable posterior variance.
A nonnegative finite value is unchanged. A negative value at or above -relative_allowance * signal_variance is replaced by 0. Any more negative value, and any NaN or infinity, is rejected. signal_variance is the variance of the diagonal that entered the reduction: the kernel signal k(x,x), plus observation noise when that noise was added to the same diagonal. For the training-row latent identity the same role is the noise variance that bounds the identity. signal_variance is read only for a negative value.
The default relative allowance, kStablePosteriorVarianceRoundoffUlps machine epsilons, covers the rounding of a compensated sum. A Schur complement that follows a rounded Cholesky factorization and triangular solve carries the conditioning of the factor as well; its allowance is choleskySchurRelativeError.
Parameters:
variance |
Variance to check; a roundoff negative becomes 0. |
signal_variance |
Variance of the diagonal that entered the sum. |
relative_allowance |
Forward error of the reduction relative to signal_variance. A negative value is accepted only when this is finite and below 1: an error of the size of the signal certifies no digit, so clamping to 0 would be a guess. Infinity, NaN and 1 or more reject every negative value. |
Returns:
False when the value is rejected.
bool acceptStablePosteriorVariance(double& variance, double signal_variance)
acceptStablePosteriorVariance with the compensated-sum allowance.
bool acceptStablePosteriorVariance(Eigen::VectorXd& variance, const Eigen::VectorXd& signal)
Accept every entry of a stable posterior variance vector.
Returns:
False when the sizes differ or any entry is rejected by the scalar overload; entries before the rejected one may already be clamped.
void requireStablePosteriorVariance(double& variance, double signal_variance, double relative_allowance)
Accept one stable posterior variance or throw.
Parameters:
StableVarianceError |
when acceptStablePosteriorVariance rejects the value. |
void requireStablePosteriorVariance(Eigen::VectorXd& variance, const Eigen::VectorXd& signal)
Accept every entry of a stable posterior variance vector or throw.
Parameters:
StableVarianceError |
when the sizes differ or any entry is rejected. |
template <typename RelativeError>
void requireStableSchurDiagonal(Eigen::VectorXd& variance, const Eigen::VectorXd& signal, RelativeError&& relative_error)
requireStablePosteriorVariance over a Schur diagonal whose allowance is the forward error of a solve.
relative_error is called once, and only when an entry is negative, because it may cost triangular solves or a collective. It must return the same value on every rank that reaches this call. Each entry is then accepted down to -relative_error * signal; NaN, infinity and anything more negative raise StableVarianceError. This is the one check for diagonals that come from a rounded Cholesky solve, whatever holds the factor.
template <typename Solve, typename SolveTranspose>
double estimateLowerInverseNorm1(Eigen::Index order, Solve&& solve, SolveTranspose&& solve_transpose)
Estimate of ||L^-1||_1 for a lower triangular L (Hager, with Higham’s alternating-sign probe).
solve applies L^-1 to a vector and solve_transpose applies L^-T. The estimate is a lower bound on the norm, as in LAPACK’s xTRCON, and in practice within a small factor of it. It costs at most ten triangular solves. Infinite when a solve is not finite, which is a singular factor.
double choleskySchurRelativeError(Eigen::Index order, double factor_frobenius_norm, double inverse_norm1)
Relative forward error of a Schur complement computed from a rounded Cholesky factor and triangular solve.
Let L be the computed factor of order m, K + dK = L L^T its backward error, w = L^-1 b the exact solve and w^ the rounded one, and nu = ||L||_F ||L^-1||_1, which bounds kappa_2(L) / sqrt(m) because ||L||_2 <= ||L||_F and ||L^-1||_2 <= sqrt(m) ||L^-1||_1. inverse_norm1 is an upper bound on ||L^-1||_1. A lower bound makes nu, and this allowance, a lower bound on the forward error, so a pivot whose negativity is real roundoff is rejected. With u = eps / 2 and gamma_k = k u / (1 - k u):
substitution solves (L + dL) w^ = b with abs(dL) <= gamma_m abs(L) (Higham, Accuracy and Stability, Thm 8.5), so ||w^ - w||_2 <= a ||w^||_2 with a = gamma_m m nu;
Cholesky has abs(dK) <= gamma_{m+1} abs(L) abs(L^T) (Thm 10.3), which moves b^T K^-1 b by at most b_f ||w||^2 with b_f = gamma_{m+1} m^2 nu^2.
A valid Schur complement has ||w||^2 <= prior, so the computed one prior - ||w^||^2 is off by at most (a (2 + a) + b_f) / (1 - a - b_f)^2 of the prior, plus one rounding of the result, eps. The value is infinite when a + b_f >= 1 or when the bound itself is 1 or more: an error as large as the signal leaves no certified digit, and no negative result can be called roundoff.
double upperInverseNorm1FromComputed(double computed_norm, Eigen::Index order)
Upper bound on ||L^-1||_1 from a computed inverse’s 1-norm.
Column sums of a computed inverse can round down, so the value passed to choleskySchurRelativeError is lifted by the unit roundoff of an order-length sum. This is not estimateLowerInverseNorm1: that function is a lower bound and is not an error bound.
double upperInverseNorm1FromResidual(double computed_norm, double residual_norm, double factor_abs_norm, Eigen::Index order)
Upper bound on ||L^-1||_1 from a computed triangular solve.
computed_norm is ||Y||_1 for Y solving L Y = I, residual_norm is ||I - L Y||_1, and factor_abs_norm is ||L||_1. The residual is enlarged by the rounding of I - L Y (Higham), and the result is lifted by upperInverseNorm1FromComputed. A column-sum lift alone is not a certificate: it leaves out the triangular-solve error. A non-finite argument or a residual bound of 1 or more is infinite.
template <typename Derived>
double upperInverseNorm1(const Eigen::MatrixBase<Derived>& factor)
Upper bound on ||L^-1||_1 for an explicit lower-triangular factor.
Y solves L Y = I. The bound is upperInverseNorm1FromResidual. A singular or non-finite solve is infinite.
template <typename Derived>
double denseCholeskySchurRelativeError(const Eigen::MatrixBase<Derived>& factor)
choleskySchurRelativeError of a dense lower Cholesky factor.
The inverse norm is upperInverseNorm1, an upper bound. The Hager estimate is a lower bound and is not used here.
template <typename Backend, typename Derived>
double subsetFactorSchurRelativeError(Backend& backend, const Eigen::MatrixBase<Derived>& factor, int order)
Schur relative error of a variance-subset factor.
A dense host factor is read with denseCholeskySchurRelativeError. An empty host factor is what a distributed factorization leaves behind: the factor is cached on the backend, and the empty matrix reads as +inf, which makes borderedCholeskyDiagonal fall back to four ulps. The backend’s cached_factor_schur_relative_error is that factor’s conditioning. order is the cached factor’s dimension.
template <typename Derived, typename RelativeError>
Eigen::VectorXd borderedCholeskyDiagonalWith(const Eigen::VectorXd& prior, const Eigen::MatrixBase<Derived>& whitened, RelativeError&& relative_error)
Squared final pivots of bordered Cholesky factorizations.
If whitened is \(W=L^{-1}K_{tq}\), entry \(j\) is
the square of the last diagonal in the Cholesky factor of \(\begin{bmatrix}LL^T&K_{tq}\\K_{tq}^T&K_{qq,jj}\end{bmatrix}\). ExactSum accumulates the prior and every negative square without rounding; only the final result is rounded to binary64. Consequently the reduction error is at most one rounding of the local posterior variance, rather than \(\gamma_n K_{qq,jj}\) from a length- \(n\) dot product followed by a cancellation.
template <typename Derived>
Eigen::VectorXd borderedCholeskyDiagonal(const Eigen::VectorXd& prior, const Eigen::MatrixBase<Derived>& whitened)
borderedCholeskyDiagonal for a whitened block L^-1 K_tq with no factor in hand: the allowance is the rounding of the compensated sum alone.
template <typename Derived, typename FactorDerived>
Eigen::VectorXd borderedCholeskyDiagonal(const Eigen::VectorXd& prior, const Eigen::MatrixBase<Derived>& whitened, const Eigen::MatrixBase<FactorDerived>& factor)
borderedCholeskyDiagonal for W = L^-1 K_tq solved with the dense lower factor factor; the allowance is choleskySchurRelativeError of that factor.
An empty factor means the factor is not held on the host (it is resident on a device), so its conditioning cannot be read; the allowance is then that of the two-argument form.
template <typename PriorDerived, typename WeightDerived, typename SolvedDerived, typename RelativeError>
double borderedCholeskyActionVarianceWith(const Eigen::MatrixBase<PriorDerived>& prior, const Eigen::MatrixBase<WeightDerived>& weights, const Eigen::MatrixBase<SolvedDerived>& whitened_action, RelativeError&& relative_error)
Variance of a linear query action from its bordered Cholesky solve.
The prior action \(w^T K_{qq}w\) and the negative squared entries of \(L^{-1}K_{tq}w\) share one exact accumulator. This is the scalar bordered-Cholesky pivot for a directional or integrated observation.
template <typename PriorDerived, typename WeightDerived, typename SolvedDerived>
double borderedCholeskyActionVariance(const Eigen::MatrixBase<PriorDerived>& prior, const Eigen::MatrixBase<WeightDerived>& weights, const Eigen::MatrixBase<SolvedDerived>& whitened_action)
borderedCholeskyActionVariance with the compensated-sum allowance.
template <typename PriorDerived, typename WeightDerived, typename SolvedDerived, typename FactorDerived>
double borderedCholeskyActionVariance(const Eigen::MatrixBase<PriorDerived>& prior, const Eigen::MatrixBase<WeightDerived>& weights, const Eigen::MatrixBase<SolvedDerived>& whitened_action, const Eigen::MatrixBase<FactorDerived>& factor)
borderedCholeskyActionVariance for L^-1 K_tq w solved with the dense lower factor factor, with the allowance of choleskySchurRelativeError.
double pcg_dot(const Eigen::VectorXd& a, const Eigen::VectorXd& b)
Inner product over the replicated CG state. The solver runs the same loop on every rank with x, r, p, z held identically replicated, and apply_A returns an already-assembled (replicated) matvec, so each rank’s long-double dot is the full inner product. No cross-rank reduction is taken: summing the P identical replicated copies would scale every dot by P (harmless in the alpha/beta ratios) but the long-double accumulation of P identical doubles rounds differently per rank count, so a reduction here makes the CG trajectory match only within a fixed-P group. Returning the local replicated dot is bit-identical at every rank count.
PCGResult preconditioned_cg(const std::function<Eigen::VectorXd(const Eigen::VectorXd&)>& apply_A, const std::function<Eigen::VectorXd(const Eigen::VectorXd&)>& apply_M_inv, const Eigen::VectorXd& b, const PCGSettings& settings = {})
Preconditioned conjugate gradient on a SPD matrix A whose action on a vector is given by apply_A. The preconditioner inverse is apply_M_inv. Both are evaluated once per CG iteration.
The full CG state (x, r, p, z) is replicated on every rank; apply_A returns a replicated matvec, so the inner products inside the loop are taken locally without MPI. Each iteration performs:
1 matvec A @ p
1 precondit z = M^{-1} r
3 inner prod p^T A p, r^T z, ||r||^2 (latter for tolerance check)
2 axpy x += alpha p; r -= alpha A p
1 vec sum p = z + beta p
pcg_dot accumulates in long double over the replicated vector, so the floating-point trajectory of CG is bit-identical at every rank count when the matvec and preconditioner are also bit-identical.
bool kokkosHostExecutionMemory()
True when the Kokkos execution memory is the host. A non-Kokkos build does not call this. Host memory is already the execution space, so a factor that lives in an Eigen matrix does not cross a boundary.
DistributedFactorization distributedFactorization()
Process-wide selection; Reproducible unless configured otherwise.
std::uint64_t distributedFactorizationGeneration()
Changes each time the selection changes. A cached factor, inverse or replica records the generation it was computed under and is not reused under another one.
void configureDistributedFactorization(DistributedFactorization mode)
Select the distributed factorization and reapply the configured thread count, since the BLAS thread policy depends on the selection.
std::optional<DistributedFactorization> parseDistributedFactorization(std::string_view name)
“reproducible” or “library”; anything else gives no value.
int configuredLinalgThreads()
Requested dense numerical budget, independent of nested BLAS controls.
void configureLinalgThreads(int threads)
Configure the process thread budget before concurrent numerical work. Keeping the call inside the library reaches private static BLAS symbols without exposing them to an oracle’s BLAS runtime. The count is a process-wide run parameter; set it before constructing models. Eigen and BLAS search products keep one fixed reduction order; canonical tiles and panels spend the requested budget in parallel without changing their inner product order. The count is also the OpenMP team of kernel and Hessian assembly. The OpenMP runtime receives the same count, so OMP_NUM_THREADS does not fight the team.
void configureProductThreads(int threads)
Thread count of Eigen and BLAS products alone, leaving configuredLinalgThreads() unchanged. This low-level control honours its argument; callers that require invariant reductions explicitly select one thread per independently scheduled tile.
void configureLibrarySerialKernels(bool enabled)
When set, the dense factor and the triangular solves use Eigen ‘s library kernels (LAPACK when BLAS is linked) instead of the OpenMP panel kernels. One thread is the serial baseline the scaling notes compare with the panel path. Clearing the flag restores the panel kernels for a team of more than one. A single configured thread stays on Eigen ‘s factor and triangular solve: the panel kernels are a different rounding even with one worker, and the oracle counts were measured on Eigen.
void configureUnconstrainedLibraryReductions(bool enabled)
Opt into unconstrained library reductions (e.g. SLATE MethodTrsm::Auto hypercube reductions and unaligned ScaLAPACK slab views) for diagnostic overhead comparisons. Disabled by default so both Reproducible and Library factorizations preserve canonical tile order across ranks, grids and threads.
void configureTileThreads(int threads)
Threads one rank devotes to independent tile products of the canonical factorization and solves. Each product runs on one thread, so the values do not depend on this count. Under the Library factorization the tiles stay on the calling thread as well.
int affinityCpuCount()
CPUs in this process’s scheduling affinity, or 0 when unknown.
int blasThreadCount()
Actual thread count of the BLAS runtime linked inside this library, or zero when the build uses no OpenBLAS runtime.
bool teamPanelKernels()
Panel factorization and substitution. False when the library serial flag is set, when OpenMP is off, and when the configured team is one thread. The one-thread case is Eigen ‘s own kernels.
void configureKernelThreads(int threads)
Process default captured by subsequently constructed local executors. Configure before constructing models; CPU allocation and BLAS thread limits belong to the application that owns the process.
void refreshKernelTeam()
Recompute the default team from the requested kernel threads and the configured linalg threads: the larger of the two when a parallel runtime is built in. configureLinalgThreads calls this.
std::int64_t blockCyclicLocalExtent(std::int64_t n, std::int64_t nb, std::int64_t iproc, std::int64_t isrc, std::int64_t nprocs)
NUMROC in 64-bit arithmetic: the number of the n entries of one dimension, distributed in blocks of nb over nprocs processes starting at process isrc, that process iproc owns. Returns 0 for a non-positive order, block or process count.
std::int64_t largestLocalEntries(std::int64_t m, std::int64_t n, std::int64_t mb, std::int64_t nb, std::int64_t rsrc, std::int64_t csrc, std::int64_t nprow, std::int64_t npcol)
Entries of the largest local array (leading dimension times local columns) any process of an nprow x npcol grid holds for an m x n matrix in mb x nb blocks whose first block sits on process (rsrc, csrc).
The source process owns the most rows and the most columns: it receives every complete round of blocks plus the first leftover block. The leading dimension is taken as max(1, local rows) of that process, the convention of every descriptor DistributedState builds; a descriptor whose leading dimension exceeds the largest local row count on some process is outside this bound (see exceedsLp64).
std::int64_t largestLocalEntries(const int* desc, int nprow, int npcol)
largestLocalEntries for a ScaLAPACK descriptor on an nprow x npcol grid. The leading dimension field is also taken into account, so a descriptor with a padded leading dimension is measured by the array it describes.
std::atomic<std::int64_t>& lp64IndexLimitStore()
Limit the routing decision compares against: kLp64IndexLimit, unless a ScopedLp64IndexLimit lowers it so tests reach the routed paths at small orders. The value is the inline copy of the translation unit that decides.
bool exceedsLp64(const int* desc, int nprow, int npcol)
True when an LP64 ScaLAPACK routine on this descriptor would form an element offset past 2^31 - 1 on some process of the grid. Every process that passes the same descriptor fields gets the same answer, except where processes pass different leading dimensions; the descriptors DistributedState builds use max(1, local rows), whose largest value is the source process’s row count, and give the same answer everywhere.
bool exceedsLp64(std::int64_t count)
True when an element count or workspace size does not fit LP64 INTEGER.
AvailableMemory availableHostBudget()
Node headroom restricted by visible cgroup v1 and v2 ancestors. Null means unknown; zero means the allocation has exhausted a measured limit.
std::int64_t availableHostBytes()
Compatibility query: zero represents unknown or exhausted availability. Allocation decisions use availableHostBudget to distinguish the two.
bool fitsRankShare(std::int64_t needed, std::int64_t available, int node_ranks)
True when needed bytes fit this rank’s share of available bytes split evenly over the ranks of the node. Unknown availability (zero) fits.
void requireRankShare(const char* what, std::int64_t needed, AvailableMemory available, int node_ranks)
Throws std::runtime_error naming what, the bytes it needs per rank and this rank’s share when needed does not fit fitsRankShare.
void replicate_owned_values(double* data, std::size_t count, const MpiContext& context)
Replicate entries with exactly one owner and positive zero elsewhere. Integer OR preserves the owner’s bits, including signed zero, without rounding or a rank-dependent floating-point reduction.
void disjoint_sum_bcast(double* data, int count, const MpiContext& context)
Replicate a sum with at most one nonzero contributor per entry. Adding positive zeros preserves that contributor’s value regardless of the reduction tree. Overlapping contributions require ordered_sum_bcast.
void ordered_sum_bcast(double* data, int count, const MpiContext& context)
Sum overlapping contributions in rank order and replicate the result. Only the supplied process group participates. Local views enter no MPI.
void compensated_sum_bcast(CompensatedSum* data, int count, const MpiContext& context)
Merge compensated contributions in rank order, retaining the rounding error from adding their main sums in the resulting correction.
void exact_sum_bcast(ExactSum* sums, int count, const MpiContext& context)
Replace each accumulator by the exact sum over the process group and replicate the result. Digits are integers, so the reduction is associative: the outcome does not depend on the rank count, the reduction tree or the way the addends were split over ranks.
int schemeISliceBits(Eigen::Index length)
Bit width of one Ozaki Scheme I slice for a product of length terms. Two slices of this width have an exact binary64 product, and the sum of length such products is exact as well, with the slice scales kept separate.
SchemeISlices splitSchemeI(const Eigen::Ref<const Eigen::VectorXd>& values)
Split one operand into Scheme I slices. The sum of the slices is the operand. This split does not form the product.
double accumulateSchemeI(const SchemeISlices& left, const SchemeISlices& right)
Sum the exact slice products. The split and this accumulation are separate.
double schemeIProductRaw(const double* left, const double* right, int length)
Scheme I product of two length-n factors in term order.
template <typename Left, typename Right>
double schemeIProduct(const Eigen::MatrixBase<Left>& left, const Eigen::MatrixBase<Right>& right)
Scheme I product of two equally shaped operands, in the same term order as the compensated predict contraction (column, then row).
void disjoint_sum_bcast(double* data, int count, DistributedState& st = DistributedState::instance())
Reduction for buffers whose per-rank contributions have DISJOINT support: every entry is nonzero on at most one rank and +0.0 (from setZero) everywhere else. IEEE-754 addition gives x + (+0.0) = x and (+0.0) + (+0.0) = +0.0 exactly, so MPI_SUM under any reduction tree returns the unique contributor bit-for-bit identical to ordered_sum_bcast and to the single-rank assembly, at MPI_Allreduce’s O(log P) cost instead of the Gather(P * count) + root long-double sum + Bcast round-trip.
Applies to the one-owner-per-block covariance assemblies (ownsBlock gating writes each block and its transpose partner from exactly one rank via assignBlockToMatrix assignment, never accumulation). Overlapping partial sums (per-rank training-slice means, trace terms, scalar log-marginal contributions) require ordered_sum_bcast to fix their reduction order for a given partition. Different partitions can produce different rounded local sums.
int lp64Workspace(double query, const char* routine, const DistributedState& st)
LP64 INTEGER workspace length from the ScaLAPACK workspace query result query. The largest query over the grid decides, so every process either proceeds or throws std::length_error naming routine. Collective.
Eigen::VectorXd columnSquaredNormsExact(const std::vector<double>& buf, const int* desc, int m, int ncols, DistributedState& st)
Column-wise sums of squares of a block-cyclic matrix whose tiles are owned whole by one rank. Each tile column contributes a partial sum accumulated in a fixed order inside the tile; the partials enter an exact accumulator, so the replicated result is independent of the grid.
double cachedFactorSchurRelativeError(int m, DistributedState& st = DistributedState::instance())
Relative forward error of a Schur complement formed from the cached distributed factor (choleskySchurRelativeError). ||L||_F is summed over the lower triangle of the local blocks. ||L^-1||_1 is upperInverseNorm1FromResidual: the 1-norm of the inverse from one cached triangular solve, corrected by the residual of that solve. A column-sum lift alone leaves out the triangular-solve error and is not a certificate. The factor itself is never gathered. Every rank receives the same value, and every rank must call it.
void requireCachedFactorSchurDiagonal(Eigen::VectorXd& diagonal, const Eigen::VectorXd& prior, int m, DistributedState& st)
requireStablePosteriorVariance over a Schur diagonal formed from the cached distributed factor. The diagonal is replicated, so every rank asks for the conditioning together or none does, and every rank throws together.
EigenMatrix forward_solve_mat_bilinear_distributed(const EigenMatrix& L, std::vector<double> b_buf, const int* desc_b, int m, int ncols, DistributedState& st = DistributedState::instance(), const Eigen::VectorXd* prior = nullptr, Eigen::VectorXd* posterior_diagonal = nullptr)
Distributed bilinear form M = (L^{-1} KK)^T (L^{-1} KK).
Given the lower Cholesky factor L of the training kernel K (m x m, scattered into the DistributedState cache on first use, reused on subsequent calls) and a distributed cross-covariance buffer KK_dist (m x ncols, block-cyclic with descriptor desc_kk), returns the small ncols x ncols matrix M = (L^{-1} KK)^T (L^{-1} KK).
Used by GaussianProcessRegression::calculateObservationPosteriorCovariance to compute the posterior covariance between joint query channels: K_post(i, j) = K_qq(i, j) - M(i, j), since K^{-1} = L^{-T} L^{-1} so KK^T K^{-1} KK = (L^{-1} KK)^T (L^{-1} KK).
The factor, triangular solve and symmetric product stay distributed. Only the ncols x ncols result is gathered for the caller.
Eigen::VectorXd cholesky_inverse_diagonal_distributed(const EigenMatrix& L, int order, DistributedState& st = DistributedState::instance())
Diagonal of (L L^T)^-1 from distributed columns of L^-1. Triangular inversion avoids solving for the known zero upper triangle. The owned factor is immutable; only the resulting diagonal is replicated.
bool factor_inverse_lower(const EigenMatrix& L, int n, std::vector<double>& inverse, int* desc, DistributedState& st)
Lower triangle of C^{-1}, in the layout of the cached factor of order n (L, when not empty, replaces the cache first). The reproducible factorization forms it with the tile-ordered inverse, whose bits do not depend on the grid; the library factorization uses pdpotri. The inverse costs about 2n^3/3, against 2n^3 for substitutions on n columns. It is returned, not cached. Returns false when the library inverse fails.
template <class Entry>
ExactSum trace_lower_symmetric_local(const double* A, int lda, int n, Entry&& b, DistributedState& st)
This rank’s exact share of tr(A B) for symmetric n x n matrices: A is read on its lower triangle in the layout of desc (leading dimension lda), and b(i, j) returns entry (i, j) of B for i >= j. Off-diagonal products count twice. Every product enters the accumulator exactly, so the merged sum does not depend on how the entries are distributed.
double trace_inverse_times_symmetric(const EigenMatrix& L, const EigenMatrix* B, int n, DistributedState& st = DistributedState::instance())
tr(C^{-1} B) for a symmetric replicated B, or tr(C^{-1}) when B is null, from the inverse of the factor (see factor_inverse_lower). The same formula runs at every rank count. Returns NaN when the inverse fails.
bool teamDivideConquerEigen(const Eigen::MatrixXd& sym, Eigen::VectorXd& evals, Eigen::MatrixXd& evecs)
Ascending eigenpairs of a symmetric matrix.
Eigen ‘s blocked Householder tridiagonalization, compiled without a BLAS kernel. The pairs do not follow the OpenBLAS microkernel or the thread count. Returns false when the order is not square or the solver fails.
bool covarianceDsyevr(const Eigen::MatrixXd& sym, Eigen::VectorXd& evals, Eigen::MatrixXd& evecs)
Covariance eigensolve used by the stable basis. Eigen ‘s symmetric eigensolver, range all, lower triangle. The pairs do not follow the OpenBLAS microkernel.
std::int64_t teamPanelWidth()
Column panel of the triangular solve. The width is the largest power of two whose panel fits in one core’s level-2 cache at the joint order of the scaling grid. TeamFactor.cpp states that rule. The solve bits do not follow this width: teamPanelBitsIndependent checks that.
bool teamPanelBitsIndependent()
True when a one-thread solve, a one-column panel, and the derived panel write the same bits on one lower factor. The check is the sweep behind the claim that the published solve does not depend on the panel width.
double teamSolveWallSeconds()
Wall time accumulated by dense and distributed triangular solves since the last reset.
double teamFactorWallSeconds()
Wall time accumulated by dense and distributed Cholesky factors since the last reset.
bool teamParallelPays(double flops)
False. Vendor BLAS already uses the affinity count, so this function does not start a second team. The flop argument is ignored. There is no cutoff and no saved clock.
bool teamCholeskyLower(double* lower, std::int64_t lda, std::int64_t n)
Lower Cholesky of a column-major matrix. Only the lower triangle is read and written. The factor is Eigen ‘s blocked Cholesky, compiled without a BLAS kernel. Returns false when a pivot is not positive; the matrix may then be partly overwritten.
void teamSolveLower(const double* lower, std::int64_t lda, bool lower_factor, double* rhs, std::int64_t ldb, std::int64_t n, std::int64_t cols)
Solves L X = B (lower == true) or L^T X = B, L stored lower-triangular and column-major. The substitution is Eigen ‘s blocked triangular solve, compiled without a BLAS kernel.
void teamSolveLowerVector(const double* lower, std::int64_t lda, bool lower_factor, double* rhs, std::int64_t n)
The solve above for one right-hand side held as a vector. It runs Eigen ‘s matrix-vector triangular sweep, the kernel a serial build runs on a vector, so a vector solve has the same bits in every build. A one-column matrix goes to teamSolveLower and its blocked matrix kernel.
void teamSymmetricGram(const double* b, std::int64_t ldb, double* c, std::int64_t ldc, std::int64_t n)
The three kernels below run on configuredLinalgThreads() workers of the tile pool. Each worker owns whole blocks of Eigen ‘s own blocking, so the bits do not follow the thread count. C = B^T B for a column-major B. The product is Eigen ‘s blocked product, compiled without a BLAS kernel, so the bits do not follow OPENBLAS_CORETYPE.
std::atomic<int>& tileThreadCount()
Number of threads one rank devotes to independent tile products.
void setTileThreads(int threads)
Sets the tile thread count (at least one).
template <class F>
void parallelFor(long count, F&& fn)
parallelFor(count, fn): see TilePool::run.
bool trainingCholeskySelected(Eigen::Index order)
A product library or an in-process Scheme II engine is configured and the order spans two panels.
bool trainingCholeskyDistributedSelected(Eigen::Index order)
As trainingCholeskySelected, for trainingCholeskyDistributed: device libraries only.
bool trainingCholeskyLower(ProductMatrix lower)
Panel boundaries are independent of the process grid. Fixed-order scalar code factors and solves panels; Scheme II updates the trailing matrix. Only the lower triangle is an input. Failure can modify that input.
std::shared_ptr<const schemeii::Context> schemeIIContext()
The in-process Scheme II engine, or null. The reproducible distributed kernels take their tile products from it.
void configureTrainingProductLibrary(const std::string& library)
Select a Scheme II product. A path loads a device library through the v1 C ABI; “scheme2:fp64[…]” or “scheme2:int8[…]” selects an in-process CPU engine (see schemeii::parseOptions). Empty selects the native backend. Explicit library or device errors throw; they cannot masquerade as a run with the requested arithmetic. Configure before training starts.
bool trainingProductConfigured()
A device library or an in-process engine is configured.
bool trainingProductLibraryLoaded()
A device library (not an in-process engine) is configured.
bool tryTrainingProduct(ConstProductMatrix a, ConstProductMatrix b, ProductMatrix c, bool transpose_a = false, bool transpose_b = false, double alpha = 1.0, double beta = 0.0, bool partitioned = false)
C = alpha op(A) op(B) + beta C. Returns false when the native backend should handle the product (no device library, or a small matrix). C must have the output dimensions and must not overlap either input. A partitioned call uses a size decision made for the global product, so changing the process grid cannot switch a local block’s arithmetic.
Eigen::MatrixXd trainingProduct(ConstProductMatrix a, ConstProductMatrix b, bool transpose_a, bool transpose_b)
Allocating form with a native Eigen product when no device product runs.