ccubes-cl/src/clccubes.h

114 lines
2.7 KiB
C
Raw Normal View History

2025-03-26 11:50:07 +02:00
/*
* Copyright (c) 2025 Paul Irofti <paul@irofti.net>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
2025-03-20 19:32:25 +02:00
#ifndef CLccubes_H__
#define CLccubes_H__
2025-03-26 11:35:52 +02:00
#include <stdbool.h>
2025-03-20 19:32:25 +02:00
#include "cl_setup.h"
#ifndef _MSC_VER
#include <stdint.h>
#else
#include <stdint_msvc.h>
#endif
#define ROW_DIM 0
#define COL_DIM 1
struct ccubes_context {
struct cl_uctx *clctx;
2025-03-21 18:52:41 +02:00
cl_program ccubes_program;
2025-03-20 19:32:25 +02:00
cl_kernel ccubes_task;
/* internal memory sizes */
int k;
int ninputs;
int posrows;
int negrows;
int implicant_words;
int value_bit_width;
int value_bit_mask;
int pichart_words;
2025-03-26 11:41:28 +02:00
int estimPI;
/* INPUTS */
cl_mem nofvalues;
cl_mem ON_set;
cl_mem OFF_set;
cl_mem p_implicants_pos;
cl_mem p_implicants_val;
cl_mem last_index;
cl_mem p_covered;
cl_mem p_pichart_pos;
/* OUTPUTS */
cl_mem coverage;
cl_mem fixed_bits;
cl_mem value_bits;
cl_mem pichart_values;
/* Host outputs */
bool *h_coverage;
unsigned int *h_fixed_bits;
unsigned int *h_value_bits;
unsigned int *h_pichart_values;
/* ND-Range */
size_t gws; /* global work size */
2025-03-26 15:15:57 +02:00
size_t goff; /* global offset */
2025-03-20 19:32:25 +02:00
};
struct ccubes_context *
ccubes_create();
int
ccubes_do_tasks(struct ccubes_context *ccubesctx,
int n_tasks,
2025-03-26 12:59:48 +02:00
int n_tasks_off,
int k,
2025-03-26 11:41:28 +02:00
int ninputs,
int posrows,
int negrows,
int implicant_words,
int value_bit_width,
int value_bit_mask,
2025-03-26 11:41:28 +02:00
int pichart_words,
int estimPI,
2025-03-26 15:15:57 +02:00
int *nofvalues, /* IN: RC */
int *ON_set, /* IN: RC */
int *OFF_set, /* IN: RC */
2025-03-26 11:41:28 +02:00
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 */
);
2025-03-21 18:52:41 +02:00
void
ccubes_clean_up(struct ccubes_context *ctx);
void
ccubes_destroy(struct ccubes_context *ctx);
2025-03-20 19:32:25 +02:00
#endif