#include "cl_alloc.h"
#include "cl_utils.h"
#include "CL/cl.h"
-#include "gen/program.h"
+#include "gen/gbe_program.h"
#include <stdio.h>
#include <string.h>
cl_kernel_get_name(const cl_kernel k)
{
if (UNLIKELY(k == NULL)) return NULL;
- return GenKernelGetName(k->gen_kernel);
+ return gbe_kernel_get_name(k->opaque);
}
LOCAL void
cl_kernel_get_simd_width(const cl_kernel k)
{
assert(k != NULL);
- return GenKernelGetSIMDWidth(k->gen_kernel);
+ return gbe_kernel_get_simd_width(k->opaque);
}
LOCAL void
-cl_kernel_setup(cl_kernel k, const struct GenKernel *gen_kernel)
+cl_kernel_setup(cl_kernel k, gbe_kernel opaque)
{
cl_context ctx = k->program->ctx;
cl_buffer_mgr bufmgr = cl_context_get_bufmgr(ctx);
/* Allocate the gen code here */
- const uint32_t code_sz = GenKernelGetCodeSize(gen_kernel);
- const char *code = GenKernelGetCode(gen_kernel);
+ const uint32_t code_sz = gbe_kernel_get_code_size(opaque);
+ const char *code = gbe_kernel_get_code(opaque);
k->bo = cl_buffer_alloc(bufmgr, "CL kernel", code_sz, 64u);
/* Upload the code */
cl_buffer_subdata(k->bo, 0, code_sz, code);
- k->gen_kernel = gen_kernel;
+ k->opaque = opaque;
}
LOCAL cl_kernel
TRY_ALLOC_NO_ERR (to, CALLOC(struct _cl_kernel));
to->bo = from->bo;
to->const_bo = from->const_bo;
- to->gen_kernel = from->gen_kernel;
+ to->opaque = from->opaque;
to->ref_n = 1;
to->magic = CL_MAGIC_KERNEL_HEADER;
to->program = from->program;
cl_uint i;
for (i = 0; i < wk_dim; ++i) {
- const uint32_t required_sz = GenKernelGetRequiredWorkGroupSize(ker->gen_kernel, i);
+ const uint32_t required_sz = gbe_kernel_get_required_work_group_size(ker->opaque, i);
if (required_sz != 0 && required_sz != local_wk_sz[i]) {
err = CL_INVALID_WORK_ITEM_SIZE;
goto error;
#include "cl_defs.h"
#include "cl_internals.h"
#include "cl_driver.h"
+#include "gen/gbe_program.h"
#include "CL/cl.h"
#include <stdint.h>
#include <stdlib.h>
/* This is the kernel as it is interfaced by the compiler */
-struct GenKernel;
+struct _gbe_kernel;
/*! One OCL function */
struct _cl_kernel {
- uint64_t magic; /* To identify it as a kernel */
- volatile int ref_n; /* We reference count this object */
- cl_buffer bo; /* The code itself */
- cl_buffer const_bo; /* Buffer for all __constants values in the OCL program */
- cl_program program; /* Owns this structure (and pointers) */
- const struct GenKernel *gen_kernel; /* (Opaque) compiler structure for the OCL kernel */
- uint8_t ref_its_program; /* True only for the user kernel (created by clCreateKernel) */
+ uint64_t magic; /* To identify it as a kernel */
+ volatile int ref_n; /* We reference count this object */
+ cl_buffer bo; /* The code itself */
+ cl_buffer const_bo; /* Buffer for all __constants values in the OCL program */
+ cl_program program; /* Owns this structure (and pointers) */
+ gbe_kernel opaque; /* (Opaque) compiler structure for the OCL kernel */
+ uint8_t ref_its_program; /* True only for the user kernel (created by clCreateKernel) */
};
/* Allocate an empty kernel */
/* Destroy and deallocate an empty kernel */
extern void cl_kernel_delete(cl_kernel);
-/* Setup the kernel with the given Gen Kernel */
-extern void cl_kernel_setup(cl_kernel k, const struct GenKernel *gen_kernel);
+/* Setup the kernel with the given GBE Kernel */
+extern void cl_kernel_setup(cl_kernel k, gbe_kernel opaque);
/* Get the kernel name */
extern const char *cl_kernel_get_name(const cl_kernel k);
#include "cl_utils.h"
#include "CL/cl.h"
#include "CL/cl_intel.h"
-#include "gen/program.h"
+#include "gen/gbe_program.h"
#include <stdio.h>
#include <stdlib.h>
cl_context_delete(p->ctx);
/* Free the program as allocated by the compiler */
- if (p->gen_program) GenProgramDelete(p->gen_program);
+ if (p->opaque) gbe_program_delete(p->opaque);
p->magic = CL_MAGIC_DEAD_HEADER; /* For safety */
cl_free(p);
cl_int err = CL_SUCCESS;
uint32_t i;
- assert(p->gen_program != NULL);
- p->ker_n = GenProgramGetKernelNum(p->gen_program);
+ assert(p->opaque != NULL);
+ p->ker_n = gbe_program_get_kernel_num(p->opaque);
/* Allocate the kernel array */
TRY_ALLOC (p->ker, CALLOC_ARRAY(cl_kernel, p->ker_n));
for (i = 0; i < p->ker_n; ++i) {
- const GenKernel *gen_kernel = GenProgramGetKernel(p->gen_program, i);
- assert(gen_kernel != NULL);
+ const gbe_kernel opaque = gbe_program_get_kernel(p->opaque, i);
+ assert(opaque != NULL);
TRY_ALLOC (p->ker[i], cl_kernel_new(p));
- cl_kernel_setup(p->ker[i], gen_kernel);
+ cl_kernel_setup(p->ker[i], opaque);
}
error:
program = cl_program_new(ctx);
- program->gen_program = GenProgramNewFromLLVM(file_name, 0, NULL, NULL);
- if (program->gen_program == NULL) {
+ program->opaque = gbe_program_new_from_llvm(file_name, 0, NULL, NULL);
+ if (program->opaque == NULL) {
err = CL_INVALID_PROGRAM;
goto error;
}
#define __CL_PROGRAM_H__
#include "cl_internals.h"
+#include "gen/gbe_program.h"
#include "CL/cl.h"
#include <stdint.h>
#include <stdlib.h>
// This is the structure ouput by the compiler
-struct GenProgram;
+struct _gbe_program;
/* This maps an OCL file containing some kernels */
struct _cl_program {
- uint64_t magic; /* To identify it as a program */
- volatile int ref_n; /* We reference count this object */
- struct GenProgram *gen_program; /* Program as ouput by the compiler */
- cl_kernel *ker; /* All kernels included by the OCL file */
- cl_program prev, next; /* We chain the programs together */
- cl_context ctx; /* Its parent context */
- char *bin; /* The program copied verbatim */
- size_t bin_sz; /* Its size in memory */
- uint32_t ker_n; /* Number of declared kernels */
- uint32_t from_source:1; /* Built from binary or source? */
- uint32_t is_built:1; /* Did we call clBuildProgram on it? */
+ uint64_t magic; /* To identify it as a program */
+ volatile int ref_n; /* We reference count this object */
+ gbe_program opaque; /* (Opaque) program as ouput by the compiler */
+ cl_kernel *ker; /* All kernels included by the OCL file */
+ cl_program prev, next; /* We chain the programs together */
+ cl_context ctx; /* Its parent context */
+ char *bin; /* The program copied verbatim */
+ size_t bin_sz; /* Its size in memory */
+ uint32_t ker_n; /* Number of declared kernels */
+ uint32_t from_source:1; /* Built from binary or source? */
+ uint32_t is_built:1; /* Did we call clBuildProgram on it? */
};
/* Create a empty program */