From 054ae362a18ce85f22c5a87f20cfda86579d0e31 Mon Sep 17 00:00:00 2001 From: Paul Irofti Date: Fri, 28 Mar 2025 02:23:36 +0200 Subject: [PATCH] Pass value_bit_mask as constant define. Capitalize constant in kernel. --- src/CCubes.c | 1 + src/ccubes.cl | 10 +++++----- src/clccubes.c | 5 +++++ src/clccubes.h | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/CCubes.c b/src/CCubes.c index 9fd17ed..4f4d07b 100644 --- a/src/CCubes.c +++ b/src/CCubes.c @@ -236,6 +236,7 @@ SEXP CCubes(SEXP tt) { negrows, implicant_words, value_bit_width, + value_bit_mask, pichart_words, estimPI, nofvalues, diff --git a/src/ccubes.cl b/src/ccubes.cl index 1aeb52b..3145795 100644 --- a/src/ccubes.cl +++ b/src/ccubes.cl @@ -255,10 +255,10 @@ ccubes_task(int k, int value = ON_set[tempk[c] * POSROWS + frows[f]]; tempc[c] = value + 1; - int word_index = tempk[c] / (BITS_PER_WORD / value_bit_width); - int bit_index = (tempk[c] % (BITS_PER_WORD / value_bit_width)) * value_bit_width; + int word_index = tempk[c] / (BITS_PER_WORD / VALUE_BIT_WIDTH); + int bit_index = (tempk[c] % (BITS_PER_WORD / VALUE_BIT_WIDTH)) * VALUE_BIT_WIDTH; - fixed_bits[word_index] |= (value_bit_mask << bit_index); + fixed_bits[word_index] |= (VALUE_BIT_MASK << bit_index); value_bits[word_index] |= ((unsigned int)value << bit_index); } @@ -281,7 +281,7 @@ ccubes_task(int k, for (int w = 0; w < IMPLICANT_WORDS; w++) { // If the new PI has values on positions outside the existing PI’s fixed positions, it’s not a subset - unsigned int index_mask = p_implicants_pos[i * implicant_words + w]; + unsigned int index_mask = p_implicants_pos[i * IMPLICANT_WORDS + w]; if ((fixed_bits[w] & index_mask) != index_mask) { is_subset = false; @@ -289,7 +289,7 @@ ccubes_task(int k, } // then compare the value bits, if one or more values on those positions are different, it’s not a subset - if ((value_bits[w] & index_mask) != (p_implicants_val[i * implicant_words + w] & index_mask)) { + if ((value_bits[w] & index_mask) != (p_implicants_val[i * IMPLICANT_WORDS + w] & index_mask)) { is_subset = false; break; } diff --git a/src/clccubes.c b/src/clccubes.c index c4c6aee..3d132a8 100644 --- a/src/clccubes.c +++ b/src/clccubes.c @@ -70,6 +70,7 @@ ccubes_init(struct ccubes_context *ctx, int negrows, int implicant_words, int value_bit_width, + int value_bit_mask, int pichart_words, int estimPI ) @@ -82,6 +83,7 @@ ccubes_init(struct ccubes_context *ctx, ctx->negrows = negrows; ctx->implicant_words = implicant_words; ctx->value_bit_width = value_bit_width; + ctx->value_bit_mask = value_bit_mask; ctx->pichart_words = pichart_words; ctx->estimPI = estimPI; @@ -113,6 +115,7 @@ ccubes_preprocess(struct ccubes_context *ctx) fprintf(fp, "#define NEGROWS %d\n", ctx->negrows); fprintf(fp, "#define IMPLICANT_WORDS %d\n", ctx->implicant_words); fprintf(fp, "#define VALUE_BIT_WIDTH %d\n", ctx->value_bit_width); + fprintf(fp, "#define VALUE_BIT_MASK %d\n", ctx->value_bit_mask); fprintf(fp, "#define PICHART_WORDS %d\n", ctx->pichart_words); fprintf(fp, "#endif\n"); @@ -412,6 +415,7 @@ ccubes_do_tasks(struct ccubes_context *ccubesctx, int negrows, int implicant_words, int value_bit_width, + int value_bit_mask, int pichart_words, int estimPI, int *nofvalues, /* IN: RC */ @@ -439,6 +443,7 @@ ccubes_do_tasks(struct ccubes_context *ccubesctx, negrows, implicant_words, value_bit_width, + value_bit_mask, pichart_words, estimPI); if (ccubesctx == NULL) { diff --git a/src/clccubes.h b/src/clccubes.h index dbda0c0..3b976db 100644 --- a/src/clccubes.h +++ b/src/clccubes.h @@ -43,6 +43,7 @@ struct ccubes_context { int negrows; int implicant_words; int value_bit_width; + int value_bit_mask; int pichart_words; int estimPI; @@ -86,6 +87,7 @@ ccubes_do_tasks(struct ccubes_context *ccubesctx, int negrows, int implicant_words, int value_bit_width, + int value_bit_mask, int pichart_words, int estimPI, int *nofvalues, /* IN: RC */