From 29f5b628317bcf83ddc5bfeaec92108b6bb1e89d Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 26 Jul 2020 18:39:53 +0200 Subject: Switch to external threadpool library. --- pssolve.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'pssolve.c') diff --git a/pssolve.c b/pssolve.c index 28333e2..36e09cf 100644 --- a/pssolve.c +++ b/pssolve.c @@ -28,12 +28,12 @@ #include #include +#include #include "bicgstab.h" #include "common.h" #include "log.h" #include "pssolve.h" -#include "threadpool.h" #define NB_COEFFS(eq_ctx) ((eq_ctx)->nb_coeffs[0] * (eq_ctx)->nb_coeffs[1]) #define NB_COLLOC_POINTS(eq_ctx) ((eq_ctx)->nb_colloc_points[0] * (eq_ctx)->nb_colloc_points[1]) @@ -58,8 +58,8 @@ struct PSSolvePriv { int *ipiv; double *mat; - ThreadPoolContext *tp; - ThreadPoolContext *tp_internal; + TPContext *tp; + TPContext *tp_internal; }; typedef struct ConstructMatrixThread { @@ -70,9 +70,7 @@ typedef struct ConstructMatrixThread { unsigned int var_idx; } ConstructMatrixThread; -static void construct_matrix(void *arg, - unsigned int job_idx, unsigned int nb_jobs, - unsigned int thread_idx, unsigned int nb_threads) +static void construct_matrix(void *arg, unsigned int job_idx, unsigned int thread_idx) { ConstructMatrixThread *cmt = arg; const PSEquationContext *eq_ctx = cmt->eq_ctx; @@ -192,8 +190,7 @@ int tdi_pssolve_solve(PSSolveContext *ctx, .mat_stride = s->nb_coeffs, .var_idx = j, }; - tdi_threadpool_execute(s->tp, NB_COEFFS(&s->eqs[j]), construct_matrix, - &thread); + tp_execute(s->tp, NB_COEFFS(&s->eqs[j]), construct_matrix, &thread); mat += NB_COEFFS(&s->eqs[j]) * s->nb_coeffs; } } @@ -347,7 +344,7 @@ int tdi_pssolve_context_init(PSSolveContext *ctx) if (ctx->tp) { s->tp = ctx->tp; } else { - ret = tdi_threadpool_init(&s->tp_internal, 1); + ret = tp_init(&s->tp_internal, 1); if (ret < 0) return ret; s->tp = s->tp_internal; @@ -487,7 +484,7 @@ void tdi_pssolve_context_free(PSSolveContext **pctx) free(ctx->priv->mat); tdi_bicgstab_context_free(&ctx->priv->bicgstab); - tdi_threadpool_free(&ctx->priv->tp_internal); + tp_free(&ctx->priv->tp_internal); } free(ctx->priv); -- cgit v1.2.3