StarPU Handbook
starpu_opencl.h
Go to the documentation of this file.
1/* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2010-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4 *
5 * StarPU is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation; either version 2.1 of the License, or (at
8 * your option) any later version.
9 *
10 * StarPU is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 *
14 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
15 */
16
17#ifndef __STARPU_OPENCL_H__
18#define __STARPU_OPENCL_H__
19
20#include <starpu_config.h>
21#ifdef STARPU_USE_OPENCL
22#ifndef CL_TARGET_OPENCL_VERSION
23#define CL_TARGET_OPENCL_VERSION 100
24#endif
25#ifdef __APPLE__
26#include <OpenCL/cl.h>
27#else
28#include <CL/cl.h>
29#endif
30#include <assert.h>
31
32#ifdef __cplusplus
33extern "C"
34{
35#endif
36
47{
50};
51
61void starpu_opencl_get_context(int devid, cl_context *context);
62
66void starpu_opencl_get_device(int devid, cl_device_id *device);
67
72void starpu_opencl_get_queue(int devid, cl_command_queue *queue);
73
77void starpu_opencl_get_current_context(cl_context *context);
78
83void starpu_opencl_get_current_queue(cl_command_queue *queue);
84
103int starpu_opencl_set_kernel_args(cl_int *err, cl_kernel *kernel, ...);
104
132void starpu_opencl_load_program_source(const char *source_file_name, char *located_file_name, char *located_dir_name, char *opencl_program_source);
133
139void starpu_opencl_load_program_source_malloc(const char *source_file_name, char **located_file_name, char **located_dir_name, char **opencl_program_source);
140
149int starpu_opencl_compile_opencl_from_file(const char *source_file_name, const char *build_options);
150
159int starpu_opencl_compile_opencl_from_string(const char *opencl_program_source, const char *file_name, const char *build_options);
160
167int starpu_opencl_load_binary_opencl(const char *kernel_id, struct starpu_opencl_program *opencl_programs);
168
172int starpu_opencl_load_opencl_from_file(const char *source_file_name, struct starpu_opencl_program *opencl_programs, const char *build_options);
176int starpu_opencl_load_opencl_from_string(const char *opencl_program_source, struct starpu_opencl_program *opencl_programs, const char *build_options);
177
182
195int starpu_opencl_load_kernel(cl_kernel *kernel, cl_command_queue *queue, struct starpu_opencl_program *opencl_programs, const char *kernel_name, int devid);
196
200int starpu_opencl_release_kernel(cl_kernel kernel);
201
216int starpu_opencl_collect_stats(cl_event event);
217
229const char *starpu_opencl_error_string(cl_int status);
230
236void starpu_opencl_display_error(const char *func, const char *file, int line, const char *msg, cl_int status);
237
243#define STARPU_OPENCL_DISPLAY_ERROR(status) starpu_opencl_display_error(__starpu_func__, __FILE__, __LINE__, NULL, status)
244
248static __starpu_inline void starpu_opencl_report_error(const char *func, const char *file, int line, const char *msg, cl_int status)
249{
250 starpu_opencl_display_error(func, file, line, msg, status);
251 assert(0);
252}
253
259#define STARPU_OPENCL_REPORT_ERROR(status) starpu_opencl_report_error(__starpu_func__, __FILE__, __LINE__, NULL, status)
260
265#define STARPU_OPENCL_REPORT_ERROR_WITH_MSG(msg, status) starpu_opencl_report_error(__starpu_func__, __FILE__, __LINE__, msg, status)
266
271cl_int starpu_opencl_allocate_memory(int devid, cl_mem *addr, size_t size, cl_mem_flags flags);
272
285cl_int starpu_opencl_copy_ram_to_opencl(void *ptr, unsigned src_node, cl_mem buffer, unsigned dst_node, size_t size, size_t offset, cl_event *event, int *ret);
286
299cl_int starpu_opencl_copy_opencl_to_ram(cl_mem buffer, unsigned src_node, void *ptr, unsigned dst_node, size_t size, size_t offset, cl_event *event, int *ret);
300
313cl_int starpu_opencl_copy_opencl_to_opencl(cl_mem src, unsigned src_node, size_t src_offset, cl_mem dst, unsigned dst_node, size_t dst_offset, size_t size, cl_event *event, int *ret);
314
325cl_int starpu_opencl_copy_async_sync(uintptr_t src, size_t src_offset, unsigned src_node, uintptr_t dst, size_t dst_offset, unsigned dst_node, size_t size, cl_event *event);
326
331#ifdef __cplusplus
332}
333#endif
334
335#endif /* STARPU_USE_OPENCL */
336
337#endif /* __STARPU_OPENCL_H__ */
cl_program programs[STARPU_MAXOPENCLDEVS]
Definition: starpu_opencl.h:49
cl_int starpu_opencl_copy_opencl_to_opencl(cl_mem src, unsigned src_node, size_t src_offset, cl_mem dst, unsigned dst_node, size_t dst_offset, size_t size, cl_event *event, int *ret)
int starpu_opencl_compile_opencl_from_file(const char *source_file_name, const char *build_options)
static __starpu_inline void starpu_opencl_report_error(const char *func, const char *file, int line, const char *msg, cl_int status)
Definition: starpu_opencl.h:248
#define STARPU_MAXOPENCLDEVS
Definition: starpu_config.h:223
int starpu_opencl_load_kernel(cl_kernel *kernel, cl_command_queue *queue, struct starpu_opencl_program *opencl_programs, const char *kernel_name, int devid)
cl_int starpu_opencl_allocate_memory(int devid, cl_mem *addr, size_t size, cl_mem_flags flags)
cl_int starpu_opencl_copy_opencl_to_ram(cl_mem buffer, unsigned src_node, void *ptr, unsigned dst_node, size_t size, size_t offset, cl_event *event, int *ret)
int starpu_opencl_load_opencl_from_file(const char *source_file_name, struct starpu_opencl_program *opencl_programs, const char *build_options)
int starpu_opencl_release_kernel(cl_kernel kernel)
void starpu_opencl_get_context(int devid, cl_context *context)
void starpu_opencl_load_program_source(const char *source_file_name, char *located_file_name, char *located_dir_name, char *opencl_program_source)
const char * starpu_opencl_error_string(cl_int status)
int starpu_opencl_set_kernel_args(cl_int *err, cl_kernel *kernel,...)
void starpu_opencl_get_queue(int devid, cl_command_queue *queue)
void starpu_opencl_get_device(int devid, cl_device_id *device)
int starpu_opencl_load_binary_opencl(const char *kernel_id, struct starpu_opencl_program *opencl_programs)
cl_int starpu_opencl_copy_async_sync(uintptr_t src, size_t src_offset, unsigned src_node, uintptr_t dst, size_t dst_offset, unsigned dst_node, size_t size, cl_event *event)
int starpu_opencl_load_opencl_from_string(const char *opencl_program_source, struct starpu_opencl_program *opencl_programs, const char *build_options)
cl_int starpu_opencl_copy_ram_to_opencl(void *ptr, unsigned src_node, cl_mem buffer, unsigned dst_node, size_t size, size_t offset, cl_event *event, int *ret)
void starpu_opencl_display_error(const char *func, const char *file, int line, const char *msg, cl_int status)
int starpu_opencl_unload_opencl(struct starpu_opencl_program *opencl_programs)
void starpu_opencl_get_current_queue(cl_command_queue *queue)
int starpu_opencl_compile_opencl_from_string(const char *opencl_program_source, const char *file_name, const char *build_options)
void starpu_opencl_get_current_context(cl_context *context)
void starpu_opencl_load_program_source_malloc(const char *source_file_name, char **located_file_name, char **located_dir_name, char **opencl_program_source)
int starpu_opencl_collect_stats(cl_event event)
Definition: starpu_opencl.h:47