ViennaLS
Loading...
Searching...
No Matches
lsOxidationBiCGSTABAbi.hpp
Go to the documentation of this file.
1// Stable C ABI exported by the ViennaLS_GPU shared library.
2//
3// The GPU BiCGSTAB solver lives in a separate shared library that links
4// against the CUDA runtime. ViennaLS itself must NOT link against CUDA, so
5// that a build with GPU support still loads on machines with no CUDA runtime
6// installed. The library is therefore opened lazily with dlopen() and these
7// symbols are resolved with dlsym() -- see lsOxidationBiCGSTABInterface.hpp.
8//
9// Everything here is deliberately plain C: opaque void* handles, no
10// references, int instead of bool. That keeps the boundary independent of
11// C++ name mangling and of the standard library, so the two sides stay
12// compatible even when built by different compilers (nvcc vs g++).
13//
14// Bump VIENNALS_GPU_ABI_VERSION on any incompatible change to the signatures
15// below; the loader refuses a library reporting a different version.
16
17#pragma once
18
19#include <cstddef>
20#include <cstdint>
21
22#define VIENNALS_GPU_ABI_VERSION 1
23
24// The exporting side (lsOxidationBiCGSTABKernels.cu) must keep these visible
25// even under -fvisibility=hidden, or dlsym() cannot find them.
26#if defined(_WIN32)
27#define VIENNALS_GPU_ABI __declspec(dllexport)
28#else
29#define VIENNALS_GPU_ABI __attribute__((visibility("default")))
30#endif
31
32extern "C" {
33
36
39VIENNALS_GPU_ABI void *viennalsGpuAllocBuffers(uint32_t n, int nFaces,
40 int useIlu0Preconditioner);
41
44
46VIENNALS_GPU_ABI int viennalsGpuIsValid(const void *handle);
47
50
53 const uint32_t *nb,
54 std::size_t count);
55
57VIENNALS_GPU_ABI int viennalsGpuSetupCSR(void *handle, const uint32_t *hNb,
58 uint32_t n, int nFaces);
59
62viennalsGpuUploadSolverArrays(void *handle, const double *diag, const double *b,
63 const double *coeff, uint32_t diagLen,
64 std::size_t coeffLen);
65
67VIENNALS_GPU_ABI int viennalsGpuUploadRhs(void *handle, const double *b,
68 uint32_t n);
69
72VIENNALS_GPU_ABI int viennalsGpuSolveBiCGSTAB(void *handle, double *x,
73 double diagEps, unsigned maxIter,
74 double tolerance,
75 unsigned *outIterations,
76 double *outResidual);
77
78} // extern "C"
#define VIENNALS_GPU_ABI
Definition lsOxidationBiCGSTABAbi.hpp:29
VIENNALS_GPU_ABI int viennalsGpuAbiVersion(void)
Returns the ABI version this library was built against.
VIENNALS_GPU_ABI int viennalsGpuUploadNeighborIds(void *handle, const uint32_t *nb, std::size_t count)
Upload the geometry-fixed neighbor-ID array; count must equal nFaces*n.
VIENNALS_GPU_ABI const char * viennalsGpuGetLastErrorMessage(void)
Human-readable detail for the last failure on this thread.
VIENNALS_GPU_ABI int viennalsGpuUploadRhs(void *handle, const double *b, uint32_t n)
Upload only the RHS vector, when the matrix geometry is already resident.
VIENNALS_GPU_ABI int viennalsGpuSetupCSR(void *handle, const uint32_t *hNb, uint32_t n, int nFaces)
Build the CSR sparsity pattern and run the cuSPARSE symbolic analysis.
VIENNALS_GPU_ABI int viennalsGpuUploadSolverArrays(void *handle, const double *diag, const double *b, const double *coeff, uint32_t diagLen, std::size_t coeffLen)
Upload per-solve arrays (diag, b, faceCoeffs) and re-factorize ILU(0).
VIENNALS_GPU_ABI int viennalsGpuSolveBiCGSTAB(void *handle, double *x, double diagEps, unsigned maxIter, double tolerance, unsigned *outIterations, double *outResidual)
Run GPU BiCGSTAB. x is the initial guess on entry, the solution on exit. Non-zero only when the solve...
VIENNALS_GPU_ABI int viennalsGpuIsValid(const void *handle)
Non-zero if the handle is valid (non-null and successfully allocated).
VIENNALS_GPU_ABI void * viennalsGpuAllocBuffers(uint32_t n, int nFaces, int useIlu0Preconditioner)
Allocate GPU buffers for n nodes and nFaces (2*D) faces. Returns nullptr if no usable CUDA device or ...
VIENNALS_GPU_ABI void viennalsGpuFreeBuffers(void *handle)
Free previously allocated buffers. Safe to call with nullptr.