70 lines
1.2 KiB
C
70 lines
1.2 KiB
C
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
#include "real.h"
|
||
|
#include "cl_setup.h"
|
||
|
|
||
|
#include "clccubes.h"
|
||
|
|
||
|
#include "config.h"
|
||
|
#include "logging.h"
|
||
|
|
||
|
|
||
|
int
|
||
|
ccubes_build(struct ccubes_context *ctx)
|
||
|
{
|
||
|
int rc = 0;
|
||
|
|
||
|
ctx->clctx = malloc(sizeof *ctx->clctx);
|
||
|
|
||
|
ctx->clctx->device_type = CL_DEVICE_TYPE_GPU;
|
||
|
strcpy(ctx->clctx->platform_name, "NVIDIA Corporation\0");
|
||
|
/* strcpy(ctx->clctx->platform_name, "Advanced Micro Devices, Inc.\0"); */
|
||
|
/*strcpy(ctx->clctx->platform_name, "Intel(R) Corporation\0");*/
|
||
|
rc = cl_init(ctx->clctx);
|
||
|
if (rc != CL_SUCCESS) {
|
||
|
printf("[%d] Failed to initialize the OpenCL framework\n",
|
||
|
rc);
|
||
|
goto err;
|
||
|
}
|
||
|
|
||
|
|
||
|
rc = cl_build(*ctx->clctx, CL_DEVICE_TYPE_GPU,
|
||
|
"ccubes.cl", &ctx->ccubes_program);
|
||
|
if (rc != CL_SUCCESS) {
|
||
|
log_warn("test", "Failed building ccubes.cl (%d)", rc);
|
||
|
goto err;
|
||
|
}
|
||
|
|
||
|
rc = cl_get_kern(ctx->ccubes_program, "ccubes_task",
|
||
|
&ctx->ccubes_task);
|
||
|
if (rc != CL_SUCCESS) {
|
||
|
log_warn("test", "Failed fetching ccubes_task (%d)", rc);
|
||
|
goto err;
|
||
|
}
|
||
|
|
||
|
err:
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
void
|
||
|
ccubes_clean_up(struct ccubes_context *ctx)
|
||
|
{
|
||
|
cl_clean_up(*ctx->clctx);
|
||
|
|
||
|
clReleaseProgram(ctx->ccubes_program);
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
int
|
||
|
ccubes()
|
||
|
{
|
||
|
struct ccubes_context ccubesctx;
|
||
|
|
||
|
ccubes_build(&ccubesctx);
|
||
|
|
||
|
err:
|
||
|
ccubes_clean_up(&ccubesctx);
|
||
|
}
|