Compare commits

...

2 commits

Author SHA1 Message Date
158923d4e3 Fix compilation errors. 2025-03-26 11:41:28 +02:00
fb60e6a04e stdbool for bool 2025-03-26 11:35:52 +02:00
2 changed files with 67 additions and 26 deletions

View file

@ -10,6 +10,25 @@
#include "logging.h" #include "logging.h"
unsigned long int
nchoosek(int n, int k)
{
if (k == 0 || k == n) return 1;
if (k == 1) return n;
unsigned long int result = 1;
if (k > n - k) {
k = n - k;
}
for (int i = 0; i < k; i++) {
result = result * (n - i) / (i + 1);
}
return result;
}
int int
ccubes_init(struct ccubes_context *ctx, ccubes_init(struct ccubes_context *ctx,
int k, int k,
@ -114,14 +133,14 @@ err:
int int
ccubes_alloc(struct ccubes_context *ctx, ccubes_alloc(struct ccubes_context *ctx,
const real *nofvalues, /* IN: RC */ real *nofvalues, /* IN: RC */
const real *ON_set, /* IN: RC */ real *ON_set, /* IN: RC */
const real *OFF_set, /* IN: RC */ real *OFF_set, /* IN: RC */
const unsigned int *p_implicants_pos, /* IN: RC */ unsigned int *p_implicants_pos, /* IN: RC */
const unsigned int *p_implicants_val, /* IN: RC */ unsigned int *p_implicants_val, /* IN: RC */
const int *last_index, /* IN: RC */ int *last_index, /* IN: RC */
const int *p_covered, /* IN: RC */ int *p_covered, /* IN: RC */
const int *p_pichart_pos, /* IN: RC */ int *p_pichart_pos, /* IN: RC */
bool *coverage, /* OUT: RW */ bool *coverage, /* OUT: RW */
unsigned int *fixed_bits, /* OUT: RW */ unsigned int *fixed_bits, /* OUT: RW */
unsigned int *value_bits, /* OUT: RW */ unsigned int *value_bits, /* OUT: RW */
@ -276,8 +295,8 @@ ccubes_run(struct ccubes_context *ctx)
} }
rc = clEnqueueNDRangeKernel(ctx->clctx->gpu_queue, ctx->ccubes_task, rc = clEnqueueNDRangeKernel(ctx->clctx->gpu_queue, ctx->ccubes_task,
1, NULL, ctx->gws, NULL, 1, NULL, &ctx->gws, NULL,
0, NULL, &ev_ksvd[1]); 0, NULL, NULL);
if (rc != CL_SUCCESS) { if (rc != CL_SUCCESS) {
log_error("clccubes", "NDRange failed (%d)", rc); log_error("clccubes", "NDRange failed (%d)", rc);
goto err; goto err;
@ -328,7 +347,7 @@ err:
return rc; return rc;
} }
void int
ccubes_unmap(struct ccubes_context *ctx) ccubes_unmap(struct ccubes_context *ctx)
{ {
int rc = 0; int rc = 0;
@ -370,18 +389,18 @@ ccubes(int k,
int value_bit_width, int value_bit_width,
int pichart_words, int pichart_words,
int estimPI, int estimPI,
const real *nofvalues, /* IN: RC */ real *nofvalues, /* IN: RC */
const real *ON_set, /* IN: RC */ real *ON_set, /* IN: RC */
const real *OFF_set, /* IN: RC */ real *OFF_set, /* IN: RC */
const unsigned int *p_implicants_pos, /* IN: RC */ unsigned int *p_implicants_pos, /* IN: RC */
const unsigned int *p_implicants_val, /* IN: RC */ unsigned int *p_implicants_val, /* IN: RC */
const int *last_index, /* IN: RC */ int *last_index, /* IN: RC */
const int *p_covered, /* IN: RC */ int *p_covered, /* IN: RC */
const int *p_pichart_pos, /* IN: RC */ int *p_pichart_pos, /* IN: RC */
bool *coverage, /* OUT: RW */ bool *coverage, /* OUT: RW */
unsigned int *fixed_bits, /* OUT: RW */ unsigned int *fixed_bits, /* OUT: RW */
unsigned int *value_bits, /* OUT: RW */ unsigned int *value_bits, /* OUT: RW */
unsigned int *pichart_values /* OUT: RW */ unsigned int *pichart_values /* OUT: RW */
) )
{ {
int rc = 0; int rc = 0;
@ -425,8 +444,7 @@ ccubes(int k,
coverage, coverage,
fixed_bits, fixed_bits,
value_bits, value_bits,
pichart_values pichart_values);
)
if (rc != CL_SUCCESS) { if (rc != CL_SUCCESS) {
log_error("clccubes", "ccubes_alloc failed (%d)", rc); log_error("clccubes", "ccubes_alloc failed (%d)", rc);
goto err; goto err;

View file

@ -1,6 +1,8 @@
#ifndef CLccubes_H__ #ifndef CLccubes_H__
#define CLccubes_H__ #define CLccubes_H__
#include <stdbool.h>
#include "cl_setup.h" #include "cl_setup.h"
#ifndef _MSC_VER #ifndef _MSC_VER
@ -26,6 +28,7 @@ struct ccubes_context {
int implicant_words; int implicant_words;
int value_bit_width; int value_bit_width;
int pichart_words; int pichart_words;
int estimPI;
/* INPUTS */ /* INPUTS */
cl_mem nofvalues; cl_mem nofvalues;
@ -53,7 +56,27 @@ struct ccubes_context {
size_t gws; /* global work size */ size_t gws; /* global work size */
}; };
int ccubes(void); int ccubes(int k,
int ninputs,
int posrows,
int negrows,
int implicant_words,
int value_bit_width,
int pichart_words,
int estimPI,
real *nofvalues, /* IN: RC */
real *ON_set, /* IN: RC */
real *OFF_set, /* IN: RC */
unsigned int *p_implicants_pos, /* IN: RC */
unsigned int *p_implicants_val, /* IN: RC */
int *last_index, /* IN: RC */
int *p_covered, /* IN: RC */
int *p_pichart_pos, /* IN: RC */
bool *coverage, /* OUT: RW */
unsigned int *fixed_bits, /* OUT: RW */
unsigned int *value_bits, /* OUT: RW */
unsigned int *pichart_values /* OUT: RW */
);
int int
clccubes(struct ccubes_context *ccubesctx, cl_mem alpha0, cl_mem G, size_t signals, clccubes(struct ccubes_context *ccubesctx, cl_mem alpha0, cl_mem G, size_t signals,