class gpr::linalg::DistributedState

Overview

#include <gpr/linalg/DistributedState.h>
 
class DistributedState {
public:
    // structs
 
    struct CholeskyFactorSnapshot;
    struct DescCacheEntry;
    struct TileCommunicators;
 
    // construction
 
    DistributedState(std::shared_ptr<const MpiCommunicator> communication);
    ~DistributedState();
 
    // methods
 
    static DistributedState& instance();
    static std::uint64_t factorization_generation();
    static DistributedBackendKind compiled_backend();
    static int recommended_block_size(int requested_block, int nprocs);
    static int recommended_nprow(int nprocs, int block_size);
    static void release(std::vector<double>& buffer);
    const std::shared_ptr<const MpiCommunicator>& communication() const;
    std::uint64_t grid_generation() const;
    DistributedFactorization factorization() const;
    bool reproducible() const;
    bool exceeds_lp64(const int* desc) const;
    bool tile_kernels(const int* desc, const char* routine, const int* other = nullptr) const;
    void require_lp64(const int* desc, const char* routine) const;
    void set_factorization(DistributedFactorization mode);
    DistributedBackendKind backend_kind() const;
    const char* backend_name() const;
    void configure(int block_size, int nprow, bool computation_tile = false);
    int configured_block_size() const;
    int effective_configured_block_size() const;
    int configured_nprow() const;
    void initialize(int block_size = 0, int nprow = 0);
    int node_ranks() const;
    int cpu_share() const;
    void make_lin_desc(int m, int n, int* desc) const;
    int lin_local_rows(int m) const;
    int col_block_nb(int n) const;
    void col_block_range(int n, int& start, int& count) const;
    void make_col_desc(int m, int n, int* desc) const;
    int compute_ictxt() const;
    int lin_local_cols(int n) const;
    std::vector<double> scatter_lin(const EigenMatrix& global, int m, int n, int* desc) const;
    std::vector<double> scatter_lin_colvector_root(const Eigen::VectorXd& global, int m, int* desc) const;
    Eigen::VectorXd gather_lin_colvector_root(const double* local, const int* desc, int m) const;
    void make_desc(int m, int n, int* desc) const;
    int local_rows(int m) const;
    int local_cols(int n) const;
    int local_index_for_global(int global_index, int block_size, int proc_coord, int nprocs_dim) const;
    int global_index_for_local(int local_index, int block_size, int proc_coord, int nprocs_dim) const;
    std::vector<double> scatter(const EigenMatrix& global, int m, int n, int* desc) const;
    void scatter_by_panels(const double* global, int m, int n, const int* desc, double* local, int row, int col, int nprow, int npcol) const;
    std::vector<double> alloc_local(int m, int n, int* desc) const;
    std::vector<double> scatter_colvector_root(const Eigen::VectorXd& global, int m, int* desc) const;
    EigenMatrix gather(const double* local, const int* desc, int m, int n, bool broadcast_result = true) const;
    EigenMatrix gather_block(const double* local, const int* desc, int row0, int col0, int m, int n, bool broadcast_result = true) const;
    Eigen::VectorXd gather_colvector_root(const double* local, const int* desc, int m, bool broadcast_result = true) const;
    void cache_L(std::vector<double> L_dist, const int* desc, int n);
    void claim_cached_L(const void* owner);
    bool cached_L_owned_by(const void* owner) const;
    bool cached_L_is_unowned() const;
    CholeskyFactorSnapshot take_cached_L(const void* owner);
    bool restore_cached_L(CholeskyFactorSnapshot snapshot, const void* owner);
    bool has_cached_L() const;
    const double* cached_L() const;
    double* cached_L_mut();
    bool has_cached_U() const;
    void cache_U(std::vector<double> U);
    const double* cached_U() const;
    const int* cached_L_desc() const;
    int cached_n() const;
    void invalidate_L();
    void cache_L_lin(std::vector<double> L_dist, const int* desc, int n);
    bool has_cached_L_lin() const;
    const double* cached_L_lin() const;
    double* cached_L_lin_mut();
    const int* cached_L_lin_desc() const;
    int cached_lin_n() const;
    void cache_inv(std::vector<double> inv_dist, const int* desc, int n);
    std::size_t inverse_builds() const;
    bool has_cached_inv() const;
    const double* cached_inv() const;
    const int* cached_inv_desc() const;
    int cached_inv_n() const;
    void invalidate_inv();
    void invalidate_derived_cholesky();
    bool owns_global_entry(int global_row, int global_col) const;
    bool owns_lin_entry(int global_row, int global_col) const;
    const double* cached_inv_block(int global_row, int global_col, int& leading_dimension) const;
    double cached_inv_local_entry(int global_row, int global_col) const;
    int context() const;
    int lin_context() const;
    MPI_Comm world_comm() const;
    int lin_myrow() const;
    int lin_mycol() const;
    int nprocs() const;
    int myrank() const;
    int myrow() const;
    int mycol() const;
    int nprow() const;
    int npcol() const;
    int block_size() const;
    bool is_root() const;
    TileCommunicators tile_communicators(int context = -1);
};

Detailed Documentation

Construction

DistributedState(std::shared_ptr<const MpiCommunicator> communication)

Construct independent factor storage on a shared process group. Grid initialization and destruction are collective on that group.

Methods

static std::uint64_t factorization_generation()

Generation of the factorization selection; a factor held outside this state records it and is not reused under another selection.

static void release(std::vector<double>& buffer)

Returns the storage of buffer to the allocator.

DistributedFactorization factorization() const

Distributed factorization the solves of this state use. The selection is process-wide; see configureDistributedFactorization.

bool exceeds_lp64(const int* desc) const

True when an LP64 ScaLAPACK routine cannot index the local arrays of desc on its process grid (Lp64Limits.h). The answer depends on the descriptor fields only, so every process of the grid agrees.

bool tile_kernels(const int* desc, const char* routine, const int* other = nullptr) const

True when a factorization, substitution or inverse on desc (and on the second operand other, when given) runs on the tile kernels: always under the reproducible selection, and under the library selection when the LP64 ScaLAPACK routine would overflow its element offsets on either operand. The tile kernels index in 64 bits. The first rerouted call of a process prints one line on the root rank.

void require_lp64(const int* desc, const char* routine) const

Throws std::length_error, on every process alike, when routine has no tile counterpart and its LP64 offsets on desc would overflow.

void set_factorization(DistributedFactorization mode)

Select the factorization and drop every cached factor, transpose, replica and inverse. Caches of other states compare the generation they were computed under and read as absent after the change.

void configure(int block_size, int nprow, bool computation_tile = false)

Fix the grid that initialize builds. A positive block_size or nprow overrides what callers request. With computation_tile, a non-positive block_size selects the automatic computation tile (recommended_block_size) wherever the block also sets the arithmetic: in SLATE builds and under the reproducible factorization. Block sizes callers pass to initialize then describe a data layout, such as an observation stride, and do not choose the tile. The choice follows the factorization selected when initialize runs.

int effective_configured_block_size() const

Block size initialize takes over the caller’s request; zero when the caller’s request stands.

int node_ranks() const

Ranks of this process group on this node (one before initialize).

int cpu_share() const

CPUs of this process’s affinity mask divided among the ranks of the group on this node whose masks overlap it, at least one; zero before initialize or where affinity is unknown. Unbound ranks launched on one node all see the whole mask and share it; ranks bound to disjoint CPUs keep their own.

const double* cached_inv_block(int global_row, int global_col, int& leading_dimension) const

Local storage of the cached inverse at a global entry this rank owns, with the leading dimension of the local buffer; entries of the same block-cyclic block follow at unit row and leading-dimension column offsets.