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