Skip to content

Commit 012cf59

Browse files
authored
Added API documentation (#386)
* API overview * API overview * API overview * API overview
1 parent 435e2c1 commit 012cf59

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
This requires switching $L$ with $U$ and $P$ with $Q$ and reinterpretting them as CSR instead of CSC.
99
It is seamless from the user perspective and fixed many bugs.
1010

11-
2. Added more rigorous checks for PRs for clang formatting and to compile without warnings and memory leaks.
11+
2. Significant improvements to documentation and instructions inside and outside the code. Added general API description, including details on memory space synchronization.
1212

13-
3. Updated pull request and issue templates.
13+
3. Added more rigorous checks for PRs for clang formatting and to compile without warnings and memory leaks.
14+
15+
4. Updated pull request and issue templates.
1416

1517
### Bug Fixes
1618

1719
1. Fixed a bug that produced inaccurate results for some asymmetric matrices with major feature 1.
1820

19-
2. Synchronized devices after HIP functions. HIP executes asynchronously, so bugs occured wihout synchronization.
21+
2. Synchronized devices after HIP functions. HIP executes asynchronously, so bugs occured without synchronization.
2022

2123
3. Corrected the way cmake finds suitsparse.
2224

docs/sphinx/user_guide/index.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,52 @@ issue <https://github.com/ORNL/ReSolve/issues>`__.
145145

146146
.. |runResolve| replace:: ``runResolve``
147147
.. _runResolve: https://github.com/ORNL/ReSolve/blob/develop/runResolve
148+
149+
150+
Re::Solve General API Description
151+
---------------------------
152+
Users are encouraged to look at the examples and tests for guidance on how to use the library.
153+
When there is any conflict between the examples/tests and this documentation, the examples/tests are correct.
154+
155+
Solver Subroutines
156+
~~~~~~~~~~~~~~~~~~~~
157+
158+
For direct solvers, the following functions are provided and must be called in this order:
159+
160+
* ``analyze()`` - Performs symbolic factorization, currently only with KLU on the CPU.
161+
* ``factorize()`` - Performs numeric factorization, given a symbolic factorization.
162+
* ``refactorizationSetup()`` - Prepares for a new numeric factorization, given a new matrix with the same sparsity structure (required only if using ``refactorize()``).
163+
* ``solve()`` - Solves the linear system, given a numeric factorization.
164+
* ``refactorize()`` - Reuses the symbolic factorization to perform a new numeric factorization, given a new matrix.
165+
166+
Subsequent systems only require calls to ``refactorize()`` and ``solve()`` if the sparsity structure hasn't changed.
167+
168+
Note some examples do not reuse the factorization from the 0-th iteration because the numeric sparsity structure changes and that's how the matrices are stored. In a practical application, the sparsity structure is likely to remain the same. If it does not, it is the user's responsibility to reallocate memory and call ``analyze()`` and ``factorize()`` again. The user should enforce that symbolic nonzeros are stored explicitly, even if they are numerically zero.
169+
170+
Function Requirements
171+
~~~~~~~~~~~~~~~~~~~~
172+
173+
Functions must be used as in the examples and tests:
174+
175+
* Workspaces are required for GPU solvers. The generic workspace_type is required for backend agnostic code.
176+
* Handles are created with the ``initializeHandles()`` function and destroyed with the default destructor.
177+
* Allocate memory first, preferably with the ``ReSolve::MatrixHandler`` or ``ReSolve::VectorHandler`` classes.
178+
* Memory must be allocated before attempting to copy to it.
179+
* Solver output variables must be allocated before passing to the solver.
180+
* Use setup functions to initialize objects, where available. Do not call them more than once.
181+
* Call the set or factor functions before the corresponding reset or refactor functions.
182+
* Deallocate memory at the end.
183+
184+
Functions in ReSolve that take pointers as arguments will have the following requirements:
185+
186+
* Pointers must be valid and point to allocated memory, unless the function's use is to allocate memory.
187+
* Pointers that are not marked as const must point to memory that is writable.
188+
* Pointers that are marked as const must point to memory that is readable.
189+
190+
Memory Synchronization
191+
~~~~~~~~~~~~~~~~~~~~
192+
193+
* For CPU solvers, memory is always in sync.
194+
* For GPU solvers, the user must synchronize memory manually.
195+
* Manually call ``setUpdated()`` if you modify the contents of a ``ReSolve::MatrixHandler`` or ``ReSolve::VectorHandler`` object without using the object's member functions.
196+
* Manually call ``syncData(memspace)`` when you modify the other memory space and want them to match. Both memory spaces must be allocated.

0 commit comments

Comments
 (0)