Pass value_bit_mask as constant define. Capitalize constant in kernel.

This commit is contained in:
Paul Irofti 2025-03-28 02:23:36 +02:00
parent 909f1fdef5
commit 054ae362a1
4 changed files with 13 additions and 5 deletions

View file

@ -236,6 +236,7 @@ SEXP CCubes(SEXP tt) {
negrows,
implicant_words,
value_bit_width,
value_bit_mask,
pichart_words,
estimPI,
nofvalues,

View file

@ -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 PIs fixed positions, its 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, its 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;
}

View file

@ -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) {

View file

@ -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 */