diff options
-rw-r--r-- | bicgstab.c | 11 | ||||
-rw-r--r-- | bicgstab.h | 2 | ||||
-rw-r--r-- | pssolve.c | 2 |
3 files changed, 8 insertions, 7 deletions
@@ -31,11 +31,11 @@ #include "bicgstab.h" #include "common.h" -#define BICGSTAB_MAXITER 16 #define BICGSTAB_TOL (1e-15) struct BiCGStabContext { int N; + int maxiter; double *x; double *p, *v, *y, *z, *t; @@ -164,7 +164,7 @@ static int solve_cl(BiCGStabContext *ctx, rho_prev = rho; } - if (i == BICGSTAB_MAXITER) + if (i == ctx->maxiter) return -1; clEnqueueReadBuffer(ocl_q, ctx->cl_x, 1, 0, sizeof(double) * N, @@ -200,7 +200,7 @@ static int solve_sw(BiCGStabContext *ctx, memcpy(res0, res, N * sizeof(*res0)); memcpy(p, res, N * sizeof(*p)); - for (i = 0; i < BICGSTAB_MAXITER; i++) { + for (i = 0; i < ctx->maxiter; i++) { rho = cblas_ddot(N, res, 1, res0, 1); if (i) { @@ -239,7 +239,7 @@ static int solve_sw(BiCGStabContext *ctx, rho_prev = rho; } - if (i == BICGSTAB_MAXITER) + if (i == ctx->maxiter) return -1; memcpy(x, ctx->x, sizeof(*x) * ctx->N); @@ -298,7 +298,7 @@ int tdi_bicgstab_init(BiCGStabContext *ctx, const double *k, const double *x0) return 0; } -int tdi_bicgstab_context_alloc(BiCGStabContext **pctx, int N, +int tdi_bicgstab_context_alloc(BiCGStabContext **pctx, int N, int maxiter, cl_context ocl_ctx, cl_command_queue ocl_q) { BiCGStabContext *ctx; @@ -309,6 +309,7 @@ int tdi_bicgstab_context_alloc(BiCGStabContext **pctx, int N, return -ENOMEM; ctx->N = N; + ctx->maxiter = maxiter; #if HAVE_OPENCL if (ocl_ctx) { @@ -36,7 +36,7 @@ typedef struct BiCGStabContext BiCGStabContext; * If the OpenCL context and command queue are provided (non-NULL), the solver * will run using clBLAS. */ -int tdi_bicgstab_context_alloc(BiCGStabContext **ctx, int N, +int tdi_bicgstab_context_alloc(BiCGStabContext **ctx, int N, int maxiter, cl_context ocl_ctx, cl_command_queue ocl_q); /** @@ -406,7 +406,7 @@ int tdi_pssolve_context_init(PSSolveContext *ctx) s->steps_since_inverse = INT_MAX; /* init the BiCGStab solver */ - ret = tdi_bicgstab_context_alloc(&s->bicgstab, N, ctx->ocl_ctx, ctx->ocl_queue); + ret = tdi_bicgstab_context_alloc(&s->bicgstab, N, 64, ctx->ocl_ctx, ctx->ocl_queue); if (ret < 0) return ret; |