.. index:: pair: namespace; gpr::linalg::canonical .. _doxid-namespacegpr_1_1linalg_1_1canonical: namespace gpr::linalg::canonical ================================ .. toctree:: :hidden: enum_gpr_linalg_canonical_Triangle.rst struct_gpr_linalg_canonical_SubstitutionCache.rst struct_gpr_linalg_canonical_TileGeometry.rst class_gpr_linalg_canonical_AlignedBlockCache.rst class_gpr_linalg_canonical_AlignedBuffer.rst class_gpr_linalg_canonical_AlignedTile.rst Overview ~~~~~~~~ .. ref-code-block:: cpp :class: doxyrest-overview-code-block namespace canonical { // typedefs typedef Eigen::Map> :target:`TileMap`; typedef Eigen::Map :ref:`AlignedMap`; // enums enum :ref:`Triangle`; // structs struct :ref:`SubstitutionCache`; struct :ref:`TileGeometry`; // classes class :ref:`AlignedBlockCache`; class :ref:`AlignedBuffer`; class :ref:`AlignedTile`; // global variables int :ref:`kExactMinColumns` = 32; std::int64_t :ref:`kTransposeBatchEntries` = std::int64_t{1}<<24; // global functions std::atomic& :ref:`choleskyPanelGroup`(); :ref:`TileGeometry` :target:`geometryOf`(:ref:`DistributedState`& st, const int* desc); :ref:`TileMap` :target:`tileAt`(double* base, int lld, const :ref:`TileGeometry`& g, int row_tile, int col_tile, int rows, int cols); void :ref:`requireWorkspaceBudget`(:ref:`DistributedState`& st, const char* what, std::int64_t needed, :ref:`AvailableMemory` available); void :target:`trsm`(:ref:`DistributedState`& st, :ref:`Triangle` triangle, const double* T, const int* desc_t, double* B, const int* desc_b, int n, int ncols, bool lower_rhs); std::int64_t :ref:`transposeWorkspaceBytes`(const int* desc, int local_cols, std::int64_t batch_entries); std::vector :ref:`transposeFactor`(:ref:`DistributedState`& st, const double* L, const int* desc, int n, std::int64_t batch_entries = 0); void :ref:`trsmLowerFactor`(:ref:`DistributedState`& st, const double* L, const int* desc_l, double* B, const int* desc_b, int n, int ncols, bool transpose); void :ref:`trsmCachedLowerFactor`(:ref:`DistributedState`& st, double* B, const int* desc_b, int n, int ncols, bool transpose); void :ref:`trsmLowerFactorCached`(:ref:`DistributedState`& st, :ref:`SubstitutionCache`& cache, const double* L, const int* desc_l, double* B, const int* desc_b, int n, int ncols, bool transpose); void :ref:`solveLowerFactorCached`(:ref:`DistributedState`& st, :ref:`SubstitutionCache`& cache, const double* L, const int* desc_l, double* B, const int* desc_b, int n, int ncols); Eigen::MatrixXd :ref:`gramTiles`(const Eigen::MatrixXd& x, int nb); void :ref:`solveLowerFactor`(:ref:`DistributedState`& st, const double* L, const int* desc_l, double* B, const int* desc_b, int n, int ncols); void :ref:`choleskyInverseLower`(:ref:`DistributedState`& st, const double* L, const int* desc, int n, std::vector& inverse, std::optional upper = std::nullopt); void :ref:`extendBorder`(:ref:`DistributedState`& st, const :ref:`DistributedState::TileCommunicators`& comms, const :ref:`TileGeometry`& g, double* A, int lld, int n, int first_new, int tiles); int :ref:`exactOuterWidth`(); bool :ref:`potrfLowerExact`(:ref:`DistributedState`& st, const :ref:`schemeii::Context`& ctx, double* A, const int* desc, int n, int n_factored); bool :ref:`potrfLower`(:ref:`DistributedState`& st, double* A, const int* desc, int n, int n_factored = 0); bool :target:`wideTileProductAvailable`(); template void :ref:`subtractTileProduct`(Target&& out, const Left& left, const Right& right); } // namespace canonical .. _details-namespacegpr_1_1linalg_1_1canonical: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Typedefs -------- .. index:: pair: typedef; AlignedMap .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a63676a872bd6630e9acc143a524ec10e: .. ref-code-block:: cpp :class: doxyrest-title-code-block typedef Eigen::Map AlignedMap A packed tile of an :ref:`AlignedBuffer `, typed as :ref:`AlignedTile::map() `. Global Variables ---------------- .. index:: pair: variable; kExactMinColumns .. _doxid-namespacegpr_1_1linalg_1_1canonical_1af2f115ab672fbbacc11d26381a1a0d2b: .. ref-code-block:: cpp :class: doxyrest-title-code-block int kExactMinColumns = 32 Solves T X = B in place (X overwrites B) for a tiled triangular T. T is read on its stored triangle only. For :ref:`Triangle::Lower ` the tile rows are visited in ascending order (forward substitution) and for :ref:`Triangle::Upper ` in descending order (back substitution). When lower_rhs is true, B holds a matrix whose tiles above the tile diagonal are zero and only tiles on or below the diagonal of X are computed; this halves the work for the inverse. Collective over the grid. T and B share the block size of their descriptors; B has n rows and ncols columns. Right-hand sides from which a substitution step takes its update from one Scheme II product; narrower solves use the fixed-order kernel. Compared with the global column count, so the choice does not follow the grid. .. index:: pair: variable; kTransposeBatchEntries .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a96eba5be0b464fc222a22fe56b52a8fc: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::int64_t kTransposeBatchEntries = std::int64_t{1}<<24 Entries of one message batch of the factor transpose: 2^24 doubles (128 MiB), at least one tile. Global Functions ---------------- .. index:: pair: function; choleskyPanelGroup .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a376c6d7ad8ec96c1efd7f04b67917627: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::atomic& choleskyPanelGroup() Panels the tile Cholesky factors before it applies them, together, to the trailing tiles. Every tile still receives the updates of the panels one at a time in ascending order, so the factor does not depend on this count; a trailing tile is loaded and stored once per group instead of once per panel. Substitution uses the same group count to amortize its tile copies while preserving the order of every update. .. index:: pair: function; requireWorkspaceBudget .. _doxid-namespacegpr_1_1linalg_1_1canonical_1aee06d6f1d95ceeb2a60471216f31681b: .. ref-code-block:: cpp :class: doxyrest-title-code-block void requireWorkspaceBudget(:ref:`DistributedState`& st, const char* what, std::int64_t needed, :ref:`AvailableMemory` available) All ranks refuse a workspace when any rank lacks its local share. No peer can enter the following data exchange after another rank throws. .. index:: pair: function; transposeWorkspaceBytes .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a59aa717e9c271daa28ed697e5facc68e: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::int64_t transposeWorkspaceBytes(const int* desc, int local_cols, std::int64_t batch_entries) Bytes transposeFactor claims beyond the factor: the transposed factor (the local array of desc) and one send and one receive batch. .. index:: pair: function; transposeFactor .. _doxid-namespacegpr_1_1linalg_1_1canonical_1af6eff4ad37103a5ebf6569a43873264c: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::vector transposeFactor(:ref:`DistributedState`& st, const double* L, const int* desc, int n, std::int64_t batch_entries = 0) Returns U = L^T in the tile layout of L: tile (i, k) of U is the transpose of tile (k, i) of L. Only the lower triangle of L is read. Collective. Tiles move between each pair of ranks in batches of at most batch_entries (kTransposeBatchEntries when zero), so the workspace beyond U is two batches rather than a copy of every tile sent and received. Before U is allocated, U and the batches are compared with this rank's share of the node's available memory; a shortfall throws std::runtime_error naming both, in place of an allocation the OOM killer ends mid-run. .. index:: pair: function; trsmLowerFactor .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a78199a3ad9eb619f32344e8484a3b4cc: .. ref-code-block:: cpp :class: doxyrest-title-code-block void trsmLowerFactor(:ref:`DistributedState`& st, const double* L, const int* desc_l, double* B, const int* desc_b, int n, int ncols, bool transpose) Solves L X = B (transpose == false) or L^T X = B (transpose == true) in place for the lower Cholesky factor L in the block-cyclic layout. .. index:: pair: function; trsmCachedLowerFactor .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a0055603ce4fe87ba41d121eda5715c8d: .. ref-code-block:: cpp :class: doxyrest-title-code-block void trsmCachedLowerFactor(:ref:`DistributedState`& st, double* B, const int* desc_b, int n, int ncols, bool transpose) Same as trsmLowerFactor for the factor cached in st: the transposed factor is built once per factorization and reused by every back substitution. .. index:: pair: function; trsmLowerFactorCached .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a1e60eb40c4c7608d4b2543cfc5e1e9c9: .. ref-code-block:: cpp :class: doxyrest-title-code-block void trsmLowerFactorCached(:ref:`DistributedState`& st, :ref:`SubstitutionCache`& cache, const double* L, const int* desc_l, double* B, const int* desc_b, int n, int ncols, bool transpose) Solves L X = B (transpose == false) or L^T X = B in place for a factor that outlives the call, reusing the transposed factor kept in cache. .. index:: pair: function; solveLowerFactorCached .. _doxid-namespacegpr_1_1linalg_1_1canonical_1aea942df3b09611e63ebac5b7279d262f: .. ref-code-block:: cpp :class: doxyrest-title-code-block void solveLowerFactorCached(:ref:`DistributedState`& st, :ref:`SubstitutionCache`& cache, const double* L, const int* desc_l, double* B, const int* desc_b, int n, int ncols) Solves L L^T X = B in place against a cached factor. .. index:: pair: function; gramTiles .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a39ea998a41511ed1e6bc9ea2834c86cc: .. ref-code-block:: cpp :class: doxyrest-title-code-block Eigen::MatrixXd gramTiles(const Eigen::MatrixXd& x, int nb) Gram matrix X^T X of a replicated matrix, accumulated over row tiles in ascending order with one dense product per (column tile, column tile, row tile). Every rank evaluates it from identical data in the same order, so the bits do not depend on the process grid that produced X. .. index:: pair: function; solveLowerFactor .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a1a97fa9b46bf89e4ea0c176e047df63d: .. ref-code-block:: cpp :class: doxyrest-title-code-block void solveLowerFactor(:ref:`DistributedState`& st, const double* L, const int* desc_l, double* B, const int* desc_b, int n, int ncols) Solves L L^T X = B in place: forward substitution with L, then back substitution with the transposed factor, which is built once. .. index:: pair: function; choleskyInverseLower .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a8138ffa3c555f7236eee5e9edd36ddde: .. ref-code-block:: cpp :class: doxyrest-title-code-block void choleskyInverseLower(:ref:`DistributedState`& st, const double* L, const int* desc, int n, std::vector& inverse, std::optional upper = std::nullopt) Overwrites inverse with K^{-1} = L^{-T} L^{-1} on and below the tile diagonal (tiles above the diagonal hold zero), in the layout of desc. L is the lower Cholesky factor in the same layout; upper, when given, is its transpose from transposeFactor, which is otherwise built and dropped. Cache presence is independent of the local pointer: a rank with no matrix columns has an empty cached transpose and can pass an engaged null pointer. .. index:: pair: function; extendBorder .. _doxid-namespacegpr_1_1linalg_1_1canonical_1ae08d1dcb02cd5bed8d0ed9ca34644a55: .. ref-code-block:: cpp :class: doxyrest-title-code-block void extendBorder(:ref:`DistributedState`& st, const :ref:`DistributedState::TileCommunicators`& comms, const :ref:`TileGeometry`& g, double* A, int lld, int n, int first_new, int tiles) Brings the border tiles (tile rows from first_new on) of a partly factored matrix to the state they have in a right-looking factorization after the panel steps 0 .. first_new - 1: every border tile (i, j) with j < first_new holds L_ij, and every border tile (i1, i2) with i2 >= first_new has received the updates of those panels, in ascending panel order. The tiles of the factored block move once, to the process rows that own border tiles, in place of a broadcast of every panel to every rank. Collective. .. index:: pair: function; exactOuterWidth .. _doxid-namespacegpr_1_1linalg_1_1canonical_1ad4a55222233d5b2903eb869831cb8422: .. ref-code-block:: cpp :class: doxyrest-title-code-block int exactOuterWidth() Width, in matrix rows, of the outer blocks of the exact factorization. The trailing update of one outer block is one Scheme II product with this inner dimension, which amortizes the residue reconstruction. The value depends on nothing but the environment, never on the grid. .. index:: pair: function; potrfLowerExact .. _doxid-namespacegpr_1_1linalg_1_1canonical_1aaad860801b0fd8648670f5814f235409: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool potrfLowerExact(:ref:`DistributedState`& st, const :ref:`schemeii::Context`& ctx, double* A, const int* desc, int n, int n_factored) potrfLower with exact Scheme II trailing products and fixed-order panel kernels. Outer blocks of :ref:`exactOuterWidth() ` / nb tiles: inside an outer block the panel is factored right-looking tile by tile (fixed-order diagonal Cholesky, panel solve and inner updates); the rest of the trailing matrix receives one exact product A_ij -= L_iB L_jB^T per outer block B. Every tile receives the same operations in the same order on every grid that shares nb, and with n_factored > 0 the border rows receive exactly the operations of a factorization of the whole matrix. .. index:: pair: function; potrfLower .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a7b234d935f508cae6ed1fb7a952e1d39: .. ref-code-block:: cpp :class: doxyrest-title-code-block bool potrfLower(:ref:`DistributedState`& st, double* A, const int* desc, int n, int n_factored = 0) Cholesky factorization of the lower triangle of the tiled symmetric positive definite matrix A, in place: on success the lower triangle holds L with A = L L^T. Right-looking tile algorithm: the diagonal tile is factored by one rank, the panel is solved tile by tile, and each trailing tile receives its updates in ascending panel order from whole-tile products. Collective. Returns false, on every rank, when a diagonal tile is not positive definite. When n_factored > 0 (a multiple of the block size) the leading n_factored x n_factored block already holds its factor, and the rows below it hold the unfactored border; the call extends the factor to order n. Every tile then receives the same updates in the same order as in a factorization of the whole matrix. .. index:: pair: function; subtractTileProduct .. _doxid-namespacegpr_1_1linalg_1_1canonical_1a74d64854c716d0ba4d094abc4a3b03a4: .. ref-code-block:: cpp :class: doxyrest-title-code-block template void subtractTileProduct(Target&& out, const Left& left, const Right& right) Subtract a dense product from a column-major tile. Full packed operands support a strided result; partial or strided operands use :ref:`Eigen `.