Tensor Tiling Library
 
Loading...
Searching...
No Matches
c/TTL_import_export.h
Go to the documentation of this file.
1/*
2 * TTL_import_export.h
3 *
4 * Copyright (c) 2023 Mobileye
5 *
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#pragma once
20
21#include <stddef.h>
22#include <stdint.h>
23#include <stdio.h>
24#include <string.h>
25
26/**
27 * @brief TTL_event_t is a pseudonym for OpenCL event_t
28 *
29 * To allow full compatibility with OpenCL but allow other implementations to
30 * use TTL_event_t in a way that is more applicable to their platforms we
31 * used TTL_event_t. For OpenCL TTL_event_t is event_t.
32 */
34
35/**
36 * @brief Wait for events that identify the async_work_group_copy operations to
37 * complete.
38 *
39 * @param num_events Number of events to wait for (size of event_list)
40 * @param event_list A pointer to a list of events.
41 *
42 * Not supported in the 'C' version.
43 *
44 * @see OpenCL's wait_group_events() builtin for more information.
45 */
46static inline void wait_group_events(int num_events, event_t *event_list) {
47 (void)num_events;
48 (void)event_list;
49 // Nothing to do in C we have no events.
50}
51
52static inline event_t async_work_group_copy_3D3D(void *const dst, size_t dst_offset, const void *const src, size_t src_offset,
53 size_t num_bytes_per_element, size_t num_elements_per_line, size_t num_lines,
54 size_t num_planes, size_t src_total_line_length, size_t src_total_plane_spacing,
55 size_t dst_total_line_length, size_t dst_total_plane_spacing, event_t event) {
56 (void)dst_total_line_length;
57 (void)event;
58
59 for (size_t plane = 0; plane < num_planes; plane++) {
60 const uchar *src_ptr =
61 (uchar *)src + ((src_offset + (src_total_plane_spacing * plane)) * num_bytes_per_element);
62 uint8_t *dst_ptr = (uint8_t *)dst + ((dst_offset + (dst_total_plane_spacing * plane)) * num_bytes_per_element);
63
64 for (size_t line = 0; line < num_lines; line++) {
65 memcpy(dst_ptr, src_ptr, num_bytes_per_element * num_elements_per_line);
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}
74
static void wait_group_events(int num_events, event_t *event_list)
Wait for events that identify the async_work_group_copy operations to complete.
event_t TTL_event_t
TTL_event_t is a pseudonym for OpenCL event_t.
static event_t async_work_group_copy_3D3D(void *const dst, size_t dst_offset, const 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)
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