StarPU Internal Handbook
driver_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 __DRIVER_OPENCL_H__
18 #define __DRIVER_OPENCL_H__
19 
22 #ifndef _GNU_SOURCE
23 #define _GNU_SOURCE 1
24 #endif
25 
26 #ifdef STARPU_USE_OPENCL
27 
28 #define CL_TARGET_OPENCL_VERSION 100
29 #ifdef __APPLE__
30 #include <OpenCL/cl.h>
31 #else
32 #include <CL/cl.h>
33 #endif
34 #endif
35 
36 #include <core/workers.h>
37 #include <datawizard/node_ops.h>
38 
39 #if defined(STARPU_USE_OPENCL) || defined(STARPU_SIMGRID)
41 void _starpu_opencl_discover_devices(struct _starpu_machine_config *config);
42 
43 unsigned _starpu_opencl_get_device_count(void);
44 void _starpu_opencl_init(void);
45 void *_starpu_opencl_worker(void *);
46 extern struct _starpu_node_ops _starpu_driver_opencl_node_ops;
47 #else
48 #define _starpu_opencl_discover_devices(config) ((void) (config))
49 #endif
50 
51 #ifdef STARPU_USE_OPENCL
52 extern struct _starpu_driver_ops _starpu_driver_opencl_ops;
53 extern char *_starpu_opencl_program_dir;
54 
55 int _starpu_run_opencl(struct _starpu_worker *);
56 int _starpu_opencl_driver_init(struct _starpu_worker *);
57 int _starpu_opencl_driver_run_once(struct _starpu_worker *);
58 int _starpu_opencl_driver_deinit(struct _starpu_worker *);
59 
60 int _starpu_opencl_init_context(int devid);
61 int _starpu_opencl_deinit_context(int devid);
62 cl_device_type _starpu_opencl_get_device_type(int devid);
63 #endif
64 
65 #if 0
66 cl_int _starpu_opencl_copy_rect_opencl_to_ram(cl_mem buffer, unsigned src_node, void *ptr, unsigned dst_node, const size_t buffer_origin[3], const size_t host_origin[3],
67  const size_t region[3], size_t buffer_row_pitch, size_t buffer_slice_pitch,
68  size_t host_row_pitch, size_t host_slice_pitch, cl_event *event);
69 
70 cl_int _starpu_opencl_copy_rect_ram_to_opencl(void *ptr, unsigned src_node, cl_mem buffer, unsigned dst_node, const size_t buffer_origin[3], const size_t host_origin[3],
71  const size_t region[3], size_t buffer_row_pitch, size_t buffer_slice_pitch,
72  size_t host_row_pitch, size_t host_slice_pitch, cl_event *event);
73 #endif
74 
75 unsigned _starpu_opencl_test_request_completion(struct _starpu_async_channel *async_channel);
76 void _starpu_opencl_wait_request_completion(struct _starpu_async_channel *async_channel);
77 
78 int _starpu_opencl_copy_interface_from_opencl_to_opencl(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req);
79 int _starpu_opencl_copy_interface_from_opencl_to_cpu(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req);
80 int _starpu_opencl_copy_interface_from_cpu_to_opencl(starpu_data_handle_t handle, void *src_interface, unsigned src_node, void *dst_interface, unsigned dst_node, struct _starpu_data_request *req);
81 
82 int _starpu_opencl_copy_data_from_opencl_to_cpu(uintptr_t src, size_t src_offset, unsigned src_node, uintptr_t dst, size_t dst_offset, unsigned dst_node, size_t size, struct _starpu_async_channel *async_channel);
83 int _starpu_opencl_copy_data_from_opencl_to_opencl(uintptr_t src, size_t src_offset, unsigned src_node, uintptr_t dst, size_t dst_offset, unsigned dst_node, size_t size, struct _starpu_async_channel *async_channel);
84 int _starpu_opencl_copy_data_from_cpu_to_opencl(uintptr_t src, size_t src_offset, unsigned src_node, uintptr_t dst, size_t dst_offset, unsigned dst_node, size_t size, struct _starpu_async_channel *async_channel);
85 
86 int _starpu_opencl_is_direct_access_supported(unsigned node, unsigned handling_node);
87 uintptr_t _starpu_opencl_malloc_on_node(unsigned dst_node, size_t size, int flags);
88 void _starpu_opencl_free_on_node(unsigned dst_node, uintptr_t addr, size_t size, int flags);
89 
90 #endif // __DRIVER_OPENCL_H__
Definition: copy_driver.h:127
Definition: drivers.h:24
Definition: workers.h:359
Definition: node_ops.h:48
Definition: workers.h:70