aboutsummaryrefslogtreecommitdiff
path: root/residual_calc.h
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-04-15 21:44:14 +0200
committerAnton Khirnov <anton@khirnov.net>2024-04-15 21:44:14 +0200
commite30cfde7614be7062249954eab6c3f56eeabbb51 (patch)
tree1a27f188ed94b9ae4d566150ca951a8ac7f0fad1 /residual_calc.h
parent982d71cb08f6ccf564c0558c659ae2756bb39ba1 (diff)
residual_calc: accept all diff coefficients in a single array
Plus an offset parameter that signals the distance between different coefficients. This allows to avoid passing so many pointers around, which reduces register pressure and simplifies writing SIMD. Seems also to be a little faster.
Diffstat (limited to 'residual_calc.h')
-rw-r--r--residual_calc.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/residual_calc.h b/residual_calc.h
index 1498bc9..01ad602 100644
--- a/residual_calc.h
+++ b/residual_calc.h
@@ -68,6 +68,14 @@ int mg2di_residual_calc_init(ResidualCalcContext *ctx);
/**
* Calculate the residual.
*
+ * @param diff_coeffs Array containing all PDE coefficients.
+ * @param diff_coeffs_stride Distance between adjacent lines for a given PDE
+ * coefficient.
+ * @param diff_coeffs_offset Distance between blocks containing different PDE
+ * coefficients. I.e. diff_coeffs[i * diff_coeffs_offset + j * diff_coeffs_stride + k]
+ * is the value of the i-th PDE coefficient (MG2D_DIFF_COEFF_*) at the
+ * (j, k)th gridpoint.
+ *
* @param reflect Flags indicating if dst should be extended by reflection.
* If the 'MG2D_BOUNDARY_x'th bit is set in reflect, then dst should be
* reflected reflect_dist points beyond its bounds in the corresponding
@@ -79,8 +87,8 @@ int mg2di_residual_calc(ResidualCalcContext *ctx, size_t size[2],
double *dst, ptrdiff_t dst_stride,
const double *u, ptrdiff_t u_stride,
const double *rhs, ptrdiff_t rhs_stride,
- const double * const diff_coeffs[MG2D_DIFF_COEFF_NB],
- ptrdiff_t diff_coeffs_stride,
+ const double *diff_coeffs, ptrdiff_t diff_coeffs_stride,
+ ptrdiff_t diff_coeffs_offset,
double u_mult, double res_mult,
int reflect, size_t reflect_dist);