H2Lib  3.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
opencl.h File Reference
#include <stdio.h>
#include <assert.h>
#include <CL/cl.h>
#include <omp.h>
#include "basic.h"

Go to the source code of this file.

Data Structures

struct  _ocl
 Structure that contains basic OpenCL objects for arbitrary computations. More...
 
struct  _task
 Simple representation of a task. More...
 
struct  _taskgroup
 A collection of tasks for the same callback function. More...
 

Macros

#define CL_CHECK(res)
 
#define SCHEDULE_OPENCL(cpu_threads, gpu_threads, func, ...)
 Macro that simplifies the use of the task scheduler. More...
 

Typedefs

typedef struct _task task
 Abbreviation for a struct _task.
 
typedef taskptask
 Abbreviation for a pointer to a struct _task.
 
typedef struct _taskgroup taskgroup
 Abbreviation for a struct _taskgroup.
 
typedef taskgroupptaskgroup
 Abbreviation for a pointer to a struct _taskgroup.
 

Enumerations

enum  task_affinity { CPU_ONLY, GPU_ONLY, CPU_FIRST, GPU_FIRST }
 This enum specifies the affinity of exceution of a taskgroup. More...
 

Functions

void get_opencl_devices (cl_device_id **devices, cl_uint *ndevices)
 Retrieve an array of available OpenCL devices. More...
 
void set_opencl_devices (cl_device_id *devices, cl_uint ndevices, cl_uint queues_per_device)
 Set an array of OpenCL devices to be used for computations. More...
 
const char * get_error_string (cl_int error)
 Returns a string corresponding to the error code error. More...
 
void setup_kernels (const char *src_str, const uint num_kernels, const char **kernel_names, cl_kernel **kernels)
 Reads a file specified by filename and compiles all OpenCL kernels given by the array kernel_names into OpenCL kernels kernels. More...
 
ptask new_ocltask (void *data, ptask next)
 Create a new task. More...
 
void del_ocltask (ptaskgroup tg, ptask t)
 Delete a task. More...
 
ptaskgroup new_ocltaskgroup (task_affinity affinity, ptaskgroup next, void(*merge_tasks)(ptaskgroup tg, void **data), void(*cleanup_merge)(void *data), void(*distribute_results)(ptaskgroup tg, void *data), void(*close_taskgroup)(ptaskgroup tg), void(*callback_cpu)(void *data), void(*callback_gpu)(void *data), size_t(*getsize_task)(void *data), void(*split_task)(void *data, void ***split, uint *n), void(*cleanup_task)(void *data), void *data)
 Create a new list of tasks with the same code to execute. More...
 
void del_taskgroup (ptaskgroup tg)
 Delete a taskgroup object. More...
 
void add_task_taskgroup (ptaskgroup *tg, void *data)
 Adds a new _task to a _taskgroup. More...
 
void add_taskgroup_to_scheduler (ptaskgroup tg)
 Enqueues a full taskgroup to the execution queue of the scheduler. More...
 
void start_scheduler (uint cpu_threads, uint gpu_threads)
 Starts the task scheduler with cpu_threads Threads on the CPU and gpu_threads on the GPU. More...
 
void stop_scheduler ()
 Stop the task scheduler. More...
 

Variables

struct _ocl ocl_system
 Global variable that contains basic OpenCL objects for arbitrary computations.
 

Detailed Description

Author
Sven Christophersen
Date
2015