Rebuild only when necessary.
This commit is contained in:
parent
0c46ec57fe
commit
76c637a64a
4 changed files with 17 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue