start allocating cl_mem inputs and outputs
This commit is contained in:
parent
5fc7e00341
commit
d68ee488a6
4 changed files with 95 additions and 7 deletions
2
Makefile
2
Makefile
|
@ -1,4 +1,4 @@
|
||||||
NAME = test_ompcl
|
NAME = test_ccubes
|
||||||
|
|
||||||
SRCS = $(shell find . -maxdepth 1 -type f -name '*.c')
|
SRCS = $(shell find . -maxdepth 1 -type f -name '*.c')
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
78
clccubes.c
78
clccubes.c
|
@ -43,6 +43,68 @@ ccubes_build(struct ccubes_context *ctx)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* INPUTS
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* __global const real *nofvalues, IN: RC */
|
||||||
|
ctx->nofvalues = clCreateBuffer(ctx->clctx->ctx,
|
||||||
|
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||||
|
NINPUTS * sizeof(real), nofvalues, &rc);
|
||||||
|
if (rc != CL_SUCCESS) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/* __global const real *ON_set, IN: RC */
|
||||||
|
ctx->ON_set = clCreateBuffer(ctx->clctx->ctx,
|
||||||
|
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||||
|
POSROWS * NINPUTS * sizeof(real), ON_set, &rc);
|
||||||
|
if (rc != CL_SUCCESS) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/* __global const real *OFF_set, IN: RC */
|
||||||
|
ctx->OFF_set = clCreateBuffer(ctx->clctx->ctx,
|
||||||
|
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||||
|
NINPUTS * NEGROWS * sizeof(real), OFF_set, &rc);
|
||||||
|
if (rc != CL_SUCCESS) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/* __global const unsigned int *p_implicants_pos, IN: RC */
|
||||||
|
ctx->p_implicants_pos = clCreateBuffer(ctx->clctx->ctx,
|
||||||
|
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||||
|
estimPI * IMPLICANT_WORDS * sizeof(int), p_implicants_pos, &rc);
|
||||||
|
if (rc != CL_SUCCESS) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/* __global const unsigned int *p_implicants_val, IN: RC */
|
||||||
|
ctx->p_implicants_val = clCreateBuffer(ctx->clctx->ctx,
|
||||||
|
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||||
|
estimPI * IMPLICANT_WORDS * sizeof(int), p_implicants_val, &rc);
|
||||||
|
if (rc != CL_SUCCESS) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/* __global const int *last_index, IN: RC */
|
||||||
|
ctx->last_index = clCreateBuffer(ctx->clctx->ctx,
|
||||||
|
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||||
|
POSROWS * sizeof(int), last_index, &rc);
|
||||||
|
if (rc != CL_SUCCESS) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/* __global const int *p_covered, IN: RC */
|
||||||
|
ctx->p_covered = clCreateBuffer(ctx->clctx->ctx,
|
||||||
|
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||||
|
estimPI * sizeof(int), p_covered, &rc);
|
||||||
|
if (rc != CL_SUCCESS) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
/* __global const int *p_pichart_pos, IN: RC */
|
||||||
|
ctx->p_pichart_pos = clCreateBuffer(ctx->clctx->ctx,
|
||||||
|
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||||
|
estimPI * PICHART_WORDS * sizeof(int), p_pichart_pos, &rc);
|
||||||
|
if (rc != CL_SUCCESS) {
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
err:
|
err:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +116,22 @@ ccubes_clean_up(struct ccubes_context *ctx)
|
||||||
|
|
||||||
clReleaseProgram(ctx->ccubes_program);
|
clReleaseProgram(ctx->ccubes_program);
|
||||||
|
|
||||||
|
/* INPUTS */
|
||||||
|
clReleaseMemObject(ctx->nofvalues);
|
||||||
|
clReleaseMemObject(ON_set);
|
||||||
|
clReleaseMemObject(OFF_set);
|
||||||
|
clReleaseMemObject(p_implicants_pos);
|
||||||
|
clReleaseMemObject(p_implicants_val);
|
||||||
|
clReleaseMemObject(last_index);
|
||||||
|
clReleaseMemObject(p_covered);
|
||||||
|
clReleaseMemObject(p_pichart_pos);
|
||||||
|
|
||||||
|
/* OUTPUTS */
|
||||||
|
clReleaseMemObject(coverage);
|
||||||
|
clReleaseMemObject(fixed_bits);
|
||||||
|
clReleaseMemObject(value_bits);
|
||||||
|
clReleaseMemObject(pichart_values);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
clccubes.h
16
clccubes.h
|
@ -17,6 +17,22 @@ struct ccubes_context {
|
||||||
|
|
||||||
cl_program ccubes_program;
|
cl_program ccubes_program;
|
||||||
cl_kernel ccubes_task;
|
cl_kernel ccubes_task;
|
||||||
|
|
||||||
|
/* INPUTS */
|
||||||
|
cl_mem ctx->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;
|
||||||
};
|
};
|
||||||
|
|
||||||
int ccubes(void);
|
int ccubes(void);
|
||||||
|
|
|
@ -67,8 +67,6 @@ int main(int argc, char *argv[])
|
||||||
char *program;
|
char *program;
|
||||||
|
|
||||||
struct ccubes_context ccubesctx;
|
struct ccubes_context ccubesctx;
|
||||||
cl_program ccubes_program;
|
|
||||||
|
|
||||||
|
|
||||||
/* Inputs */
|
/* Inputs */
|
||||||
|
|
||||||
|
@ -103,9 +101,5 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
err:
|
err:
|
||||||
clReleaseProgram(ccubes_program);
|
|
||||||
|
|
||||||
cl_clean_up(*ccubesctx.clctx);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue