Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 1 | /* |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 2 | * SPDX-FileCopyrightText: Copyright 2020-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the License); you may |
| 7 | * not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * 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, WITHOUT |
| 14 | * 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 | #include <ethosu.hpp> |
| 20 | #include <uapi/ethosu.h> |
| 21 | |
| 22 | #include <algorithm> |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 23 | #include <cstdlib> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 24 | #include <exception> |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 25 | #include <fstream> |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 26 | #include <iomanip> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 27 | #include <iostream> |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 28 | #include <utility> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 29 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 30 | #include <fcntl.h> |
| 31 | #include <poll.h> |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 32 | #include <signal.h> |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 33 | #include <sys/ioctl.h> |
| 34 | #include <sys/mman.h> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 35 | #include <unistd.h> |
| 36 | |
| 37 | using namespace std; |
| 38 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 39 | namespace { |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 40 | std::string driverVersionToString(const EthosU::ethosu_uapi_kernel_driver_version &version) { |
| 41 | return std::to_string(version.major) + "." + std::to_string(version.minor) + "." + std::to_string(version.patch); |
| 42 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 43 | |
| 44 | enum class Severity { Error, Warning, Info, Debug }; |
| 45 | |
| 46 | class Log { |
| 47 | public: |
| 48 | Log(const Severity _severity = Severity::Error) : severity(_severity) {} |
| 49 | |
| 50 | ~Log() = default; |
| 51 | |
| 52 | template <typename T> |
| 53 | const Log &operator<<(const T &d) const { |
| 54 | if (level >= severity) { |
| 55 | cout << d; |
| 56 | } |
| 57 | |
| 58 | return *this; |
| 59 | } |
| 60 | |
| 61 | const Log &operator<<(ostream &(*manip)(ostream &)) const { |
| 62 | if (level >= severity) { |
| 63 | manip(cout); |
| 64 | } |
| 65 | |
| 66 | return *this; |
| 67 | } |
| 68 | |
| 69 | private: |
| 70 | static Severity getLogLevel() { |
| 71 | if (const char *e = getenv("ETHOSU_LOG_LEVEL")) { |
| 72 | const string env(e); |
| 73 | |
| 74 | if (env == "Error") { |
| 75 | return Severity::Error; |
| 76 | } else if (env == "Warning") { |
| 77 | return Severity::Warning; |
| 78 | } else if (env == "Info") { |
| 79 | return Severity::Info; |
| 80 | } else if (env == "Debug") { |
| 81 | return Severity::Debug; |
| 82 | } else { |
| 83 | cerr << "Unsupported log level '" << env << "'" << endl; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | return Severity::Warning; |
| 88 | } |
| 89 | |
| 90 | static const Severity level; |
| 91 | const Severity severity; |
| 92 | }; |
| 93 | |
| 94 | const Severity Log::level = Log::getLogLevel(); |
| 95 | |
| 96 | } // namespace |
| 97 | |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 98 | namespace EthosU { |
Mikael Olsson | e9c3f07 | 2023-06-12 15:58:10 +0200 | [diff] [blame^] | 99 | |
| 100 | const SemanticVersion getLibraryVersion() { |
| 101 | return {DRIVER_LIBRARY_VERSION_MAJOR, DRIVER_LIBRARY_VERSION_MINOR, DRIVER_LIBRARY_VERSION_PATCH}; |
| 102 | } |
| 103 | |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 104 | __attribute__((weak)) int eioctl(int fd, unsigned long cmd, void *data = nullptr) { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 105 | int ret = ::ioctl(fd, cmd, data); |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 106 | if (ret < 0) { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 107 | throw EthosU::Exception("IOCTL failed"); |
| 108 | } |
| 109 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 110 | Log(Severity::Debug) << "ioctl. fd=" << fd << ", cmd=" << setw(8) << setfill('0') << hex << cmd << ", ret=" << ret |
| 111 | << endl; |
| 112 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 113 | return ret; |
| 114 | } |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 115 | |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 116 | __attribute__((weak)) int eopen(const char *pathname, int flags) { |
| 117 | int fd = ::open(pathname, flags); |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 118 | if (fd < 0) { |
| 119 | throw Exception("Failed to open device"); |
| 120 | } |
| 121 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 122 | Log(Severity::Debug) << "open. fd=" << fd << ", path='" << pathname << "', flags=" << flags << endl; |
| 123 | |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 124 | return fd; |
| 125 | } |
| 126 | |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 127 | __attribute__((weak)) int |
| 128 | eppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmo_p, const sigset_t *sigmask) { |
| 129 | int result = ::ppoll(fds, nfds, tmo_p, sigmask); |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 130 | if (result < 0) { |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 131 | throw Exception("Failed to wait for ppoll event or signal"); |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | return result; |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | __attribute__((weak)) int eclose(int fd) { |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 138 | Log(Severity::Debug) << "close. fd=" << fd << endl; |
| 139 | |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 140 | int result = ::close(fd); |
| 141 | if (result < 0) { |
| 142 | throw Exception("Failed to close file"); |
| 143 | } |
| 144 | |
| 145 | return result; |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 146 | } |
| 147 | __attribute((weak)) void *emmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 148 | void *ptr = ::mmap(addr, length, prot, flags, fd, offset); |
| 149 | if (ptr == MAP_FAILED) { |
| 150 | throw Exception("Failed to mmap file"); |
| 151 | } |
| 152 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 153 | Log(Severity::Debug) << "map. fd=" << fd << ", addr=" << setfill('0') << addr << ", length=" << dec << length |
| 154 | << ", ptr=" << hex << ptr << endl; |
| 155 | |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 156 | return ptr; |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | __attribute__((weak)) int emunmap(void *addr, size_t length) { |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 160 | Log(Severity::Debug) << "unmap. addr=" << setfill('0') << addr << ", length=" << dec << length << endl; |
| 161 | |
Davide Grohmann | c90bfab | 2021-10-19 13:59:27 +0200 | [diff] [blame] | 162 | int result = ::munmap(addr, length); |
| 163 | if (result < 0) { |
| 164 | throw Exception("Failed to munmap file"); |
| 165 | } |
| 166 | |
| 167 | return result; |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | } // namespace EthosU |
| 171 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 172 | namespace EthosU { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 173 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 174 | /**************************************************************************** |
| 175 | * Exception |
| 176 | ****************************************************************************/ |
| 177 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 178 | Exception::Exception(const char *msg) : msg(msg) {} |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 179 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 180 | Exception::~Exception() throw() {} |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 181 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 182 | const char *Exception::what() const throw() { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 183 | return msg.c_str(); |
| 184 | } |
| 185 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 186 | /**************************************************************************** |
Davide Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 187 | * Semantic Version |
| 188 | ****************************************************************************/ |
| 189 | |
| 190 | bool SemanticVersion::operator==(const SemanticVersion &other) { |
| 191 | return other.major == major && other.minor == minor && other.patch == patch; |
| 192 | } |
| 193 | |
| 194 | bool SemanticVersion::operator<(const SemanticVersion &other) { |
| 195 | if (other.major > major) |
| 196 | return true; |
| 197 | if (other.minor > minor) |
| 198 | return true; |
| 199 | return other.patch > patch; |
| 200 | } |
| 201 | |
| 202 | bool SemanticVersion::operator<=(const SemanticVersion &other) { |
| 203 | return *this < other || *this == other; |
| 204 | } |
| 205 | |
| 206 | bool SemanticVersion::operator!=(const SemanticVersion &other) { |
| 207 | return !(*this == other); |
| 208 | } |
| 209 | |
| 210 | bool SemanticVersion::operator>(const SemanticVersion &other) { |
| 211 | return !(*this <= other); |
| 212 | } |
| 213 | |
| 214 | bool SemanticVersion::operator>=(const SemanticVersion &other) { |
| 215 | return !(*this < other); |
| 216 | } |
| 217 | |
| 218 | ostream &operator<<(ostream &out, const SemanticVersion &v) { |
| 219 | return out << "{ major=" << unsigned(v.major) << ", minor=" << unsigned(v.minor) << ", patch=" << unsigned(v.patch) |
| 220 | << " }"; |
| 221 | } |
| 222 | |
| 223 | /**************************************************************************** |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 224 | * Device |
| 225 | ****************************************************************************/ |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 226 | Device::Device(const char *device) : fd(eopen(device, O_RDWR | O_NONBLOCK)) { |
| 227 | ethosu_uapi_kernel_driver_version version = {}; |
| 228 | |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 229 | Log(Severity::Info) << "Device(\"" << device << "\"). this=" << this << ", fd=" << fd << endl; |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 230 | |
| 231 | try { |
| 232 | eioctl(fd, ETHOSU_IOCTL_DRIVER_VERSION_GET, &version); |
| 233 | |
| 234 | if (MAX_SUPPORTED_KERNEL_DRIVER_MAJOR_VERSION < version.major || |
| 235 | MIN_SUPPORTED_KERNEL_DRIVER_MAJOR_VERSION > version.major) { |
| 236 | throw Exception( |
| 237 | std::string("Unsupported kernel driver version: ").append(driverVersionToString(version)).c_str()); |
| 238 | } |
| 239 | } catch (std::exception &e) { |
| 240 | try { |
| 241 | eclose(fd); |
| 242 | } catch (...) { std::throw_with_nested(e); } |
| 243 | throw; |
| 244 | } |
| 245 | |
| 246 | driverVersion = {version.major, version.minor, version.patch}; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 247 | } |
| 248 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 249 | Device::~Device() noexcept(false) { |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 250 | eclose(fd); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 251 | Log(Severity::Info) << "~Device(). this=" << this << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 252 | } |
| 253 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 254 | int Device::ioctl(unsigned long cmd, void *data) const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 255 | return eioctl(fd, cmd, data); |
| 256 | } |
| 257 | |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 258 | const SemanticVersion &Device::getDriverVersion() const { |
| 259 | return driverVersion; |
| 260 | } |
| 261 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 262 | Capabilities Device::capabilities() const { |
Davide Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 263 | ethosu_uapi_device_capabilities uapi; |
| 264 | (void)eioctl(fd, ETHOSU_IOCTL_CAPABILITIES_REQ, static_cast<void *>(&uapi)); |
| 265 | |
| 266 | Capabilities capabilities( |
| 267 | HardwareId(uapi.hw_id.version_status, |
| 268 | SemanticVersion(uapi.hw_id.version_major, uapi.hw_id.version_minor), |
| 269 | SemanticVersion(uapi.hw_id.product_major), |
| 270 | SemanticVersion(uapi.hw_id.arch_major_rev, uapi.hw_id.arch_minor_rev, uapi.hw_id.arch_patch_rev)), |
Davide Grohmann | 40e23d1 | 2021-06-17 09:59:40 +0200 | [diff] [blame] | 271 | HardwareConfiguration(uapi.hw_cfg.macs_per_cc, uapi.hw_cfg.cmd_stream_version, bool(uapi.hw_cfg.custom_dma)), |
Davide Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 272 | SemanticVersion(uapi.driver_major_rev, uapi.driver_minor_rev, uapi.driver_patch_rev)); |
| 273 | return capabilities; |
| 274 | } |
| 275 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 276 | /**************************************************************************** |
| 277 | * Buffer |
| 278 | ****************************************************************************/ |
| 279 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 280 | Buffer::Buffer(const Device &device, const size_t capacity) : fd(-1), dataPtr(nullptr), dataCapacity(capacity) { |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 281 | ethosu_uapi_buffer_create uapi = {static_cast<uint32_t>(dataCapacity)}; |
| 282 | fd = device.ioctl(ETHOSU_IOCTL_BUFFER_CREATE, static_cast<void *>(&uapi)); |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 283 | |
Davide Grohmann | 2ba3c1d | 2021-11-08 15:08:48 +0100 | [diff] [blame] | 284 | void *d; |
| 285 | try { |
| 286 | d = emmap(nullptr, dataCapacity, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); |
| 287 | } catch (std::exception &e) { |
| 288 | try { |
| 289 | eclose(fd); |
| 290 | } catch (...) { std::throw_with_nested(e); } |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 291 | throw; |
Davide Grohmann | 2ba3c1d | 2021-11-08 15:08:48 +0100 | [diff] [blame] | 292 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 293 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 294 | dataPtr = reinterpret_cast<char *>(d); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 295 | |
| 296 | Log(Severity::Info) << "Buffer(" << &device << ", " << dec << capacity << "), this=" << this << ", fd=" << fd |
| 297 | << ", dataPtr=" << static_cast<void *>(dataPtr) << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 298 | } |
| 299 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 300 | Buffer::~Buffer() noexcept(false) { |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 301 | try { |
| 302 | emunmap(dataPtr, dataCapacity); |
| 303 | } catch (std::exception &e) { |
| 304 | try { |
| 305 | eclose(fd); |
| 306 | } catch (...) { std::throw_with_nested(e); } |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 307 | throw; |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 308 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 309 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 310 | eclose(fd); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 311 | |
| 312 | Log(Severity::Info) << "~Buffer(). this=" << this << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 313 | } |
| 314 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 315 | size_t Buffer::capacity() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 316 | return dataCapacity; |
| 317 | } |
| 318 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 319 | void Buffer::clear() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 320 | resize(0, 0); |
| 321 | } |
| 322 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 323 | char *Buffer::data() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 324 | return dataPtr + offset(); |
| 325 | } |
| 326 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 327 | void Buffer::resize(size_t size, size_t offset) const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 328 | ethosu_uapi_buffer uapi; |
| 329 | uapi.offset = offset; |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 330 | uapi.size = size; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 331 | eioctl(fd, ETHOSU_IOCTL_BUFFER_SET, static_cast<void *>(&uapi)); |
| 332 | } |
| 333 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 334 | size_t Buffer::offset() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 335 | ethosu_uapi_buffer uapi; |
| 336 | eioctl(fd, ETHOSU_IOCTL_BUFFER_GET, static_cast<void *>(&uapi)); |
| 337 | return uapi.offset; |
| 338 | } |
| 339 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 340 | size_t Buffer::size() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 341 | ethosu_uapi_buffer uapi; |
| 342 | eioctl(fd, ETHOSU_IOCTL_BUFFER_GET, static_cast<void *>(&uapi)); |
| 343 | return uapi.size; |
| 344 | } |
| 345 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 346 | int Buffer::getFd() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 347 | return fd; |
| 348 | } |
| 349 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 350 | /**************************************************************************** |
| 351 | * Network |
| 352 | ****************************************************************************/ |
| 353 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 354 | Network::Network(const Device &device, shared_ptr<Buffer> &buffer) : fd(-1), buffer(buffer) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 355 | // Create buffer handle |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 356 | ethosu_uapi_network_create uapi; |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 357 | uapi.type = ETHOSU_UAPI_NETWORK_BUFFER; |
| 358 | uapi.fd = buffer->getFd(); |
| 359 | fd = device.ioctl(ETHOSU_IOCTL_NETWORK_CREATE, static_cast<void *>(&uapi)); |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 360 | try { |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 361 | collectNetworkInfo(); |
| 362 | } catch (std::exception &e) { |
| 363 | try { |
| 364 | eclose(fd); |
| 365 | } catch (...) { std::throw_with_nested(e); } |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 366 | throw; |
Jonny Svärd | 2c01713 | 2021-04-12 15:56:44 +0200 | [diff] [blame] | 367 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 368 | |
| 369 | Log(Severity::Info) << "Network(" << &device << ", " << &*buffer << "), this=" << this << ", fd=" << fd << endl; |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 370 | } |
Jonny Svärd | 2c01713 | 2021-04-12 15:56:44 +0200 | [diff] [blame] | 371 | |
Kristofer Jonsson | 3c6a260 | 2022-03-10 11:17:29 +0100 | [diff] [blame] | 372 | Network::Network(const Device &device, const unsigned index) : fd(-1) { |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 373 | // Create buffer handle |
| 374 | ethosu_uapi_network_create uapi; |
| 375 | uapi.type = ETHOSU_UAPI_NETWORK_INDEX; |
| 376 | uapi.index = index; |
| 377 | fd = device.ioctl(ETHOSU_IOCTL_NETWORK_CREATE, static_cast<void *>(&uapi)); |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 378 | try { |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 379 | collectNetworkInfo(); |
| 380 | } catch (std::exception &e) { |
| 381 | try { |
| 382 | eclose(fd); |
| 383 | } catch (...) { std::throw_with_nested(e); } |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 384 | throw; |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 385 | } |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 386 | |
| 387 | Log(Severity::Info) << "Network(" << &device << ", " << index << "), this=" << this << ", fd=" << fd << endl; |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 388 | } |
Kristofer Jonsson | 3c6a260 | 2022-03-10 11:17:29 +0100 | [diff] [blame] | 389 | |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 390 | void Network::collectNetworkInfo() { |
| 391 | ethosu_uapi_network_info info; |
| 392 | ioctl(ETHOSU_IOCTL_NETWORK_INFO, static_cast<void *>(&info)); |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 393 | |
Davide Grohmann | 80f8ddf | 2022-04-07 14:50:50 +0200 | [diff] [blame] | 394 | for (uint32_t i = 0; i < info.ifm_count; i++) { |
| 395 | ifmDims.push_back(info.ifm_size[i]); |
| 396 | } |
| 397 | |
| 398 | for (uint32_t i = 0; i < info.ofm_count; i++) { |
| 399 | ofmDims.push_back(info.ofm_size[i]); |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 400 | } |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 401 | } |
| 402 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 403 | Network::~Network() noexcept(false) { |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 404 | eclose(fd); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 405 | Log(Severity::Info) << "~Network(). this=" << this << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 406 | } |
| 407 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 408 | int Network::ioctl(unsigned long cmd, void *data) { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 409 | return eioctl(fd, cmd, data); |
| 410 | } |
| 411 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 412 | shared_ptr<Buffer> Network::getBuffer() { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 413 | return buffer; |
| 414 | } |
| 415 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 416 | const std::vector<size_t> &Network::getIfmDims() const { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 417 | return ifmDims; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 418 | } |
| 419 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 420 | size_t Network::getIfmSize() const { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 421 | size_t size = 0; |
| 422 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 423 | for (auto s : ifmDims) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 424 | size += s; |
| 425 | } |
| 426 | |
| 427 | return size; |
| 428 | } |
| 429 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 430 | const std::vector<size_t> &Network::getOfmDims() const { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 431 | return ofmDims; |
| 432 | } |
| 433 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 434 | size_t Network::getOfmSize() const { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 435 | size_t size = 0; |
| 436 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 437 | for (auto s : ofmDims) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 438 | size += s; |
| 439 | } |
| 440 | |
| 441 | return size; |
| 442 | } |
| 443 | |
| 444 | /**************************************************************************** |
| 445 | * Inference |
| 446 | ****************************************************************************/ |
| 447 | |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 448 | ostream &operator<<(ostream &out, const InferenceStatus &status) { |
| 449 | switch (status) { |
| 450 | case InferenceStatus::OK: |
| 451 | return out << "ok"; |
| 452 | case InferenceStatus::ERROR: |
| 453 | return out << "error"; |
| 454 | case InferenceStatus::RUNNING: |
| 455 | return out << "running"; |
| 456 | case InferenceStatus::REJECTED: |
| 457 | return out << "rejected"; |
Davide Grohmann | 7e8f508 | 2022-03-23 12:48:45 +0100 | [diff] [blame] | 458 | case InferenceStatus::ABORTED: |
| 459 | return out << "aborted"; |
| 460 | case InferenceStatus::ABORTING: |
| 461 | return out << "aborting"; |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 462 | } |
| 463 | throw Exception("Unknown inference status"); |
| 464 | } |
| 465 | |
Davide Grohmann | fc49559 | 2022-04-25 15:27:52 +0200 | [diff] [blame] | 466 | Inference::~Inference() noexcept(false) { |
Per Åstrand | ec3f2b0 | 2021-06-09 10:43:38 +0200 | [diff] [blame] | 467 | eclose(fd); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 468 | Log(Severity::Info) << "~Inference(). this=" << this << endl; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 469 | } |
| 470 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 471 | void Inference::create(std::vector<uint32_t> &counterConfigs, bool cycleCounterEnable = false) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 472 | ethosu_uapi_inference_create uapi; |
| 473 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 474 | if (ifmBuffers.size() > ETHOSU_FD_MAX) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 475 | throw Exception("IFM buffer overflow"); |
| 476 | } |
| 477 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 478 | if (ofmBuffers.size() > ETHOSU_FD_MAX) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 479 | throw Exception("OFM buffer overflow"); |
| 480 | } |
| 481 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 482 | if (counterConfigs.size() != ETHOSU_PMU_EVENT_MAX) { |
| 483 | throw Exception("Wrong size of counter configurations"); |
| 484 | } |
| 485 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 486 | uapi.ifm_count = 0; |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 487 | for (auto it : ifmBuffers) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 488 | uapi.ifm_fd[uapi.ifm_count++] = it->getFd(); |
| 489 | } |
| 490 | |
| 491 | uapi.ofm_count = 0; |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 492 | for (auto it : ofmBuffers) { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 493 | uapi.ofm_fd[uapi.ofm_count++] = it->getFd(); |
| 494 | } |
| 495 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 496 | for (int i = 0; i < ETHOSU_PMU_EVENT_MAX; i++) { |
| 497 | uapi.pmu_config.events[i] = counterConfigs[i]; |
| 498 | } |
| 499 | |
| 500 | uapi.pmu_config.cycle_count = cycleCounterEnable; |
| 501 | |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 502 | fd = network->ioctl(ETHOSU_IOCTL_INFERENCE_CREATE, static_cast<void *>(&uapi)); |
Kristofer Jonsson | 53fd03d | 2022-06-21 16:58:45 +0200 | [diff] [blame] | 503 | |
| 504 | Log(Severity::Info) << "Inference(" << &*network << "), this=" << this << ", fd=" << fd << endl; |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 505 | } |
| 506 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 507 | std::vector<uint32_t> Inference::initializeCounterConfig() { |
| 508 | return std::vector<uint32_t>(ETHOSU_PMU_EVENT_MAX, 0); |
| 509 | } |
| 510 | |
| 511 | uint32_t Inference::getMaxPmuEventCounters() { |
| 512 | return ETHOSU_PMU_EVENT_MAX; |
| 513 | } |
| 514 | |
Davide Grohmann | 7e8f508 | 2022-03-23 12:48:45 +0100 | [diff] [blame] | 515 | bool Inference::wait(int64_t timeoutNanos) const { |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 516 | struct pollfd pfd; |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 517 | pfd.fd = fd; |
| 518 | pfd.events = POLLIN | POLLERR; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 519 | pfd.revents = 0; |
| 520 | |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 521 | // if timeout negative wait forever |
| 522 | if (timeoutNanos < 0) { |
Davide Grohmann | f036423 | 2022-06-16 17:42:58 +0200 | [diff] [blame] | 523 | return eppoll(&pfd, 1, NULL, NULL) == 0; |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 524 | } |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 525 | |
Davide Grohmann | e446b42 | 2021-10-19 15:33:23 +0200 | [diff] [blame] | 526 | struct timespec tmo_p; |
| 527 | int64_t nanosec = 1000000000; |
| 528 | tmo_p.tv_sec = timeoutNanos / nanosec; |
| 529 | tmo_p.tv_nsec = timeoutNanos % nanosec; |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 530 | |
Davide Grohmann | 7e8f508 | 2022-03-23 12:48:45 +0100 | [diff] [blame] | 531 | return eppoll(&pfd, 1, &tmo_p, NULL) == 0; |
| 532 | } |
| 533 | |
| 534 | bool Inference::cancel() const { |
| 535 | ethosu_uapi_cancel_inference_status uapi; |
| 536 | eioctl(fd, ETHOSU_IOCTL_INFERENCE_CANCEL, static_cast<void *>(&uapi)); |
| 537 | return uapi.status == ETHOSU_UAPI_STATUS_OK; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 538 | } |
| 539 | |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 540 | InferenceStatus Inference::status() const { |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 541 | ethosu_uapi_result_status uapi; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 542 | |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 543 | eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi)); |
| 544 | |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 545 | switch (uapi.status) { |
| 546 | case ETHOSU_UAPI_STATUS_OK: |
| 547 | return InferenceStatus::OK; |
| 548 | case ETHOSU_UAPI_STATUS_ERROR: |
| 549 | return InferenceStatus::ERROR; |
| 550 | case ETHOSU_UAPI_STATUS_RUNNING: |
| 551 | return InferenceStatus::RUNNING; |
| 552 | case ETHOSU_UAPI_STATUS_REJECTED: |
| 553 | return InferenceStatus::REJECTED; |
Davide Grohmann | 7e8f508 | 2022-03-23 12:48:45 +0100 | [diff] [blame] | 554 | case ETHOSU_UAPI_STATUS_ABORTED: |
| 555 | return InferenceStatus::ABORTED; |
| 556 | case ETHOSU_UAPI_STATUS_ABORTING: |
| 557 | return InferenceStatus::ABORTING; |
Davide Grohmann | 82d2258 | 2022-04-25 12:52:38 +0200 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | throw Exception("Unknown inference status"); |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 561 | } |
| 562 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 563 | const std::vector<uint32_t> Inference::getPmuCounters() const { |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 564 | ethosu_uapi_result_status uapi; |
| 565 | std::vector<uint32_t> counterValues = std::vector<uint32_t>(ETHOSU_PMU_EVENT_MAX, 0); |
| 566 | |
| 567 | eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi)); |
| 568 | |
| 569 | for (int i = 0; i < ETHOSU_PMU_EVENT_MAX; i++) { |
| 570 | if (uapi.pmu_config.events[i]) { |
| 571 | counterValues.at(i) = uapi.pmu_count.events[i]; |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | return counterValues; |
| 576 | } |
| 577 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 578 | uint64_t Inference::getCycleCounter() const { |
Per Åstrand | 2354d3e | 2020-10-24 20:17:10 +0200 | [diff] [blame] | 579 | ethosu_uapi_result_status uapi; |
| 580 | |
| 581 | eioctl(fd, ETHOSU_IOCTL_INFERENCE_STATUS, static_cast<void *>(&uapi)); |
| 582 | |
| 583 | return uapi.pmu_count.cycle_count; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 584 | } |
| 585 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 586 | int Inference::getFd() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 587 | return fd; |
| 588 | } |
| 589 | |
Per Åstrand | afb399f | 2021-11-26 12:50:35 +0100 | [diff] [blame] | 590 | const shared_ptr<Network> Inference::getNetwork() const { |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 591 | return network; |
| 592 | } |
| 593 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 594 | vector<shared_ptr<Buffer>> &Inference::getIfmBuffers() { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 595 | return ifmBuffers; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 596 | } |
| 597 | |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 598 | vector<shared_ptr<Buffer>> &Inference::getOfmBuffers() { |
Kristofer Jonsson | b74492c | 2020-09-10 13:26:01 +0200 | [diff] [blame] | 599 | return ofmBuffers; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 600 | } |
| 601 | |
Mikael Olsson | 308e7f1 | 2023-06-12 15:00:55 +0200 | [diff] [blame] | 602 | static_assert(MAX_SUPPORTED_KERNEL_DRIVER_MAJOR_VERSION >= ETHOSU_KERNEL_DRIVER_VERSION_MAJOR && |
| 603 | MIN_SUPPORTED_KERNEL_DRIVER_MAJOR_VERSION <= ETHOSU_KERNEL_DRIVER_VERSION_MAJOR, |
| 604 | "Unsupported major kernel driver version in UAPI"); |
Kristofer Jonsson | 79689c5 | 2020-10-16 14:42:19 +0200 | [diff] [blame] | 605 | } // namespace EthosU |