80 #define CL_CHECK(res) \ 81 {if (res != CL_SUCCESS) {fprintf(stderr,"Error \"%s\" (%d) in file %s on line %d\n", \ 82 get_error_string(res), res, __FILE__,__LINE__); abort();}} 126 const char **kernel_names, cl_kernel **kernels);
220 void (*cleanup_merge)(
void *data);
227 void (*callback_cpu)(
void *data);
229 void (*callback_gpu)(
void *data);
231 size_t (*getsize_task)(
void *data);
234 void (*split_task)(
void *data,
void ***splits,
uint *n);
236 void (*cleanup_task)(
void *data);
294 void (*merge_tasks)(
ptaskgroup tg,
void **data),
295 void (*cleanup_merge)(
void *data),
296 void (*distribute_results)(
ptaskgroup tg,
void *data),
297 void (*close_taskgroup)(
ptaskgroup tg),
void (*callback_cpu)(
void *data),
298 void (*callback_gpu)(
void *data),
size_t (*getsize_task)(
void *data),
299 void (*split_task)(
void *data,
void ***split,
uint *n),
300 void (*cleanup_task)(
void *data),
void *data);
359 #define SCHEDULE_OPENCL(cpu_threads, gpu_threads, func, ...) \ 360 _Pragma("omp parallel num_threads(2)") \ 362 start_scheduler(cpu_threads, gpu_threads); \ 363 if (omp_get_thread_num() == 0) { \ cl_uint num_platforms
Number of OpenCL platforms that will be used for computations.
Definition: opencl.h:47
ptaskgroup next
Definition: opencl.h:212
task * ptask
Abbreviation for a pointer to a struct _task.
Definition: opencl.h:151
taskgroup * ptaskgroup
Abbreviation for a pointer to a struct _taskgroup.
Definition: opencl.h:176
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.
void del_taskgroup(ptaskgroup tg)
Delete a taskgroup object.
void get_opencl_devices(cl_device_id **devices, cl_uint *ndevices)
Retrieve an array of available OpenCL devices.
void add_taskgroup_to_scheduler(ptaskgroup tg)
Enqueues a full taskgroup to the execution queue of the scheduler.
void * data
Definition: opencl.h:163
ptask new_ocltask(void *data, ptask next)
Create a new task.
unsigned uint
Unsigned integer type.
Definition: settings.h:70
Simple representation of a task.
Definition: opencl.h:161
ptask tasks
Definition: opencl.h:206
cl_uint num_contexts
Number of OpenCL contexts that will be used.
Definition: opencl.h:59
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.
size_t max_package_size
Definition: opencl.h:68
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 in...
#define HEADER_PREFIX
Prefix for function declarations.
Definition: settings.h:43
ptask next
Definition: opencl.h:165
void del_ocltask(ptaskgroup tg, ptask t)
Delete a task.
Structure that contains basic OpenCL objects for arbitrary computations.
Definition: opencl.h:45
cl_uint num_devices
Number of OpenCL devices the will be used.
Definition: opencl.h:55
const char * get_error_string(cl_int error)
Returns a string corresponding to the error code error.
task_affinity
This enum specifies the affinity of exceution of a taskgroup.
Definition: opencl.h:132
cl_platform_id * platforms
This array contains all OpenCL platform-ids that will be used.
Definition: opencl.h:49
size_t size
Definition: opencl.h:208
cl_platform_id * devplatforms
Just a temporary array of OpenCL platform-ids that is used in between the calls of get_opencl_devices...
Definition: opencl.h:53
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...
cl_uint queues_per_device
This values determines the number of queues that will be created per device.
Definition: opencl.h:64
cl_command_queue * queues
Array of all queues for all devices that will be used.
Definition: opencl.h:66
void * data
Definition: opencl.h:214
struct _ocl ocl_system
Global variable that contains basic OpenCL objects for arbitrary computations.
A collection of tasks for the same callback function.
Definition: opencl.h:204
task_affinity affinity
Definition: opencl.h:210
cl_device_id * devices
Array of OpenCl devices that will be used.
Definition: opencl.h:57
cl_context * contexts
Array of OpenCL contexts that will be used.
Definition: opencl.h:61
void stop_scheduler()
Stop the task scheduler.
void add_task_taskgroup(ptaskgroup *tg, void *data)
Adds a new _task to a _taskgroup.