move to clccubes
This commit is contained in:
parent
e0f9c4e755
commit
5fc7e00341
3 changed files with 73 additions and 30 deletions
69
clccubes.c
Normal file
69
clccubes.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
#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);
|
||||
}
|
|
@ -15,9 +15,12 @@
|
|||
struct ccubes_context {
|
||||
struct cl_uctx *clctx;
|
||||
|
||||
cl_program ccubes_program;
|
||||
cl_kernel ccubes_task;
|
||||
};
|
||||
|
||||
int ccubes(void);
|
||||
|
||||
int
|
||||
clccubes(struct ccubes_context *ccubesctx, cl_mem alpha0, cl_mem G, size_t signals,
|
||||
size_t atoms, uint32_t sparsity, uint32_t pcoding, cl_mem gamma, cl_uint
|
||||
|
|
|
@ -99,36 +99,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
log_debug("test", "Starting ccubes...");
|
||||
|
||||
/*
|
||||
* CCubes
|
||||
*/
|
||||
ccubesctx.clctx = malloc(sizeof *ccubesctx.clctx);
|
||||
|
||||
ccubesctx.clctx->device_type = CL_DEVICE_TYPE_GPU;
|
||||
strcpy(ccubesctx.clctx->platform_name, "NVIDIA Corporation\0");
|
||||
/* strcpy(ccubesctx.clctx->platform_name, "Advanced Micro Devices, Inc.\0"); */
|
||||
/*strcpy(ccubesctx.clctx->platform_name, "Intel(R) Corporation\0");*/
|
||||
rc = cl_init(ccubesctx.clctx);
|
||||
if (rc != CL_SUCCESS) {
|
||||
printf("[%d] Failed to initialize the OpenCL framework\n",
|
||||
rc);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
rc = cl_build(*ccubesctx.clctx, CL_DEVICE_TYPE_GPU,
|
||||
"ccubes.cl", &ccubes_program);
|
||||
if (rc != CL_SUCCESS) {
|
||||
log_warn("test", "Failed building ccubes.cl (%d)", rc);
|
||||
goto err;
|
||||
}
|
||||
|
||||
rc = cl_get_kern(ccubes_program, "ccubes_task",
|
||||
&ccubesctx.ccubes_task);
|
||||
if (rc != CL_SUCCESS) {
|
||||
log_warn("test", "Failed fetching ccubes_task (%d)", rc);
|
||||
goto err;
|
||||
}
|
||||
ccubes();
|
||||
|
||||
fflush(stdout);
|
||||
err:
|
||||
|
|
Loading…
Add table
Reference in a new issue