class gpr::linalg::schemeii::Context¶
Overview¶
#include <gpr/linalg/schemeii/SchemeII.h>
class Context {
public:
// structs
struct Impl;
// construction
Context(Options options);
Context(const Context&);
~Context();
// methods
Context& operator=(const Context&);
const Options& options() const;
std::string describe(std::int64_t k) const;
Plan plan(std::int64_t k) const;
void setThreadSource(int(*)() source);
Operand prepareRows(const double* a, std::int64_t lda, bool transpose, std::int64_t m, std::int64_t k, const Plan& plan, const int* exponents = nullptr) const;
Operand prepareColumns(const double* b, std::int64_t ldb, bool transpose, std::int64_t k, std::int64_t n, const Plan& plan, const int* exponents = nullptr) const;
void run(std::span<const Task> tasks) const;
void gemm(bool transpose_a, bool transpose_b, std::int64_t m, std::int64_t n, std::int64_t k, double alpha, const double* a, std::int64_t lda, const double* b, std::int64_t ldb, double beta, double* c, std::int64_t ldc) const;
void residues(const Task& task, std::vector<std::uint32_t>& out) const;
void reconstruct(const Plan& plan, std::span<const std::uint32_t> residues, std::span<const int> row_exponents, std::span<const int> column_exponents, std::int64_t m, std::int64_t n, double alpha, double beta, double* c, std::int64_t ldc) const;
};
Detailed Documentation¶
Methods¶
std::string describe(std::int64_t k) const
One line naming engine, provider, bits and moduli for k.
void setThreadSource(int(*)() source)
Thread count used when Options::threads is zero.
Operand prepareRows(const double* a, std::int64_t lda, bool transpose, std::int64_t m, std::int64_t k, const Plan& plan, const int* exponents = nullptr) const
Row operand from op(A) (m x k). Exponents override the row maxima.
Operand prepareColumns(const double* b, std::int64_t ldb, bool transpose, std::int64_t k, std::int64_t n, const Plan& plan, const int* exponents = nullptr) const
Column operand from op(B) (k x n).
void run(std::span<const Task> tasks) const
Runs every task; the outputs must not overlap and all tasks share k. Throws on a non-finite result.
void gemm(bool transpose_a, bool transpose_b, std::int64_t m, std::int64_t n, std::int64_t k, double alpha, const double* a, std::int64_t lda, const double* b, std::int64_t ldb, double beta, double* c, std::int64_t ldc) const
C = alpha op(A) op(B) + beta C with column-major storage. Workspace is bounded by Options::panel_bytes plus the block residues.
void residues(const Task& task, std::vector<std::uint32_t>& out) const
Residues in [0, p_t) of A’B’ for the block of a task, stored as out[t * m * n + i + j * m]. With a split inner dimension, sum these over the parts modulo p_t (exact in int64) and pass the sums to reconstruct(); prepare every part with the exponents of the whole rows and columns and the plan of the whole k.
void reconstruct(const Plan& plan, std::span<const std::uint32_t> residues, std::span<const int> row_exponents, std::span<const int> column_exponents, std::int64_t m, std::int64_t n, double alpha, double beta, double* c, std::int64_t ldc) const
C block from summed residues (see residues()).