diff --git a/src/CCubes.c b/src/CCubes.c index 0efc555..34af02d 100755 --- a/src/CCubes.c +++ b/src/CCubes.c @@ -205,7 +205,7 @@ SEXP CCubes(SEXP tt) { config_set_int("log", LOG_LEVEL_WARN); config_set_int("log:clccubes", LOG_LEVEL_DEBUG); config_set_int("log:ccubes", LOG_LEVEL_DEBUG); - config_set_int("log:cl", LOG_LEVEL_DEBUG); + config_set_int("log:cl", LOG_LEVEL_WARN); char log[100] = {0}; sprintf(log, "log-ccubes"); @@ -357,6 +357,7 @@ SEXP CCubes(SEXP tt) { // when needed, increase allocated memory if (foundPI / estimPI > 0.9) { + ctx->rebuild = 1; estimPI += 100000; p_pichart = R_Realloc(p_pichart, posrows * estimPI, int); p_pichart_pos = R_Realloc(p_pichart_pos, pichart_words * estimPI, unsigned int); diff --git a/src/cl_setup.c b/src/cl_setup.c index 3c77db7..8a2a3c1 100644 --- a/src/cl_setup.c +++ b/src/cl_setup.c @@ -21,7 +21,10 @@ #include "logging.h" #include "cl_setup.h" + +#if 0 #define CL_DEBUG +#endif cl_int cl_init(struct cl_uctx *puctx) diff --git a/src/clccubes.c b/src/clccubes.c index b35bda5..90fa335 100755 --- a/src/clccubes.c +++ b/src/clccubes.c @@ -110,6 +110,7 @@ ccubes_create(const char *ccubes_kernel_file, ccubes_kernel_file); goto err; } + ctx->rebuild = 1; ctx->ninputs = ninputs; ctx->posrows = posrows; @@ -192,6 +193,14 @@ ccubes_build(struct ccubes_context *ctx) { int rc = 0; + if (ctx->rebuild == 0) + return rc; + + rc = ccubes_preprocess(ctx); + if (rc != 0) { + log_error("clccubes", "ccubes_preprocess failed (%d)", rc); + goto err; + } rc = cl_build(*ctx->clctx, CL_DEVICE_TYPE_GPU, ctx->ccubes_kernel_file, &ctx->ccubes_program); @@ -207,6 +216,8 @@ ccubes_build(struct ccubes_context *ctx) goto err; } + ctx->rebuild = 0; + err: return rc; } @@ -524,12 +535,6 @@ ccubes_do_tasks(struct ccubes_context *ccubesctx, goto err; } - rc = ccubes_preprocess(ccubesctx); - if (rc != 0) { - log_error("clccubes", "ccubes_preprocess failed (%d)", rc); - goto err; - } - rc = ccubes_build(ccubesctx); if (rc != CL_SUCCESS) { log_error("clccubes", "ccubes_build failed (%d)", rc); diff --git a/src/clccubes.h b/src/clccubes.h index b9b441e..38bce43 100755 --- a/src/clccubes.h +++ b/src/clccubes.h @@ -33,6 +33,7 @@ struct ccubes_context { struct cl_uctx *clctx; + int rebuild; char *ccubes_kernel_file; cl_program ccubes_program; cl_kernel ccubes_task;