diff --git a/clccubes.c b/clccubes.c index 9622de6..f32a67f 100644 --- a/clccubes.c +++ b/clccubes.c @@ -10,6 +10,25 @@ #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 ccubes_init(struct ccubes_context *ctx, int k, @@ -114,14 +133,14 @@ err: int ccubes_alloc(struct ccubes_context *ctx, - const real *nofvalues, /* IN: RC */ - const real *ON_set, /* IN: RC */ - const real *OFF_set, /* IN: RC */ - const unsigned int *p_implicants_pos, /* IN: RC */ - const unsigned int *p_implicants_val, /* IN: RC */ - const int *last_index, /* IN: RC */ - const int *p_covered, /* IN: RC */ - const int *p_pichart_pos, /* IN: RC */ + 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 */ @@ -276,8 +295,8 @@ ccubes_run(struct ccubes_context *ctx) } rc = clEnqueueNDRangeKernel(ctx->clctx->gpu_queue, ctx->ccubes_task, - 1, NULL, ctx->gws, NULL, - 0, NULL, &ev_ksvd[1]); + 1, NULL, &ctx->gws, NULL, + 0, NULL, NULL); if (rc != CL_SUCCESS) { log_error("clccubes", "NDRange failed (%d)", rc); goto err; @@ -328,7 +347,7 @@ err: return rc; } -void +int ccubes_unmap(struct ccubes_context *ctx) { int rc = 0; @@ -370,18 +389,18 @@ ccubes(int k, int value_bit_width, int pichart_words, int estimPI, - const real *nofvalues, /* IN: RC */ - const real *ON_set, /* IN: RC */ - const real *OFF_set, /* IN: RC */ - const unsigned int *p_implicants_pos, /* IN: RC */ - const unsigned int *p_implicants_val, /* IN: RC */ - const int *last_index, /* IN: RC */ - const int *p_covered, /* IN: RC */ - const 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 */ + 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 rc = 0; @@ -425,8 +444,7 @@ ccubes(int k, coverage, fixed_bits, value_bits, - pichart_values - ) + pichart_values); if (rc != CL_SUCCESS) { log_error("clccubes", "ccubes_alloc failed (%d)", rc); goto err; diff --git a/clccubes.h b/clccubes.h index 55b7b5a..e2542c0 100644 --- a/clccubes.h +++ b/clccubes.h @@ -28,6 +28,7 @@ struct ccubes_context { int implicant_words; int value_bit_width; int pichart_words; + int estimPI; /* INPUTS */ cl_mem nofvalues; @@ -55,7 +56,27 @@ struct ccubes_context { 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 clccubes(struct ccubes_context *ccubesctx, cl_mem alpha0, cl_mem G, size_t signals,