Get the kernel from R path
This commit is contained in:
parent
17b29fb0dc
commit
9fa5f520b5
3 changed files with 21 additions and 3 deletions
|
@ -26,6 +26,7 @@ SEXP CCubes(SEXP tt) {
|
|||
// simulate the R command:
|
||||
// system.file("ccubes.cl", package = "IEEE")
|
||||
|
||||
const char *kernel_file = NULL;
|
||||
SEXP args = PROTECT(allocVector(VECSXP, 2));
|
||||
SET_VECTOR_ELT(args, 0, mkString("ccubes.cl"));
|
||||
SET_VECTOR_ELT(args, 1, mkString("IEEE"));
|
||||
|
@ -41,6 +42,7 @@ SEXP CCubes(SEXP tt) {
|
|||
));
|
||||
|
||||
Rprintf("Kernel file: '%s'\n", CHAR(STRING_ELT(r_result, 0)));
|
||||
kernel_file = CHAR(STRING_ELT(r_result, 0));
|
||||
UNPROTECT(3);
|
||||
|
||||
// 32 bits per word, in bit shifting representation
|
||||
|
@ -73,7 +75,7 @@ SEXP CCubes(SEXP tt) {
|
|||
sprintf(log, "log-ccubes");
|
||||
config_set_string("out", log);
|
||||
|
||||
struct ccubes_context *ctx = ccubes_create();
|
||||
struct ccubes_context *ctx = ccubes_create(kernel_file);
|
||||
if (ctx == NULL) {
|
||||
log_error("ccubes", "ccubes_do_tasks failed");
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
|
||||
struct ccubes_context *
|
||||
ccubes_create()
|
||||
ccubes_create(char *ccubes_kernel_file)
|
||||
{
|
||||
struct ccubes_context *ctx = NULL;
|
||||
int rc = 0;
|
||||
|
@ -56,6 +56,19 @@ ccubes_create()
|
|||
goto err;
|
||||
}
|
||||
|
||||
if (ccubes_kernel_file == NULL) {
|
||||
log_error("clccubes",
|
||||
"Kernel file pointer is NULL", ccubes_kernel_file);
|
||||
goto err;
|
||||
}
|
||||
ctx->ccubes_kernel_file = strdup(ccubes_kernel_file);
|
||||
if (ctx->ccubes_kernel_file == NULL) {
|
||||
log_error("clccubes",
|
||||
"Failed to copy kernel file path %s",
|
||||
ccubes_kernel_file);
|
||||
goto err;
|
||||
}
|
||||
|
||||
err:
|
||||
return ctx;
|
||||
}
|
||||
|
@ -134,7 +147,7 @@ ccubes_build(struct ccubes_context *ctx)
|
|||
|
||||
|
||||
rc = cl_build(*ctx->clctx, CL_DEVICE_TYPE_GPU,
|
||||
"ccubes.cl", &ctx->ccubes_program);
|
||||
ctx->ccubes_kernel_file, &ctx->ccubes_program);
|
||||
if (rc != CL_SUCCESS) {
|
||||
log_warn("clccubes", "Failed building ccubes.cl (%d)", rc);
|
||||
goto err;
|
||||
|
@ -555,6 +568,8 @@ ccubes_destroy(struct ccubes_context *ctx)
|
|||
cl_clean_up(*ctx->clctx);
|
||||
log_debug("clccubes", "cl_clean_up");
|
||||
|
||||
free(ctx->ccubes_kernel_file);
|
||||
|
||||
free(ctx);
|
||||
|
||||
return;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
struct ccubes_context {
|
||||
struct cl_uctx *clctx;
|
||||
|
||||
char *ccubes_kernel_file;
|
||||
cl_program ccubes_program;
|
||||
cl_kernel ccubes_task;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue