69 lines
2.1 KiB
Markdown
69 lines
2.1 KiB
Markdown
# Step 2: PARDISO Linear Solver
|
|
|
|
## 읽어야 할 파일
|
|
|
|
- `/AGENTS.md`
|
|
- `/docs/PRD.md`
|
|
- `/docs/ARCHITECTURE.md`
|
|
- `/docs/ADR.md`
|
|
- `/cmake/FesaDependencies.cmake`
|
|
- `/include/fesa/assembly/symmetric_csr.hpp`
|
|
- `/include/fesa/core/diagnostic.hpp`
|
|
|
|
## 작업
|
|
|
|
MKL PARDISO를 RAII adapter 뒤에 격리하고 symmetric positive-definite reduced system을
|
|
푼다.
|
|
|
|
```cpp
|
|
struct LinearSolveResult final {
|
|
std::vector<double> solution;
|
|
double relative_residual;
|
|
std::vector<Diagnostic> diagnostics;
|
|
};
|
|
class LinearSolver {
|
|
public:
|
|
virtual ~LinearSolver() = default;
|
|
[[nodiscard]] virtual LinearSolveResult solve(
|
|
const SymmetricCsr&,
|
|
std::span<const double> rhs) = 0;
|
|
};
|
|
class PardisoLinearSolver final : public LinearSolver {
|
|
public:
|
|
PardisoLinearSolver();
|
|
~PardisoLinearSolver() override;
|
|
PardisoLinearSolver(const PardisoLinearSolver&) = delete;
|
|
PardisoLinearSolver& operator=(const PardisoLinearSolver&) = delete;
|
|
[[nodiscard]] LinearSolveResult solve(
|
|
const SymmetricCsr&,
|
|
std::span<const double>) override;
|
|
};
|
|
```
|
|
|
|
- 3x3 SPD, repeated solve, invalid CSR, dimension mismatch, singular matrix를 먼저
|
|
테스트한다.
|
|
- `mtype=2`, LP64 index, `iparm[34]=1`, matrix checker, analysis/factor/solve/release
|
|
phase를 사용한다.
|
|
- analysis/factor/solve/release의 모든 MKL 오류를 solver diagnostic으로 변환한다.
|
|
|
|
## Acceptance Criteria
|
|
|
|
```powershell
|
|
cmake --build --preset windows-debug
|
|
ctest --preset windows-debug -R "Pardiso|LinearSolver" --output-on-failure
|
|
ctest --preset windows-debug --output-on-failure
|
|
```
|
|
|
|
## 검증 절차
|
|
|
|
1. adapter test의 link/behavior 실패를 확인한다.
|
|
2. 모든 MKL handle/workspace를 RAII로 해제한다.
|
|
3. 해와 상대잔차를 독립 계산으로 확인한다.
|
|
4. 전체 테스트와 index를 갱신한다.
|
|
|
|
## 금지사항
|
|
|
|
- MKL 타입을 `LinearSolver` public contract에 노출하지 마라. 이유: backend 격리다.
|
|
- singular system을 임의 regularization하지 마라. 이유: 모델 오류를 숨긴다.
|
|
- PARDISO 실행 중 TBB task를 중첩하지 마라. 이유: oversubscription 정책 위반이다.
|