StarPU Handbook

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
starpu_opencl.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2010-2013 Université de Bordeaux 1
4 * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
5 *
6 * StarPU is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or (at
9 * your option) any later version.
10 *
11 * StarPU is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 *
15 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
16 */
17
18 #ifndef __STARPU_OPENCL_H__
19 #define __STARPU_OPENCL_H__
20
21 #include <starpu_config.h>
22 #ifdef STARPU_USE_OPENCL
23 #ifdef __APPLE__
24 #include <OpenCL/cl.h>
25 #else
26 #include <CL/cl.h>
27 #endif
28 #include <assert.h>
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34
35 const char *starpu_opencl_error_string(cl_int status);
36 void starpu_opencl_display_error(const char *func, const char *file, int line, const char *msg, cl_int status);
37 #define STARPU_OPENCL_DISPLAY_ERROR(status) \
38 starpu_opencl_display_error(__starpu_func__, __FILE__, __LINE__, NULL, status)
39
40 static __starpu_inline void starpu_opencl_report_error(const char *func, const char *file, int line, const char *msg, cl_int status)
41 {
42 starpu_opencl_display_error(func, file, line, msg, status);
43 assert(0);
44 }
45 #define STARPU_OPENCL_REPORT_ERROR(status) \
46 starpu_opencl_report_error(__starpu_func__, __FILE__, __LINE__, NULL, status)
47
48 #define STARPU_OPENCL_REPORT_ERROR_WITH_MSG(msg, status) \
49 starpu_opencl_report_error(__starpu_func__, __FILE__, __LINE__, msg, status)
50
51 struct starpu_opencl_program
52 {
53 cl_program programs[STARPU_MAXOPENCLDEVS];
54 };
55
56 void starpu_opencl_get_context(int devid, cl_context *context);
57 void starpu_opencl_get_device(int devid, cl_device_id *device);
58 void starpu_opencl_get_queue(int devid, cl_command_queue *queue);
59 void starpu_opencl_get_current_context(cl_context *context);
60 void starpu_opencl_get_current_queue(cl_command_queue *queue);
61
62 void starpu_opencl_load_program_source(const char *source_file_name, char *located_file_name, char *located_dir_name, char *opencl_program_source);
63 int starpu_opencl_compile_opencl_from_file(const char *source_file_name, const char *build_options);
64 int starpu_opencl_compile_opencl_from_string(const char *opencl_program_source, const char *file_name, const char *build_options);
65
66 int starpu_opencl_load_binary_opencl(const char *kernel_id, struct starpu_opencl_program *opencl_programs);
67
68 int starpu_opencl_load_opencl_from_file(const char *source_file_name, struct starpu_opencl_program *opencl_programs, const char *build_options);
69 int starpu_opencl_load_opencl_from_string(const char *opencl_program_source, struct starpu_opencl_program *opencl_programs, const char *build_options);
70 int starpu_opencl_unload_opencl(struct starpu_opencl_program *opencl_programs);
71
72 int starpu_opencl_load_kernel(cl_kernel *kernel, cl_command_queue *queue, struct starpu_opencl_program *opencl_programs, const char *kernel_name, int devid);
73 int starpu_opencl_release_kernel(cl_kernel kernel);
74
75 int starpu_opencl_collect_stats(cl_event event);
76
77 int starpu_opencl_set_kernel_args(cl_int *err, cl_kernel *kernel, ...);
78
79 cl_int starpu_opencl_allocate_memory(cl_mem *addr, size_t size, cl_mem_flags flags);
80
81 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);
82
83 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);
84
85 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);
86
87 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);
88
89 #ifdef __cplusplus
90 }
91 #endif
92
93 #endif /* STARPU_USE_OPENCL */
94 #endif /* __STARPU_OPENCL_H__ */
95
starpu_opencl_copy_opencl_to_opencl
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)
starpu_opencl_get_current_context
void starpu_opencl_get_current_context(cl_context *context)
starpu_opencl_load_kernel
int starpu_opencl_load_kernel(cl_kernel *kernel, cl_command_queue *queue, struct starpu_opencl_program *opencl_programs, const char *kernel_name, int devid)
starpu_opencl_program::programs
cl_program programs[STARPU_MAXOPENCLDEVS]
Definition: starpu_opencl.h:53
starpu_opencl_release_kernel
int starpu_opencl_release_kernel(cl_kernel kernel)
starpu_opencl_set_kernel_args
int starpu_opencl_set_kernel_args(cl_int *err, cl_kernel *kernel,...)
starpu_opencl_load_opencl_from_file
int starpu_opencl_load_opencl_from_file(const char *source_file_name, struct starpu_opencl_program *opencl_programs, const char *build_options)
starpu_opencl_copy_opencl_to_ram
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)
starpu_opencl_load_binary_opencl
int starpu_opencl_load_binary_opencl(const char *kernel_id, struct starpu_opencl_program *opencl_programs)
starpu_opencl_error_string
const char * starpu_opencl_error_string(cl_int status)
starpu_opencl_load_opencl_from_string
int starpu_opencl_load_opencl_from_string(const char *opencl_program_source, struct starpu_opencl_program *opencl_programs, const char *build_options)
starpu_opencl_copy_async_sync
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)
starpu_opencl_compile_opencl_from_file
int starpu_opencl_compile_opencl_from_file(const char *source_file_name, const char *build_options)
starpu_opencl_unload_opencl
int starpu_opencl_unload_opencl(struct starpu_opencl_program *opencl_programs)
starpu_opencl_copy_ram_to_opencl
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)
starpu_opencl_get_current_queue
void starpu_opencl_get_current_queue(cl_command_queue *queue)
starpu_opencl_report_error
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:40
starpu_opencl_get_context
void starpu_opencl_get_context(int devid, cl_context *context)
starpu_opencl_compile_opencl_from_string
int starpu_opencl_compile_opencl_from_string(const char *opencl_program_source, const char *file_name, const char *build_options)
starpu_opencl_load_program_source
void starpu_opencl_load_program_source(const char *source_file_name, char *located_file_name, char *located_dir_name, char *opencl_program_source)
starpu_opencl_display_error
void starpu_opencl_display_error(const char *func, const char *file, int line, const char *msg, cl_int status)
starpu_opencl_allocate_memory
cl_int starpu_opencl_allocate_memory(cl_mem *addr, size_t size, cl_mem_flags flags)
starpu_config.h
starpu_opencl_get_queue
void starpu_opencl_get_queue(int devid, cl_command_queue *queue)
STARPU_MAXOPENCLDEVS
#define STARPU_MAXOPENCLDEVS
Definition: starpu_config.h:73
starpu_opencl_get_device
void starpu_opencl_get_device(int devid, cl_device_id *device)
starpu_opencl_collect_stats
int starpu_opencl_collect_stats(cl_event event)
starpu_opencl_program
Definition: starpu_opencl.h:51