numerics
Loading...
Searching...
No Matches
cuda_stubs.cpp
Go to the documentation of this file.
2#include <stdexcept>
3
4namespace num::cuda {
5
6[[noreturn]] static void no_cuda() {
7 throw std::runtime_error("CUDA not available");
8}
9
10real* alloc(idx) { no_cuda(); }
11void free(real*) { no_cuda(); }
12void to_device(real*, const real*, idx) { no_cuda(); }
13void to_host(real*, const real*, idx) { no_cuda(); }
14void scale(real*, idx, real) { no_cuda(); }
15void add(const real*, const real*, real*, idx) { no_cuda(); }
16void axpy(real, const real*, real*, idx) { no_cuda(); }
17real dot(const real*, const real*, idx) { no_cuda(); }
18void matvec(const real*, const real*, real*, idx, idx) { no_cuda(); }
19void matmul(const real*, const real*, real*, idx, idx, idx) { no_cuda(); }
20void thomas_batched(const real*, const real*, const real*, const real*, real*, idx, idx) { no_cuda(); }
21
22} // namespace num::cuda
CUDA kernel wrappers.
void to_device(real *dst, const real *src, idx n)
Copy host to device.
void scale(real *v, idx n, real alpha)
v = alpha * v
void thomas_batched(const real *a, const real *b, const real *c, const real *d, real *x, idx n, idx batch_size)
Batched Thomas algorithm for tridiagonal systems.
void matmul(const real *A, const real *B, real *C, idx m, idx k, idx n)
C = A * B.
void free(real *ptr)
Free device memory.
real * alloc(idx n)
Allocate device memory.
void to_host(real *dst, const real *src, idx n)
Copy device to host.
void add(const real *x, const real *y, real *z, idx n)
z = x + y
void axpy(real alpha, const real *x, real *y, idx n)
y = alpha*x + y
real dot(const real *x, const real *y, idx n)
dot product
void matvec(const real *A, const real *x, real *y, idx rows, idx cols)
y = A * x (row-major A)
double real
Definition types.hpp:10
constexpr T ipow(T x) noexcept
Compute x^N at compile time via repeated squaring.
std::size_t idx
Definition types.hpp:11