numerics
Loading...
Searching...
No Matches
matrix.cpp File Reference

Matrix constructors, GPU lifecycle, and backend dispatch for matrix ops. More...

#include "core/matrix.hpp"
#include "core/parallel/cuda_ops.hpp"
#include <algorithm>
#include "backends/seq/impl.hpp"
#include "backends/blas/impl.hpp"
#include "backends/omp/impl.hpp"
#include "backends/gpu/impl.hpp"
#include "backends/simd/impl.hpp"

Go to the source code of this file.

Namespaces

namespace  num
 

Functions

void num::matmul (const Matrix &A, const Matrix &B, Matrix &C, Backend b=default_backend)
 C = A * B.
 
void num::matvec (const Matrix &A, const Vector &x, Vector &y, Backend b=default_backend)
 y = A * x
 
void num::matadd (real alpha, const Matrix &A, real beta, const Matrix &B, Matrix &C, Backend b=default_backend)
 C = alpha*A + beta*B.
 
void num::matmul_blocked (const Matrix &A, const Matrix &B, Matrix &C, idx block_size=64)
 C = A * B (cache-blocked)
 
void num::matmul_register_blocked (const Matrix &A, const Matrix &B, Matrix &C, idx block_size=64, idx reg_size=4)
 C = A * B (register-blocked)
 
void num::matmul_simd (const Matrix &A, const Matrix &B, Matrix &C, idx block_size=64)
 C = A * B (SIMD-accelerated)
 
void num::matvec_simd (const Matrix &A, const Vector &x, Vector &y)
 y = A * x (SIMD-accelerated)
 

Detailed Description

Matrix constructors, GPU lifecycle, and backend dispatch for matrix ops.

Adding a new backend:

  1. Add the enumerator to enum class Backend in include/core/policy.hpp
  2. Create src/core/backends/<name>/ with impl.hpp and matrix.cpp
  3. Add case Backend::<name>: to each switch below
  4. Register the .cpp in cmake/sources.cmake

Definition in file matrix.cpp.