-
Notifications
You must be signed in to change notification settings - Fork 1
Add GMRES(m) linear solver — scalar, AVX2, NEON, OMP backends (ROADMA… #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
223d61a
Add GMRES(m) linear solver — scalar, AVX2, NEON, OMP backends (ROADMA…
shaia 5b0f8d8
Clarify GMRES residual test docstring: max-norm smallness check, not …
shaia ef4c106
Reword GMRES OMP consistency docstring: "consistent" not "identical"
shaia b33919d
docs: mirror poisson_solver_method_t enum in API reference
shaia b21d0fe
docs: sync poisson_solver_params_t snippet with public header
shaia d5a5917
Merge remote-tracking branch 'origin/master' into feature/gmres-linea…
shaia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /** | ||
| * @file linear_solver_gmres_avx2.c | ||
| * @brief Restarted GMRES(m) linear solver - AVX2 + OpenMP backend | ||
| * | ||
| * Provides AVX2-specific macro definitions and includes the parameterized SIMD | ||
| * template. All algorithm logic lives in the template header. Only the O(n) | ||
| * vector primitives are vectorized; dense Givens/Hessenberg work stays scalar. | ||
| */ | ||
|
|
||
| #include "../linear_solver_internal.h" | ||
| #include "cfd/boundary/boundary_conditions.h" | ||
| #include "cfd/core/memory.h" | ||
| #include <math.h> | ||
| #include <string.h> | ||
| #include <limits.h> | ||
|
|
||
| #if defined(CFD_HAS_AVX2) && defined(CFD_ENABLE_OPENMP) | ||
| #define GMRES_HAS_AVX2 1 | ||
| #include <immintrin.h> | ||
| #include <omp.h> | ||
| #endif | ||
|
|
||
| #if defined(GMRES_HAS_AVX2) | ||
|
|
||
| //============================================================================= | ||
| // AVX2-SPECIFIC MACRO DEFINITIONS | ||
| //============================================================================= | ||
|
|
||
| #define SIMD_SUFFIX avx2 | ||
| #define SIMD_VEC __m256d | ||
| #define SIMD_WIDTH 4 | ||
|
|
||
| #define SIMD_LOAD(ptr) _mm256_loadu_pd(ptr) | ||
| #define SIMD_STORE(ptr, vec) _mm256_storeu_pd(ptr, vec) | ||
| #define SIMD_SET1(val) _mm256_set1_pd(val) | ||
| #define SIMD_SETZERO() _mm256_setzero_pd() | ||
|
|
||
| #define SIMD_ADD(a, b) _mm256_add_pd(a, b) | ||
| #define SIMD_SUB(a, b) _mm256_sub_pd(a, b) | ||
| #define SIMD_MUL(a, b) _mm256_mul_pd(a, b) | ||
| #define SIMD_FMA(a, b, c) _mm256_fmadd_pd(a, b, c) | ||
|
|
||
| /* AVX2 horizontal sum (4 doubles -> 1 double) - MSVC-compatible */ | ||
| static inline double gmres_simd_hsum_avx2(__m256d vec) { | ||
| __m128d low = _mm256_castpd256_pd128(vec); | ||
| __m128d high = _mm256_extractf128_pd(vec, 1); | ||
| __m128d sum128 = _mm_add_pd(low, high); | ||
| sum128 = _mm_hadd_pd(sum128, sum128); | ||
| return _mm_cvtsd_f64(sum128); | ||
| } | ||
|
|
||
| #define SIMD_HSUM(vec) gmres_simd_hsum_avx2(vec) | ||
|
|
||
| #include "../simd_template/linear_solver_gmres_simd_template.h" | ||
|
|
||
| #undef SIMD_SUFFIX | ||
| #undef SIMD_VEC | ||
| #undef SIMD_WIDTH | ||
| #undef SIMD_LOAD | ||
| #undef SIMD_STORE | ||
| #undef SIMD_SET1 | ||
| #undef SIMD_SETZERO | ||
| #undef SIMD_ADD | ||
| #undef SIMD_SUB | ||
| #undef SIMD_MUL | ||
| #undef SIMD_FMA | ||
| #undef SIMD_HSUM | ||
|
|
||
| #else /* !GMRES_HAS_AVX2 */ | ||
|
|
||
| /* Stub for platforms without AVX2 */ | ||
| poisson_solver_t* create_gmres_avx2_solver(void) { | ||
| return NULL; | ||
| } | ||
|
|
||
| #endif /* GMRES_HAS_AVX2 */ |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.