From e30cfde7614be7062249954eab6c3f56eeabbb51 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 15 Apr 2024 21:44:14 +0200 Subject: 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. --- residual_calc.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'residual_calc.h') 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); -- cgit v1.2.3