Tensor Tiling Library
 
Loading...
Searching...
No Matches
p/opencl/TTL_async_work_group_copy_3D3D.h
Go to the documentation of this file.
1/* OpenCL built-in library: async_work_group_copy()
2
3 Copyright (c) 2018 pocl developers
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal
7 in the Software without restriction, including without limitation the rights
8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 copies of the Software, and to permit persons to whom the Software is
10 furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE.
22*/
23
24/**
25 * @brief async_work_group_copy_3D3D is not supported by all OpenCL drivers
26 *
27 * This is an implementation that can be included by defining TTL_COPY_3D
28 */
29__attribute__((overloadable)) event_t async_work_group_copy_3D3D(
30 __local void *const dst, size_t dst_offset, const __global void *const src, size_t src_offset,
31 size_t num_bytes_per_element, size_t num_elements_per_line, size_t num_lines, size_t num_planes,
32 size_t src_total_line_length, size_t src_total_plane_spacing, size_t dst_total_line_length,
33 size_t dst_total_plane_spacing, event_t event) {
34 for (size_t plane = 0; plane < num_planes; plane++) {
35 const __global uchar *src_ptr =
36 src + ((src_offset + (src_total_plane_spacing * plane)) * num_bytes_per_element);
37 __local uchar *dst_ptr = dst + ((dst_offset + (dst_total_plane_spacing * plane)) * num_bytes_per_element);
38
39 for (size_t line = 0; line < num_lines; line++) {
40 async_work_group_copy(dst_ptr, src_ptr, num_bytes_per_element * num_elements_per_line, event);
41
42 src_ptr += src_total_line_length * num_bytes_per_element;
43 dst_ptr += dst_total_line_length * num_bytes_per_element;
44 }
45 }
46
47 return event;
48}
49
50/**
51 * @brief async_work_group_copy_3D3D is not supported by all OpenCL drivers
52 *
53 * This is an implementation that can be included by defining TTL_COPY_3D
54 */
55__attribute__((overloadable)) event_t async_work_group_copy_3D3D(
56 __global void *const dst, size_t dst_offset, const __local void *const src, size_t src_offset,
57 size_t num_bytes_per_element, size_t num_elements_per_line, size_t num_lines, size_t num_planes,
58 size_t src_total_line_length, size_t src_total_plane_spacing, size_t dst_total_line_length,
59 size_t dst_total_plane_spacing, event_t event) {
60 for (size_t plane = 0; plane < num_planes; plane++) {
61 const __local uchar *src_ptr = src + ((src_offset + (src_total_plane_spacing * plane)) * num_bytes_per_element);
62 __global uchar *dst_ptr = dst + ((dst_offset + (dst_total_plane_spacing * plane)) * num_bytes_per_element);
63
64 for (size_t line = 0; line < num_lines; line++) {
65 async_work_group_copy(dst_ptr, src_ptr, num_bytes_per_element * num_elements_per_line, event);
66
67 src_ptr += src_total_line_length * num_bytes_per_element;
68 dst_ptr += dst_total_line_length * num_bytes_per_element;
69 }
70 }
71
72 return event;
73}
#define __global
The opencl __global namespace is not supported in C.
#define __local
The opencl __local namespace is not supported in C.
unsigned char uchar
OpenCL supports uchar so provide the same in c.
unsigned char event_t
event_t is not supported, so provide a harmless placeholder
event_t async_work_group_copy_3D3D(__local void *const dst, size_t dst_offset, const __global void *const src, size_t src_offset, size_t num_bytes_per_element, size_t num_elements_per_line, size_t num_lines, size_t num_planes, size_t src_total_line_length, size_t src_total_plane_spacing, size_t dst_total_line_length, size_t dst_total_plane_spacing, event_t event)
async_work_group_copy_3D3D is not supported by all OpenCL drivers