WIP add info about PI redundancy

This commit is contained in:
Adrian Dusa 2025-03-28 19:05:33 +02:00
parent 054ae362a1
commit fc766c7b69
4 changed files with 139 additions and 105 deletions

4
src/CCubes.c Normal file → Executable file
View file

@ -223,6 +223,7 @@ SEXP CCubes(SEXP tt) {
log_debug("ccubes", "Tasks %d - %d out of %d",
task, task + current_batch - 1, n_tasks);
// bool *redundant;
bool *coverage;
unsigned int *fixed_bits;
unsigned int *value_bits;
@ -247,6 +248,7 @@ SEXP CCubes(SEXP tt) {
last_index,
p_covered,
p_pichart_pos,
// redundant,
coverage,
fixed_bits,
value_bits,
@ -256,6 +258,8 @@ SEXP CCubes(SEXP tt) {
for (int i = 0; i < current_batch; i++) {
log_debug("ccubes", "Task %d", i);
// log_debug_raw("ccubes", "redundant[%d]: %d\n", i, ctx->h_redundant[i]);
log_debug_raw("ccubes", "coverage[%d]:", i);
for (int j = 0; j < posrows; j++) {
log_debug_raw("ccubes", " %d",

4
src/ccubes.cl Normal file → Executable file
View file

@ -92,6 +92,7 @@ nchoosek(int n, int k)
*
* OUTPUT:
* covsum - sum of coverage (reproduce on host instead?)
* // redundant (1) - read, write
* coverage (posrows x 1) - read, write
* fixed_bits (implicant_words x 1) - read, write
* value_bits (implicant_words x 1) - read, write
@ -117,6 +118,7 @@ ccubes_task(int k,
__global const int *last_index, /* IN: RC */
__global const int *p_covered, /* IN: RC */
__global const int *p_pichart_pos, /* IN: RC */
// __global bool *g_redundant, /* OUT: RW */
__global bool *g_coverage, /* OUT: RW */
__global unsigned int *g_fixed_bits, /* OUT: RW */
__global unsigned int *g_value_bits, /* OUT: RW */
@ -134,6 +136,7 @@ ccubes_task(int k,
// size_t gid = task - goffset;
size_t gid = get_global_linear_id();
// __global bool *redundant = &g_redundant[gid];
__global bool *coverage = &g_coverage[gid * POSROWS];
__global unsigned int *fixed_bits = &g_fixed_bits[gid * IMPLICANT_WORDS];
__global unsigned int *value_bits = &g_value_bits[gid * IMPLICANT_WORDS];
@ -264,6 +267,7 @@ ccubes_task(int k,
// check if the current PI is not redundant
bool redundant = false;
// redundant = false;
int i = 0;
while (i < prevfoundPI && !redundant) {

23
src/clccubes.c Normal file → Executable file
View file

@ -161,6 +161,7 @@ ccubes_alloc(struct ccubes_context *ctx,
int *last_index, /* IN: RC */
int *p_covered, /* IN: RC */
int *p_pichart_pos, /* IN: RC */
// bool *redundant, /* OUT: RW */
bool *coverage, /* OUT: RW */
unsigned int *fixed_bits, /* OUT: RW */
unsigned int *value_bits, /* OUT: RW */
@ -172,6 +173,7 @@ ccubes_alloc(struct ccubes_context *ctx,
/*
* Save outputs for mapping
*/
// ctx->h_redundant = redundant;
ctx->h_coverage = coverage;
ctx->h_fixed_bits = fixed_bits;
ctx->h_value_bits = value_bits;
@ -242,6 +244,10 @@ ccubes_alloc(struct ccubes_context *ctx,
* OUTPUTS
*/
/* __global bool *redundant, OUT: RW */
// ctx->redundant = clCreateBuffer(ctx->clctx->ctx, CL_MEM_READ_WRITE,
// ctx->gws * sizeof(bool), NULL, &rc);
/* __global bool *coverage, OUT: RW */
ctx->coverage = clCreateBuffer(ctx->clctx->ctx, CL_MEM_READ_WRITE,
ctx->gws * ctx->posrows * sizeof(bool), NULL, &rc);
@ -303,6 +309,8 @@ ccubes_run(struct ccubes_context *ctx)
sizeof(cl_mem), (void *)&ctx->p_pichart_pos);
/* OUTPUTS */
// rc |= clSetKernelArg(ctx->ccubes_task, arg++,
// sizeof(cl_mem), (void *)&ctx->redundant);
rc |= clSetKernelArg(ctx->ccubes_task, arg++,
sizeof(cl_mem), (void *)&ctx->coverage);
rc |= clSetKernelArg(ctx->ccubes_task, arg++,
@ -336,6 +344,13 @@ ccubes_map(struct ccubes_context *ctx)
{
int rc = 0;
// ctx->h_redundant = clEnqueueMapBuffer(ctx->clctx->gpu_queue,
// ctx->redundant, CL_TRUE, CL_MAP_READ, 0,
// ctx->gws * sizeof(bool), 0, NULL, NULL, &rc);
// if (rc != CL_SUCCESS) {
// log_error("clccubes", "redundant mapping failed (%d)", rc);
// goto err;
// }
ctx->h_coverage = clEnqueueMapBuffer(ctx->clctx->gpu_queue,
ctx->coverage, CL_TRUE, CL_MAP_READ, 0,
ctx->gws * ctx->posrows * sizeof(bool), 0, NULL, NULL, &rc);
@ -380,6 +395,11 @@ ccubes_unmap(struct ccubes_context *ctx)
/*
* UNMAP
*/
// rc = clEnqueueUnmapMemObject(ctx->clctx->gpu_queue, ctx->redundant,
// ctx->h_redundant, 0, NULL, NULL);
// if (rc != CL_SUCCESS) {
// log_error("clccubes", "redundant unmapping failed (%d)", rc);
// }
rc = clEnqueueUnmapMemObject(ctx->clctx->gpu_queue, ctx->coverage,
ctx->h_coverage, 0, NULL, NULL);
if (rc != CL_SUCCESS) {
@ -426,6 +446,7 @@ ccubes_do_tasks(struct ccubes_context *ccubesctx,
int *last_index, /* IN: RC */
int *p_covered, /* IN: RC */
int *p_pichart_pos, /* IN: RC */
// bool *redundant, /* OUT: RW */
bool *coverage, /* OUT: RW */
unsigned int *fixed_bits, /* OUT: RW */
unsigned int *value_bits, /* OUT: RW */
@ -472,6 +493,7 @@ ccubes_do_tasks(struct ccubes_context *ccubesctx,
last_index,
p_covered,
p_pichart_pos,
// redundant,
coverage,
fixed_bits,
value_bits,
@ -517,6 +539,7 @@ ccubes_clean_up(struct ccubes_context *ctx)
log_debug("clccubes", "clReleaseMemObject INPUTS");
/* OUTPUTS */
// clReleaseMemObject(ctx->redundant);
clReleaseMemObject(ctx->coverage);
clReleaseMemObject(ctx->fixed_bits);
clReleaseMemObject(ctx->value_bits);

3
src/clccubes.h Normal file → Executable file
View file

@ -58,12 +58,14 @@ struct ccubes_context {
cl_mem p_pichart_pos;
/* OUTPUTS */
// cl_mem redundant;
cl_mem coverage;
cl_mem fixed_bits;
cl_mem value_bits;
cl_mem pichart_values;
/* Host outputs */
// bool *h_redundant;
bool *h_coverage;
unsigned int *h_fixed_bits;
unsigned int *h_value_bits;
@ -98,6 +100,7 @@ ccubes_do_tasks(struct ccubes_context *ccubesctx,
int *last_index, /* IN: RC */
int *p_covered, /* IN: RC */
int *p_pichart_pos, /* IN: RC */
// bool *redundant, /* OUT: RW */
bool *coverage, /* OUT: RW */
unsigned int *fixed_bits, /* OUT: RW */
unsigned int *value_bits, /* OUT: RW */