Return ccubes context for output manipulation.
This commit is contained in:
parent
33d410c81e
commit
5f3d3074a3
4 changed files with 70 additions and 21 deletions
49
src/CCubes.c
49
src/CCubes.c
|
@ -45,8 +45,15 @@ SEXP CCubes(SEXP tt) {
|
|||
double elapsed_time;
|
||||
|
||||
config_set_int("log", LOG_LEVEL_WARN);
|
||||
config_set_int("log:ccubes", LOG_LEVEL_WARN);
|
||||
config_set_int("cl", LOG_LEVEL_DEBUG);
|
||||
config_set_int("log:clccubes", LOG_LEVEL_WARN);
|
||||
config_set_int("log:ccubes", LOG_LEVEL_DEBUG);
|
||||
config_set_int("log:cl", LOG_LEVEL_DEBUG);
|
||||
|
||||
char log[100] = {0};
|
||||
sprintf(log, "log-ccubes");
|
||||
config_set_string("out", log);
|
||||
|
||||
|
||||
|
||||
if (PRINT_INFO) {
|
||||
Rprintf("--- START ---\n");
|
||||
|
@ -189,12 +196,13 @@ SEXP CCubes(SEXP tt) {
|
|||
}
|
||||
|
||||
int n_tasks = 512;
|
||||
struct ccubes_context *ctx = NULL;
|
||||
for (int task = 0; task < nchoosek(ninputs, k); task+=n_tasks) {
|
||||
bool *coverage;
|
||||
unsigned int *fixed_bits;
|
||||
unsigned int *value_bits;
|
||||
unsigned int *pichart_values;
|
||||
ccubes_do_tasks(n_tasks,
|
||||
ctx = ccubes_do_tasks(n_tasks,
|
||||
task,
|
||||
k,
|
||||
ninputs,
|
||||
|
@ -217,6 +225,41 @@ SEXP CCubes(SEXP tt) {
|
|||
value_bits,
|
||||
pichart_values
|
||||
);
|
||||
if (ctx == NULL) {
|
||||
log_error("ccubes", "ccubes_do_tasks failed");
|
||||
}
|
||||
|
||||
for (int i = 0; i < n_tasks; i++) {
|
||||
log_debug("ccubes", "Task %d", i);
|
||||
|
||||
log_debug_raw("ccubes", "coverage[%d]:", i);
|
||||
for (int j = 0; j < posrows; j++) {
|
||||
log_debug_raw("ccubes", " %d",
|
||||
ctx->h_coverage[i * posrows + j]);
|
||||
}
|
||||
log_debug_raw("ccubes", "\n");
|
||||
|
||||
log_debug_raw("ccubes", "fixed_bits[%d]:", i);
|
||||
for (int j = 0; j < implicant_words; j++) {
|
||||
log_debug_raw("ccubes", " %d",
|
||||
ctx->h_fixed_bits[i * implicant_words + j]);
|
||||
}
|
||||
log_debug_raw("ccubes", "\n");
|
||||
|
||||
log_debug_raw("ccubes", "value_bits[%d]:", i);
|
||||
for (int j = 0; j < implicant_words; j++) {
|
||||
log_debug_raw("ccubes", " %d",
|
||||
ctx->h_value_bits[i * implicant_words + j]);
|
||||
}
|
||||
log_debug_raw("ccubes", "\n");
|
||||
|
||||
log_debug_raw("ccubes", "pichart_values[%d]:", i);
|
||||
for (int j = 0; j < pichart_words; j++) {
|
||||
log_debug_raw("ccubes", " %d",
|
||||
ctx->h_pichart_values[i * pichart_words + j]);
|
||||
}
|
||||
log_debug_raw("ccubes", "\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _OPENMP
|
||||
|
|
|
@ -26,9 +26,8 @@
|
|||
#include "logging.h"
|
||||
|
||||
|
||||
int
|
||||
ccubes_init(struct ccubes_context *ctx,
|
||||
int n_tasks,
|
||||
struct ccubes_context *
|
||||
ccubes_init(int n_tasks,
|
||||
int n_tasks_off,
|
||||
int k,
|
||||
int ninputs,
|
||||
|
@ -41,10 +40,18 @@ ccubes_init(struct ccubes_context *ctx,
|
|||
)
|
||||
{
|
||||
int rc = 0;
|
||||
struct ccubes_context *ctx = NULL;
|
||||
|
||||
ctx = malloc(sizeof *ctx);
|
||||
if (ctx == NULL) {
|
||||
log_error("clccubes", "ctx malloc failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
ctx->clctx = malloc(sizeof *ctx->clctx);
|
||||
if (ctx->clctx == NULL) {
|
||||
log_error("clccubes", "clctx malloc failed (%d)", rc);
|
||||
log_error("clccubes", "clctx malloc failed");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -61,7 +68,7 @@ ccubes_init(struct ccubes_context *ctx,
|
|||
ctx->goff = n_tasks_off;
|
||||
|
||||
err:
|
||||
return rc;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -382,7 +389,7 @@ err:
|
|||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
struct ccubes_context *
|
||||
ccubes_do_tasks(int n_tasks,
|
||||
int n_tasks_off,
|
||||
int k,
|
||||
|
@ -408,10 +415,9 @@ ccubes_do_tasks(int n_tasks,
|
|||
)
|
||||
{
|
||||
int rc = 0;
|
||||
struct ccubes_context ccubesctx;
|
||||
struct ccubes_context *ccubesctx = NULL;
|
||||
|
||||
rc = ccubes_init(&ccubesctx,
|
||||
n_tasks,
|
||||
ccubesctx = ccubes_init(n_tasks,
|
||||
n_tasks_off,
|
||||
k,
|
||||
ninputs,
|
||||
|
@ -421,24 +427,24 @@ ccubes_do_tasks(int n_tasks,
|
|||
value_bit_width,
|
||||
pichart_words,
|
||||
estimPI);
|
||||
if (rc != 0) {
|
||||
if (ccubesctx == NULL) {
|
||||
log_error("clccubes", "ccubes_init failed (%d)", rc);
|
||||
goto err;
|
||||
}
|
||||
|
||||
rc = ccubes_preprocess(&ccubesctx);
|
||||
rc = ccubes_preprocess(ccubesctx);
|
||||
if (rc != 0) {
|
||||
log_error("clccubes", "ccubes_preprocess failed (%d)", rc);
|
||||
goto err;
|
||||
}
|
||||
|
||||
rc = ccubes_build(&ccubesctx);
|
||||
rc = ccubes_build(ccubesctx);
|
||||
if (rc != CL_SUCCESS) {
|
||||
log_error("clccubes", "ccubes_build failed (%d)", rc);
|
||||
goto err;
|
||||
}
|
||||
|
||||
rc = ccubes_alloc(&ccubesctx,
|
||||
rc = ccubes_alloc(ccubesctx,
|
||||
nofvalues,
|
||||
ON_set,
|
||||
OFF_set,
|
||||
|
@ -456,19 +462,19 @@ ccubes_do_tasks(int n_tasks,
|
|||
goto err;
|
||||
}
|
||||
|
||||
rc = ccubes_run(&ccubesctx);
|
||||
rc = ccubes_run(ccubesctx);
|
||||
if (rc != CL_SUCCESS) {
|
||||
log_error("clccubes", "ccubes_run failed (%d)", rc);
|
||||
goto err;
|
||||
}
|
||||
|
||||
rc = ccubes_map(&ccubesctx);
|
||||
rc = ccubes_map(ccubesctx);
|
||||
if (rc != CL_SUCCESS) {
|
||||
log_error("clccubes", "ccubes_map failed (%d)", rc);
|
||||
goto err;
|
||||
}
|
||||
err:
|
||||
return rc;
|
||||
return ccubesctx;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -73,7 +73,7 @@ struct ccubes_context {
|
|||
size_t goff; /* global offset */
|
||||
};
|
||||
|
||||
int
|
||||
struct ccubes_context *
|
||||
ccubes_do_tasks(int n_tasks,
|
||||
int n_tasks_off,
|
||||
int k,
|
||||
|
|
Loading…
Add table
Reference in a new issue