From 3d02e1b61d6aa3e2c4c9be4e0f55dd7d2046dabb Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 14 Jun 2019 15:52:32 +0200 Subject: egs: simplify reflection boundary handling --- ell_grid_solve.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ell_grid_solve.c b/ell_grid_solve.c index 5047718..57f6340 100644 --- a/ell_grid_solve.c +++ b/ell_grid_solve.c @@ -95,7 +95,7 @@ struct EGSInternal { size_t residual_calc_size[2]; int bnd_zero[4]; - int reflect_disable[4]; + int reflect_skip; ResidualCalcContext *rescalc; @@ -177,10 +177,7 @@ static void residual_calc(EGSContext *ctx, int export_res) mg2di_timer_stop(&ctx->timer_res_calc); - priv->reflect_disable[MG2D_BOUNDARY_0L] = 1; - priv->reflect_disable[MG2D_BOUNDARY_0U] = 1; - priv->reflect_disable[MG2D_BOUNDARY_1L] = 1; - priv->reflect_disable[MG2D_BOUNDARY_1U] = 1; + priv->reflect_skip = ~0; } static void boundaries_apply_fixval(double *dst, const ptrdiff_t dst_stride[2], @@ -277,7 +274,7 @@ static void boundaries_apply(EGSContext *ctx, NDArray *a_dst, int init) } break; case MG2D_BC_TYPE_REFLECT: - if (!priv->reflect_disable[i]) { + if (!(priv->reflect_skip & (1 << i))) { mg2di_timer_start(&ctx->timer_bnd_reflect); boundaries_apply_reflect(dst, dst_strides, size_boundary); mg2di_timer_stop(&ctx->timer_bnd_reflect); @@ -387,7 +384,7 @@ static int solve_relax_step(EGSContext *ctx, int export_res) tp_execute(ctx->tp, ctx->domain_size[1], residual_add_task, ctx); mg2di_timer_stop(&r->timer_correct); - memset(priv->reflect_disable, 0, sizeof(priv->reflect_disable)); + priv->reflect_skip = 0; boundaries_apply(ctx, ctx->u, 0); } @@ -799,7 +796,7 @@ static int solve_exact(EGSContext *ctx) mg2di_timer_stop(&ec->timer_export); - memset(priv->reflect_disable, 0, sizeof(priv->reflect_disable)); + priv->reflect_skip = 0; boundaries_apply(ctx, ctx->u, 0); residual_calc(ctx, 1); @@ -954,7 +951,7 @@ finish: mg2di_timer_stop(&ctx->timer_init); if (ret >= 0) { - memset(priv->reflect_disable, 0, sizeof(priv->reflect_disable)); + priv->reflect_skip = 0; boundaries_apply(ctx, ctx->u, 1); boundaries_apply(ctx, priv->u_next, 1); -- cgit v1.2.3