diff options
-rw-r--r-- | applications/CMakeLists.txt | 6 | ||||
-rw-r--r-- | applications/inference_process/src/inference_process.cpp | 24 | ||||
-rw-r--r-- | applications/message_process/CMakeLists.txt | 25 | ||||
-rw-r--r-- | applications/message_process/include/message_process.hpp | 111 | ||||
-rw-r--r-- | applications/message_process/src/message_process.cpp | 465 | ||||
-rw-r--r-- | drivers/mhu_v2/src/mhu_v2.cpp | 4 | ||||
-rw-r--r-- | lib/ethosu_log/include/ethosu_log.h | 16 |
7 files changed, 19 insertions, 632 deletions
diff --git a/applications/CMakeLists.txt b/applications/CMakeLists.txt index 22de770..88dd052 100644 --- a/applications/CMakeLists.txt +++ b/applications/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (c) 2019-2020 Arm Limited. All rights reserved. +# Copyright (c) 2019-2021 Arm Limited. All rights reserved. # # SPDX-License-Identifier: Apache-2.0 # @@ -18,10 +18,6 @@ add_library(ethosu_applications INTERFACE) -# Build message process -add_subdirectory(message_process) -target_link_libraries(ethosu_applications INTERFACE message_process) - # Build inference process add_subdirectory(inference_process) target_link_libraries(ethosu_applications INTERFACE inference_process) diff --git a/applications/inference_process/src/inference_process.cpp b/applications/inference_process/src/inference_process.cpp index 3aa2550..7d6c7d7 100644 --- a/applications/inference_process/src/inference_process.cpp +++ b/applications/inference_process/src/inference_process.cpp @@ -75,7 +75,7 @@ bool copyOutput(const TfLiteTensor &src, InferenceProcess::DataPtr &dst) { } if (src.bytes > dst.size) { - LOG_ERR("Tensor size mismatch (bytes): actual=%d, expected%d.\n", src.bytes, dst.size); + LOG_ERR("Tensor size mismatch (bytes): actual=%d, expected%d.", src.bytes, dst.size); return true; } @@ -185,7 +185,7 @@ bool InferenceProcess::push(const InferenceJob &job) { } bool InferenceProcess::runJob(InferenceJob &job) { - LOG_INFO("Running inference job: %s\n", job.name.c_str()); + LOG_INFO("Running inference job: %s", job.name.c_str()); // Register debug log callback for profiling RegisterDebugLogCallback(tflu_debug_log); @@ -196,7 +196,7 @@ bool InferenceProcess::runJob(InferenceJob &job) { // Get model handle and verify that the version is correct const tflite::Model *model = ::tflite::GetModel(job.networkModel.data); if (model->version() != TFLITE_SCHEMA_VERSION) { - LOG_ERR("Model schema version unsupported: version=%" PRIu32 ", supported=%d.\n", + LOG_ERR("Model schema version unsupported: version=%" PRIu32 ", supported=%d.", model->version(), TFLITE_SCHEMA_VERSION); return true; @@ -215,7 +215,7 @@ bool InferenceProcess::runJob(InferenceJob &job) { // Allocate tensors TfLiteStatus allocate_status = interpreter.AllocateTensors(); if (allocate_status != kTfLiteOk) { - LOG_ERR("Failed to allocate tensors for inference: job=%s\n", job.name.c_str()); + LOG_ERR("Failed to allocate tensors for inference: job=%s", job.name.c_str()); return true; } @@ -229,7 +229,7 @@ bool InferenceProcess::runJob(InferenceJob &job) { } } if (job.input.size() != inputTensors.size()) { - LOG_ERR("Number of input buffers does not match number of non empty network tensors: input=%zu, network=%zu\n", + LOG_ERR("Number of input buffers does not match number of non empty network tensors: input=%zu, network=%zu", job.input.size(), inputTensors.size()); return true; @@ -241,7 +241,7 @@ bool InferenceProcess::runJob(InferenceJob &job) { const TfLiteTensor *tensor = inputTensors[i]; if (input.size != tensor->bytes) { - LOG_ERR("Job input size does not match network input size: job=%s, index=%zu, input=%zu, network=%u\n", + LOG_ERR("Job input size does not match network input size: job=%s, index=%zu, input=%zu, network=%u", job.name.c_str(), i, input.size, @@ -255,7 +255,7 @@ bool InferenceProcess::runJob(InferenceJob &job) { // Run the inference TfLiteStatus invoke_status = interpreter.Invoke(); if (invoke_status != kTfLiteOk) { - LOG_ERR("Invoke failed for inference: job=%s\n", job.name.c_str()); + LOG_ERR("Invoke failed for inference: job=%s", job.name.c_str()); return true; } @@ -270,7 +270,7 @@ bool InferenceProcess::runJob(InferenceJob &job) { // Copy output data if (job.output.size() > 0) { if (interpreter.outputs_size() != job.output.size()) { - LOG_ERR("Output size mismatch: job=%zu, network=%u\n", job.output.size(), interpreter.outputs_size()); + LOG_ERR("Output size mismatch: job=%zu, network=%u", job.output.size(), interpreter.outputs_size()); return true; } @@ -300,7 +300,7 @@ bool InferenceProcess::runJob(InferenceJob &job) { if (job.expectedOutput.size() > 0) { if (job.expectedOutput.size() != interpreter.outputs_size()) { - LOG_ERR("Expected number of output tensors mismatch: job=%s, expected=%zu, network=%zu\n", + LOG_ERR("Expected number of output tensors mismatch: job=%s, expected=%zu, network=%zu", job.name.c_str(), job.expectedOutput.size(), interpreter.outputs_size()); @@ -312,7 +312,7 @@ bool InferenceProcess::runJob(InferenceJob &job) { const TfLiteTensor *output = interpreter.output(i); if (expected.size != output->bytes) { - LOG_ERR("Expected output tensor size mismatch: job=%s, index=%u, expected=%zu, network=%zu\n", + LOG_ERR("Expected output tensor size mismatch: job=%s, index=%u, expected=%zu, network=%zu", job.name.c_str(), i, expected.size, @@ -335,7 +335,7 @@ bool InferenceProcess::runJob(InferenceJob &job) { } } - LOG_INFO("Finished running job: %s\n", job.name.c_str()); + LOG_INFO("Finished running job: %s", job.name.c_str()); return false; } // namespace InferenceProcess @@ -350,7 +350,7 @@ bool InferenceProcess::run(bool exitOnEmpty) { if (empty) { if (exitOnEmpty) { - LOG_INFO("Exit from InferenceProcess::run() due to empty job queue\n"); + LOG_INFO("Exit from InferenceProcess::run() due to empty job queue"); break; } diff --git a/applications/message_process/CMakeLists.txt b/applications/message_process/CMakeLists.txt deleted file mode 100644 index 2122f14..0000000 --- a/applications/message_process/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# -# Copyright (c) 2019-2021 Arm Limited. All rights reserved. -# -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed under the Apache License, Version 2.0 (the License); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an AS IS BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -add_library(message_process STATIC src/message_process.cpp) -target_include_directories(message_process PUBLIC include ${LINUX_DRIVER_STACK_PATH}/kernel) - -target_link_libraries(message_process PRIVATE cmsis_device inference_process ethosu_mailbox ethosu_log) -if (CORE_SOFTWARE_ACCELERATOR STREQUAL "NPU") - target_link_libraries(message_process PRIVATE ethosu_core_driver) -endif()
\ No newline at end of file diff --git a/applications/message_process/include/message_process.hpp b/applications/message_process/include/message_process.hpp deleted file mode 100644 index 851be04..0000000 --- a/applications/message_process/include/message_process.hpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2020-2021 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef MESSAGE_PROCESS_H -#define MESSAGE_PROCESS_H - -#include <ethosu_core_interface.h> -#include <inference_process.hpp> -#include <mailbox.hpp> - -#include <cstddef> -#include <cstdio> -#include <vector> - -namespace MessageProcess { - -template <uint32_t SIZE> -struct Queue { - EthosU::ethosu_core_queue_header header; - uint8_t data[SIZE]; - - constexpr Queue() : header({SIZE, 0, 0}) {} - - constexpr EthosU::ethosu_core_queue *toQueue() { - return reinterpret_cast<EthosU::ethosu_core_queue *>(&header); - } -}; - -class QueueImpl { -public: - struct Vec { - const void *base; - size_t length; - }; - - QueueImpl(EthosU::ethosu_core_queue &queue); - - bool empty() const; - size_t available() const; - size_t capacity() const; - void reset(); - bool read(uint8_t *dst, uint32_t length); - bool write(const Vec *vec, size_t length); - bool write(const uint32_t type, const void *src = nullptr, uint32_t length = 0); - template <typename T> - bool write(const uint32_t type, const T &src) { - return write(type, reinterpret_cast<const void *>(&src), sizeof(src)); - } - - template <typename T> - bool read(T &dst) { - return read(reinterpret_cast<uint8_t *>(&dst), sizeof(dst)); - } - -private: - void cleanHeader() const; - void cleanHeaderData() const; - void invalidateHeader() const; - void invalidateHeaderData() const; - - EthosU::ethosu_core_queue &queue; -}; - -class MessageProcess { -public: - MessageProcess(EthosU::ethosu_core_queue &in, - EthosU::ethosu_core_queue &out, - Mailbox::Mailbox &mbox, - InferenceProcess::InferenceProcess &inferenceProcess); - - void run(); - bool handleMessage(); - void sendPong(); - void sndErrorRspAndResetQueue(EthosU::ethosu_core_msg_err_type type, const char *message); - void sendVersionRsp(); - void sendCapabilityRsp(uint64_t userArg); - void sendInferenceRsp(uint64_t userArg, - std::vector<InferenceProcess::DataPtr> &ofm, - bool failed, - std::vector<uint8_t> &pmuEventConfig, - uint32_t pmuCycleCounterEnable, - std::vector<uint32_t> &pmuEventCount, - uint64_t pmuCycleCounterCount); - -private: - QueueImpl queueIn; - QueueImpl queueOut; - Mailbox::Mailbox &mailbox; - InferenceProcess::InferenceProcess &inferenceProcess; - void handleIrq(); - static void mailboxCallback(void *userArg); -}; - -} // namespace MessageProcess - -#endif diff --git a/applications/message_process/src/message_process.cpp b/applications/message_process/src/message_process.cpp deleted file mode 100644 index 6f0fede..0000000 --- a/applications/message_process/src/message_process.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/* - * Copyright (c) 2020-2021 Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the License); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#if defined(ETHOSU) -#include <ethosu_driver.h> -#endif - -#include <message_process.hpp> - -#include "cmsis_compiler.h" - -#include "ethosu_log.h" - -#include <cstddef> -#include <cstdio> -#include <cstring> -#include <inttypes.h> - -using namespace std; -using namespace InferenceProcess; -using namespace EthosU; - -namespace MessageProcess { - -QueueImpl::QueueImpl(ethosu_core_queue &_queue) : queue(_queue) { - cleanHeaderData(); -} - -bool QueueImpl::empty() const { - invalidateHeaderData(); - - return queue.header.read == queue.header.write; -} - -size_t QueueImpl::available() const { - invalidateHeaderData(); - - size_t avail = queue.header.write - queue.header.read; - - if (queue.header.read > queue.header.write) { - avail += queue.header.size; - } - - return avail; -} - -size_t QueueImpl::capacity() const { - return queue.header.size - available(); -} - -bool QueueImpl::read(uint8_t *dst, uint32_t length) { - const uint8_t *end = dst + length; - - // Available will invalidate the cache - if (length > available()) { - return false; - } - - uint32_t rpos = queue.header.read; - - while (dst < end) { - *dst++ = queue.data[rpos]; - rpos = (rpos + 1) % queue.header.size; - } - - queue.header.read = rpos; - - cleanHeader(); - - return true; -} - -bool QueueImpl::write(const Vec *vec, size_t length) { - size_t total = 0; - - for (size_t i = 0; i < length; i++) { - total += vec[i].length; - } - - invalidateHeader(); - - if (total > capacity()) { - return false; - } - - uint32_t wpos = queue.header.write; - - for (size_t i = 0; i < length; i++) { - const uint8_t *src = reinterpret_cast<const uint8_t *>(vec[i].base); - const uint8_t *end = src + vec[i].length; - - while (src < end) { - queue.data[wpos] = *src++; - wpos = (wpos + 1) % queue.header.size; - } - } - - // Update the write position last - queue.header.write = wpos; - - cleanHeaderData(); - - return true; -} - -bool QueueImpl::write(const uint32_t type, const void *src, uint32_t length) { - ethosu_core_msg msg = {ETHOSU_CORE_MSG_MAGIC, type, length}; - Vec vec[2] = {{&msg, sizeof(msg)}, {src, length}}; - - return write(vec, 2); -} - -// Skip to magic or end of queue -void QueueImpl::reset() { - invalidateHeader(); - queue.header.read = queue.header.write; - cleanHeader(); -} - -void QueueImpl::cleanHeader() const { -#if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) - SCB_CleanDCache_by_Addr(reinterpret_cast<uint32_t *>(&queue.header), sizeof(queue.header)); -#endif -} - -void QueueImpl::cleanHeaderData() const { -#if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) - SCB_CleanDCache_by_Addr(reinterpret_cast<uint32_t *>(&queue.header), sizeof(queue.header)); - uintptr_t queueDataPtr = reinterpret_cast<uintptr_t>(&queue.data[0]); - SCB_CleanDCache_by_Addr(reinterpret_cast<uint32_t *>(queueDataPtr & ~3), queue.header.size + (queueDataPtr & 3)); -#endif -} - -void QueueImpl::invalidateHeader() const { -#if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) - SCB_InvalidateDCache_by_Addr(reinterpret_cast<uint32_t *>(&queue.header), sizeof(queue.header)); -#endif -} - -void QueueImpl::invalidateHeaderData() const { -#if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) - SCB_InvalidateDCache_by_Addr(reinterpret_cast<uint32_t *>(&queue.header), sizeof(queue.header)); - uintptr_t queueDataPtr = reinterpret_cast<uintptr_t>(&queue.data[0]); - SCB_InvalidateDCache_by_Addr(reinterpret_cast<uint32_t *>(queueDataPtr & ~3), - queue.header.size + (queueDataPtr & 3)); -#endif -} - -MessageProcess::MessageProcess(ethosu_core_queue &in, - ethosu_core_queue &out, - Mailbox::Mailbox &mbox, - ::InferenceProcess::InferenceProcess &_inferenceProcess) : - queueIn(in), - queueOut(out), mailbox(mbox), inferenceProcess(_inferenceProcess) { - mailbox.registerCallback(mailboxCallback, reinterpret_cast<void *>(this)); -} - -void MessageProcess::run() { - while (true) { - // Handle all messages in queue - while (handleMessage()) - ; - - // Wait for event - __WFE(); - } -} - -void MessageProcess::handleIrq() { - __SEV(); -} - -bool MessageProcess::handleMessage() { - ethosu_core_msg msg; - - if (queueIn.available() == 0) { - return false; - } - - // Read msg header - // Only process a complete message header, else send error message - // and reset queue - if (!queueIn.read(msg)) { - sndErrorRspAndResetQueue(ETHOSU_CORE_MSG_ERR_INVALID_SIZE, "Failed to read a complete header"); - return false; - } - - LOG_INFO("Msg: header magic=%" PRIX32 ", type=%" PRIu32 ", length=%" PRIu32 "\n", msg.magic, msg.type, msg.length); - - if (msg.magic != ETHOSU_CORE_MSG_MAGIC) { - sndErrorRspAndResetQueue(ETHOSU_CORE_MSG_ERR_INVALID_MAGIC, "Invalid magic"); - return false; - } - - switch (msg.type) { - case ETHOSU_CORE_MSG_PING: - LOG_INFO("Msg: Ping\n"); - sendPong(); - break; - case ETHOSU_CORE_MSG_ERR: { - struct ethosu_core_msg_err error = {0}; - if (!queueIn.read(error)) { - LOG_ERR("Msg: Failed to receive error message\n"); - } else { - LOG_INFO("Msg: Received an error response, type=%" PRIu32 ", msg=\"%s\"\n", error.type, error.msg); - } - queueIn.reset(); - return false; - } - case ETHOSU_CORE_MSG_VERSION_REQ: - LOG_INFO("Msg: Version request\n"); - sendVersionRsp(); - break; - case ETHOSU_CORE_MSG_CAPABILITIES_REQ: { - ethosu_core_capabilities_req req; - if (!queueIn.read(req)) { - sndErrorRspAndResetQueue(ETHOSU_CORE_MSG_ERR_INVALID_PAYLOAD, "CapabilitiesReq. Failed to read payload"); - return false; - } - - LOG_INFO("Msg: Capability request.user_arg=0x%" PRIx64 "\n", req.user_arg); - - sendCapabilityRsp(req.user_arg); - break; - } - case ETHOSU_CORE_MSG_INFERENCE_REQ: { - ethosu_core_inference_req req; - - if (!queueIn.read(req)) { - sndErrorRspAndResetQueue(ETHOSU_CORE_MSG_ERR_INVALID_PAYLOAD, "InferenceReq. Failed to read payload"); - return false; - } - - LOG_INFO("Msg: InferenceReq. user_arg=0x%" PRIx64 ", network={0x%" PRIx32 ", %" PRIu32 "}", - req.user_arg, - req.network.ptr, - req.network.size); - - LOG_DEBUG_N(", ifm_count=%" PRIu32 ", ifm=[", req.ifm_count); - for (uint32_t i = 0; i < req.ifm_count; ++i) { - if (i > 0) { - LOG_DEBUG_N(", "); - } - - LOG_DEBUG_N("{0x%" PRIx32 ", %" PRIu32 "}", req.ifm[i].ptr, req.ifm[i].size); - } - LOG_DEBUG_N("]"); - - LOG_DEBUG_N(", ofm_count=%" PRIu32 ", ofm=[", req.ofm_count); - for (uint32_t i = 0; i < req.ofm_count; ++i) { - if (i > 0) { - LOG_DEBUG_N(", "); - } - - LOG_DEBUG_N("{0x%" PRIx32 ", %" PRIu32 "}", req.ofm[i].ptr, req.ofm[i].size); - } - LOG_DEBUG_N("]\n"); - - DataPtr networkModel(reinterpret_cast<void *>(req.network.ptr), req.network.size); - - vector<DataPtr> ifm; - for (uint32_t i = 0; i < req.ifm_count; ++i) { - ifm.push_back(DataPtr(reinterpret_cast<void *>(req.ifm[i].ptr), req.ifm[i].size)); - } - - vector<DataPtr> ofm; - for (uint32_t i = 0; i < req.ofm_count; ++i) { - ofm.push_back(DataPtr(reinterpret_cast<void *>(req.ofm[i].ptr), req.ofm[i].size)); - } - - vector<DataPtr> expectedOutput; - - vector<uint8_t> pmuEventConfig(ETHOSU_CORE_PMU_MAX); - for (uint32_t i = 0; i < ETHOSU_CORE_PMU_MAX; i++) { - pmuEventConfig[i] = req.pmu_event_config[i]; - } - - InferenceJob job( - "job", networkModel, ifm, ofm, expectedOutput, -1, pmuEventConfig, req.pmu_cycle_counter_enable); - job.invalidate(); - - bool failed = inferenceProcess.runJob(job); - job.clean(); - - sendInferenceRsp(req.user_arg, - job.output, - failed, - job.pmuEventConfig, - job.pmuCycleCounterEnable, - job.pmuEventCount, - job.pmuCycleCounterCount); - break; - } - default: { - char errMsg[128] = {0}; - snprintf(&errMsg[0], - sizeof(errMsg), - "Msg: Unknown type: %" PRIu32 " with payload length %" PRIu32 " bytes\n", - msg.type, - msg.length); - sndErrorRspAndResetQueue(ETHOSU_CORE_MSG_ERR_UNSUPPORTED_TYPE, errMsg); - return false; - } - } - return true; -} - -void MessageProcess::sendPong() { - if (!queueOut.write(ETHOSU_CORE_MSG_PONG)) { - LOG_ERR("Msg: Failed to write pong response. No mailbox message sent\n"); - } else { - mailbox.sendMessage(); - } -} - -void MessageProcess::sendVersionRsp() { - struct ethosu_core_msg_version ver = { - ETHOSU_CORE_MSG_VERSION_MAJOR, - ETHOSU_CORE_MSG_VERSION_MINOR, - ETHOSU_CORE_MSG_VERSION_PATCH, - 0, - }; - - if (!queueOut.write(ETHOSU_CORE_MSG_VERSION_RSP, ver)) { - LOG_ERR("Msg: Failed to write version response. No mailbox message sent\n"); - } else { - mailbox.sendMessage(); - } -} - -void MessageProcess::sendCapabilityRsp(uint64_t userArg) { - struct ethosu_core_msg_capabilities_rsp capabilities; -#if defined(ETHOSU) - struct ethosu_driver_version driver_version; - struct ethosu_hw_info hw_info; - ethosu_get_driver_version(&driver_version); - struct ethosu_driver *drv = ethosu_reserve_driver(); - ethosu_get_hw_info(drv, &hw_info); - ethosu_release_driver(drv); - - capabilities = { - userArg, - hw_info.version.version_status, - hw_info.version.version_minor, - hw_info.version.version_major, - hw_info.version.product_major, - hw_info.version.arch_patch_rev, - hw_info.version.arch_minor_rev, - hw_info.version.arch_major_rev, - driver_version.patch, - driver_version.minor, - driver_version.major, - hw_info.cfg.macs_per_cc, - hw_info.cfg.cmd_stream_version, - hw_info.cfg.custom_dma, - }; -#else - capabilities = { - userArg, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }; -#endif - - if (!queueOut.write(ETHOSU_CORE_MSG_CAPABILITIES_RSP, capabilities)) { - LOG_ERR("Failed to write capability response. No mailbox message sent\n"); - } else { - mailbox.sendMessage(); - } -} - -void MessageProcess::sndErrorRspAndResetQueue(ethosu_core_msg_err_type type, const char *message) { - ethosu_core_msg_err error = {0}; - error.type = type; - unsigned int i = 0; - - if (message) { - for (; i < (sizeof(error.msg) - 1) && message[i]; i++) { - error.msg[i] = message[i]; - } - } - LOG_ERR("Msg: \"%s\"\n", message); - if (!queueOut.write(ETHOSU_CORE_MSG_ERR, &error)) { - LOG_ERR("Msg: Failed to write error response. No mailbox message sent\n"); - return; - } - queueIn.reset(); - mailbox.sendMessage(); -} - -void MessageProcess::sendInferenceRsp(uint64_t userArg, - vector<DataPtr> &ofm, - bool failed, - vector<uint8_t> &pmuEventConfig, - uint32_t pmuCycleCounterEnable, - vector<uint32_t> &pmuEventCount, - uint64_t pmuCycleCounterCount) { - ethosu_core_inference_rsp rsp = { - .pmu_event_count = - { - 0, - }, - }; - - rsp.user_arg = userArg; - rsp.ofm_count = ofm.size(); - rsp.status = failed ? ETHOSU_CORE_STATUS_ERROR : ETHOSU_CORE_STATUS_OK; - - for (size_t i = 0; i < ofm.size(); ++i) { - rsp.ofm_size[i] = ofm[i].size; - } - - for (size_t i = 0; i < pmuEventConfig.size(); i++) { - rsp.pmu_event_config[i] = pmuEventConfig[i]; - } - rsp.pmu_cycle_counter_enable = pmuCycleCounterEnable; - for (size_t i = 0; i < pmuEventCount.size(); i++) { - rsp.pmu_event_count[i] = pmuEventCount[i]; - } - rsp.pmu_cycle_counter_count = pmuCycleCounterCount; - - LOG_INFO("Sending inference response. userArg=0x%" PRIx64 ", ofm_count=%" PRIu32 ", status=%" PRIu32 "\n", - rsp.user_arg, - rsp.ofm_count, - rsp.status); - - if (!queueOut.write(ETHOSU_CORE_MSG_INFERENCE_RSP, rsp)) { - LOG_ERR("Msg: Failed to write inference response. No mailbox message sent\n"); - } else { - mailbox.sendMessage(); - } -} - -void MessageProcess::mailboxCallback(void *userArg) { - MessageProcess *_this = reinterpret_cast<MessageProcess *>(userArg); - _this->handleIrq(); -} - -} // namespace MessageProcess diff --git a/drivers/mhu_v2/src/mhu_v2.cpp b/drivers/mhu_v2/src/mhu_v2.cpp index 3bcd256..1144a0f 100644 --- a/drivers/mhu_v2/src/mhu_v2.cpp +++ b/drivers/mhu_v2/src/mhu_v2.cpp @@ -197,12 +197,12 @@ void MHUv2::printAIDR(bool tx, bool rx) { if (tx) { aidr = getTxAIDR(); a = reinterpret_cast<struct aidr_t *>(&aidr); - LOG_INFO("TX MHUv2 reports: Major rev: %d, Minor rev: %d\n", a->ARCH_MAJOR_REV, a->ARCH_MINOR_REV); + LOG_INFO("TX MHUv2 reports: Major rev: %d, Minor rev: %d", a->ARCH_MAJOR_REV, a->ARCH_MINOR_REV); } if (rx) { aidr = getRxAIDR(); a = reinterpret_cast<struct aidr_t *>(&aidr); - LOG_INFO("RX MHUv2 reports: Major rev: %d, Minor rev: %d\n", a->ARCH_MAJOR_REV, a->ARCH_MINOR_REV); + LOG_INFO("RX MHUv2 reports: Major rev: %d, Minor rev: %d", a->ARCH_MAJOR_REV, a->ARCH_MINOR_REV); } } diff --git a/lib/ethosu_log/include/ethosu_log.h b/lib/ethosu_log/include/ethosu_log.h index 4564b98..bd460b3 100644 --- a/lib/ethosu_log/include/ethosu_log.h +++ b/lib/ethosu_log/include/ethosu_log.h @@ -46,35 +46,27 @@ #define LOG(f, ...) fprintf(stdout, f, ##__VA_ARGS__) #if ETHOSU_LOG_SEVERITY >= ETHOSU_LOG_ERR -#define LOG_ERR_N(f, ...) fprintf(stderr, f, ##__VA_ARGS__) -#define LOG_ERR(f, ...) LOG_ERR_N("E: " f " (%s:%d)", ##__VA_ARGS__, strrchr("/" __FILE__, '/') + 1, __LINE__) +#define LOG_ERR(f, ...) fprintf(stderr, "E: " f " (%s:%d)\n", ##__VA_ARGS__, strrchr("/" __FILE__, '/') + 1, __LINE__) #else #define LOG_ERR(f, ...) -#define LOG_ERR_N(f, ...) #endif #if ETHOSU_LOG_SEVERITY >= ETHOSU_LOG_WARN -#define LOG_WARN_N(f, ...) fprintf(stdout, f, ##__VA_ARGS__) -#define LOG_WARN(f, ...) LOG_WARN_N("W: " f, ##__VA_ARGS__) +#define LOG_WARN(f, ...) fprintf(stdout, "W: " f "\n", ##__VA_ARGS__) #else #define LOG_WARN(f, ...) -#define LOG_WARN_N(f, ...) #endif #if ETHOSU_LOG_SEVERITY >= ETHOSU_LOG_INFO -#define LOG_INFO_N(f, ...) fprintf(stdout, f, ##__VA_ARGS__) -#define LOG_INFO(f, ...) LOG_INFO_N("I: " f, ##__VA_ARGS__) +#define LOG_INFO(f, ...) fprintf(stdout, "I: " f "\n", ##__VA_ARGS__) #else #define LOG_INFO(f, ...) -#define LOG_INFO_N(f, ...) #endif #if ETHOSU_LOG_SEVERITY >= ETHOSU_LOG_DEBUG -#define LOG_DEBUG_N(f, ...) fprintf(stdout, f, ##__VA_ARGS__) -#define LOG_DEBUG(f, ...) LOG_DEBUG_N("D: %s(): " f, __FUNCTION__, ##__VA_ARGS__) +#define LOG_DEBUG(f, ...) fprintf(stdout, "D: %s(): " f "\n", __FUNCTION__, ##__VA_ARGS__) #else #define LOG_DEBUG(f, ...) -#define LOG_DEBUG_N(f, ...) #endif #endif
\ No newline at end of file |