Skip to content

Commit

Permalink
v4.19.0 (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
HailoRT-Automation authored Sep 29, 2024
1 parent 01e4c7f commit 3d67325
Show file tree
Hide file tree
Showing 357 changed files with 7,489 additions and 3,690 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.5.0)

find_program(CCACHE_PROGRAM ccache)
find_program(CLACHE_PROGRAM clcache)
Expand Down
6 changes: 6 additions & 0 deletions common/include/context_switch_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ typedef enum __attribute__((packed)) {
CONTEXT_SWITCH_DEFS__ACTION_TYPE_ACTIVATE_CACHE_INPUT,
CONTEXT_SWITCH_DEFS__ACTION_TYPE_ACTIVATE_CACHE_OUTPUT,
CONTEXT_SWITCH_DEFS__ACTION_TYPE_WAIT_FOR_CACHE_UPDATED,
CONTEXT_SWITCH_DEFS__ACTION_TYPE_SLEEP,
CONTEXT_SWITCH_DEFS__ACTION_TYPE_HALT,

/* Must be last */
CONTEXT_SWITCH_DEFS__ACTION_TYPE_COUNT
Expand Down Expand Up @@ -447,6 +449,10 @@ typedef struct {
uint8_t packed_vdma_channel_id;
} CONTEXT_SWITCH_DEFS__change_boundary_input_batch_t;

typedef struct {
uint32_t sleep_time;
} CONTEXT_SWITCH_DEFS__sleep_action_data_t;

#pragma pack(pop)

#ifdef __cplusplus
Expand Down
2 changes: 2 additions & 0 deletions common/include/control_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,8 @@ typedef struct {
uint8_t is_action_list_end;
uint32_t batch_counter_length;
uint32_t batch_counter;
uint32_t idle_time_length;
uint32_t idle_time;
uint32_t action_list_length;
uint8_t action_list[0];
} CONTROL_PROTOCOL__download_context_action_list_response_t;
Expand Down
1 change: 1 addition & 0 deletions common/include/firmware_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ Updating rules:
FIRMWARE_STATUS__X(CONTEXT_SWITCH_STATUS_INVALID_EXTERNAL_ACTION_LIST_ADDRESS)\
FIRMWARE_STATUS__X(CONTEXT_SWITCH_STATUS_INVALID_CACHE_SIZE)\
FIRMWARE_STATUS__X(CONTEXT_SWITCH_STATUS_INVALID_READ_OFFSET_SIZE)\
FIRMWARE_STATUS__X(CONTEXT_SWITCH_STATUS_INVALID_SLEEP_TIME)\
\
FIRMWARE_MODULE__X(FIRMWARE_MODULE__D2H_EVENT_MANAGER)\
FIRMWARE_STATUS__X(HAILO_D2H_EVENT_MANAGER_STATUS_MESSAGE_HIGH_PRIORITY_QUEUE_CREATE_FAILED)\
Expand Down
2 changes: 2 additions & 0 deletions hailort/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build/
build-*x86_64/
build-*aarch64/
dist/
/external/
12 changes: 6 additions & 6 deletions hailort/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.5.0)

option(HAILO_BUILD_PYBIND "Build Python binding" OFF)
option(HAILO_BUILD_EMULATOR "Build hailort for emulator" OFF)
option(HAILO_BUILD_UT "Build Unit Tests" OFF)
option(HAILO_BUILD_HW_DEBUG_TOOL "Build hw debug tool" OFF)
option(HAILO_INTERNAL_BUILD "Build internal hailort componments" OFF)
option(HAILO_BUILD_GSTREAMER "Compile gstreamer plugins" OFF)
option(HAILO_BUILD_EXAMPLES "Build examples" OFF)
option(HAILO_OFFLINE_COMPILATION "Don't download external dependencies" OFF)
option(HAILO_BUILD_SERVICE "Build hailort service" OFF)
option(HAILO_BUILD_PROFILER "Build hailort profiler" ON)
option(HAILO_COMPILE_WARNING_AS_ERROR "Add compilation flag for treating compilation warnings as errors" OFF)
option(HAILO_SUPPORT_PACKAGING "Create HailoRT package (internal)" OFF)
option(HAILO_BUILD_DOC "Build doc" OFF)
Expand All @@ -31,7 +29,7 @@ endif()

# Set firmware version
add_definitions( -DFIRMWARE_VERSION_MAJOR=4 )
add_definitions( -DFIRMWARE_VERSION_MINOR=18 )
add_definitions( -DFIRMWARE_VERSION_MINOR=19 )
add_definitions( -DFIRMWARE_VERSION_REVISION=0 )
if(HAILO_BUILD_SERVICE)
add_definitions( -DHAILO_SUPPORT_MULTI_PROCESS )
Expand Down Expand Up @@ -75,8 +73,10 @@ add_subdirectory(hrpc)
add_subdirectory(hrpc_protocol)
add_subdirectory(libhailort)
add_subdirectory(hailortcli)
if(HAILO_BUILD_HW_DEBUG_TOOL)
if(HAILO_INTERNAL_BUILD)
add_subdirectory(tools/hw_debug)
add_subdirectory(tools/pcie_tunnel)
add_subdirectory(tools/loopback_server)
endif()

if(HAILO_BUILD_SERVICE)
Expand Down
2 changes: 1 addition & 1 deletion hailort/LICENSE-3RD-PARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
| Catch2 | Catch2 Authors | BSL-1.0 | 2.13.7 | Cloned entire package | https://github.com/catchorg/Catch2 |
| protobuf | Google Inc. | BSD | 21.12 | Cloned entire package | https://github.com/protocolbuffers/protobuf |
| pybind11 | Wenzel Jakob | BSD | 2.10.1 | Cloned entire package | https://github.com/pybind/pybind11 |
| spdlog | Gabi Melman | MIT | 1.6.1 | Cloned entire package | https://github.com/gabime/spdlog |
| spdlog | Gabi Melman | MIT | 1.14.1 | Cloned entire package | https://github.com/gabime/spdlog |
| folly | Facebook, Inc. and its affiliates | Apache License 2.0 | v2020.08.17.00 | Copied only the file `folly/TokenBucket.h` | https://github.com/facebook/folly |
| nlohmann_json_cmake_fetchcontent | ArthurSonzogni | MIT License | v3.9.1 | Cloned entire package | https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent |
| readerwriterqueue | Cameron Desrochers | Simplified BSD | 1.0.3 | Cloned entire package | https://github.com/cameron314/readerwriterqueue |
Expand Down
2 changes: 1 addition & 1 deletion hailort/cmake/common_compiler_options.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.5.0)

FUNCTION(disable_exceptions target)
if(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion hailort/cmake/execute_cmake.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.5.0)

function(execute_process_in_clean_env)
cmake_parse_arguments(execute_process_in_clean_env "" "RESULT_VARIABLE" "" ${ARGN})
Expand Down
2 changes: 1 addition & 1 deletion hailort/cmake/external/pybind11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ if(NOT pybind11_POPULATED)
endif()
add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endif()
endif()
2 changes: 1 addition & 1 deletion hailort/cmake/external/spdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include(FetchContent)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
GIT_TAG 22a169bc319ac06948e7ee0be6b9b0ac81386604
GIT_TAG 27cb4c76708608465c413f6d0e6b8d99a4d84302 # version 1.14.1
GIT_SHALLOW TRUE
SOURCE_DIR ${HAILO_EXTERNAL_DIR}/spdlog-src
SUBBUILD_DIR ${HAILO_EXTERNAL_DIR}/spdlog-subbuild
Expand Down
9 changes: 8 additions & 1 deletion hailort/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.0)
cmake_minimum_required(VERSION 3.5.0)

if(WIN32)
set(HAILORT_COMMON_OS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/os/windows")
Expand All @@ -15,12 +15,16 @@ set(SRC_FILES
${HAILORT_COMMON_OS_DIR}/socket.cpp
${HAILORT_COMMON_OS_DIR}/process.cpp
${HAILORT_COMMON_OS_DIR}/os_utils.cpp
${HAILORT_COMMON_OS_DIR}/file_descriptor.cpp
${HAILORT_COMMON_OS_DIR}/mmap_buffer.cpp
${HAILORT_COMMON_OS_DIR}/shared_memory_buffer.cpp

${CMAKE_CURRENT_SOURCE_DIR}/barrier.cpp
${CMAKE_CURRENT_SOURCE_DIR}/file_utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/string_utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/event_internal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/fork_support.cpp
${CMAKE_CURRENT_SOURCE_DIR}/buffer_pool.cpp

${CMAKE_CURRENT_SOURCE_DIR}/device_measurements.cpp
)
Expand All @@ -29,6 +33,8 @@ if(WIN32)
# Windows only modules:
set(SRC_FILES ${SRC_FILES}
${HAILORT_COMMON_OS_DIR}/string_conversion.cpp
${HAILORT_COMMON_OS_DIR}/virtual_alloc_guard.cpp
${HAILORT_COMMON_OS_DIR}/named_mutex_guard.cpp
)
elseif(UNIX)
# Unix only modules
Expand All @@ -37,4 +43,5 @@ elseif(UNIX)
)
endif()


set(HAILORT_COMMON_CPP_SOURCES ${SRC_FILES} PARENT_SCOPE)
58 changes: 58 additions & 0 deletions hailort/common/buffer_pool.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright (c) 2024 Hailo Technologies Ltd. All rights reserved.
* Distributed under the MIT license (https://opensource.org/licenses/MIT)
**/
/**
* @file buffer_pool.cpp
* @brief Buffer pool implementation
**/

#include "buffer_pool.hpp"
#include "hailo/hailort.h"

namespace hailort
{

BasicBufferPool::BasicBufferPool(size_t buffer_size, std::vector<BufferPtr> &&buffers,
SpscQueue<BufferPtr> &&free_buffers_queue, size_t buffers_count) :
m_buffer_size(buffer_size),
m_buffers_count(buffers_count),
m_buffers(std::move(buffers)),
m_free_buffers_queue(std::move(free_buffers_queue))
{}

Expected<BufferPtr> BasicBufferPool::acquire_buffer()
{
TRY_WITH_ACCEPTABLE_STATUS(HAILO_SHUTDOWN_EVENT_SIGNALED, auto buffer,
m_free_buffers_queue.dequeue(DEFAULT_TRANSFER_TIMEOUT));
return buffer;
}

size_t BasicBufferPool::current_size()
{
return m_free_buffers_queue.size_approx();
}

hailo_status BasicBufferPool::return_to_pool(BufferPtr buffer)
{
CHECK(buffer->size() == m_buffer_size, HAILO_INTERNAL_FAILURE,
"Buffer size is not the same as expected for pool! ({} != {})", buffer->size(), m_buffer_size);

std::unique_lock<std::mutex> lock(m_mutex);
auto status = m_free_buffers_queue.enqueue(buffer);
CHECK_SUCCESS(status);

return HAILO_SUCCESS;
}

size_t BasicBufferPool::buffers_count()
{
return m_buffers_count;
}

size_t BasicBufferPool::buffer_size()
{
return m_buffer_size;
}

} /* namespace hailort */
55 changes: 55 additions & 0 deletions hailort/common/buffer_pool.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2024 Hailo Technologies Ltd. All rights reserved.
* Distributed under the MIT license (https://opensource.org/licenses/MIT)
**/
/**
* @file buffer_pool.hpp
* @brief Buffer pool
**/

#ifndef _HAILO_BUFFER_POOL_HPP_
#define _HAILO_BUFFER_POOL_HPP_

#include "hailo/hailort.h"
#include "hailo/hailort_common.hpp"
#include "hailo/buffer.hpp"
#include "hailo/vdevice.hpp"
#include "hailo/dma_mapped_buffer.hpp"
#include "common/thread_safe_queue.hpp"

#include <mutex>

namespace hailort
{

// TODO: HRT-12690 - Make other buffer pools to use this as base class
class BasicBufferPool
{
public:
BasicBufferPool(size_t buffer_size, std::vector<BufferPtr> &&buffers,
SpscQueue<BufferPtr> &&m_free_buffers_queue, size_t buffers_count);

BasicBufferPool(BasicBufferPool &&) = delete;
BasicBufferPool(const BasicBufferPool &) = delete;
BasicBufferPool &operator=(BasicBufferPool &&) = delete;
BasicBufferPool &operator=(const BasicBufferPool &) = delete;
virtual ~BasicBufferPool() = default;

Expected<BufferPtr> acquire_buffer();
size_t current_size();
hailo_status return_to_pool(BufferPtr buffer);
size_t buffers_count();
size_t buffer_size();

private:
size_t m_buffer_size;
size_t m_buffers_count;
std::vector<BufferPtr> m_buffers;
SpscQueue<BufferPtr> m_free_buffers_queue;
std::mutex m_mutex;
};
using BasicBufferPoolPtr = std::shared_ptr<BasicBufferPool>;

} /* namespace hailort */

#endif /* _HAILO_BUFFER_POOL_HPP_ */
6 changes: 6 additions & 0 deletions hailort/common/device_measurements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#include <atomic>


enum class ShouldMeasurePower {
AUTO_DETECT, // auto detect if should measure power, based on device.get_capabilities()
NO,
YES
};

class BaseMeasurement
{
public:
Expand Down
33 changes: 33 additions & 0 deletions hailort/common/env_vars.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2020-2024 Hailo Technologies Ltd. All rights reserved.
* Distributed under the MIT license (https://opensource.org/licenses/MIT)
**/
/**
* @file env_vars.hpp
* @brief: defines a set of environment variables used in the HailoRT
* **/

#ifndef HAILO_ENV_VARS_HPP_
#define HAILO_ENV_VARS_HPP_


namespace hailort
{

#define HAILORT_LOGGER_PATH_ENV_VAR ("HAILORT_LOGGER_PATH")

#define HAILORT_CONSOLE_LOGGER_LEVEL_ENV_VAR ("HAILORT_CONSOLE_LOGGER_LEVEL")

#define SCHEDULER_MON_ENV_VAR ("HAILO_MONITOR")
#define SCHEDULER_MON_ENV_VAR_VALUE ("1")

#define TRACE_ENV_VAR ("HAILO_TRACE")
#define TRACE_ENV_VAR_VALUE ("scheduler")
#define TRACE_ENV_VAR_TIME_IN_SECONDS_BOUNDED_DUMP ("HAILO_TRACE_TIME_IN_SECONDS_BOUNDED_DUMP")
#define TRACE_ENV_VAR_SIZE_IN_KB_BOUNDED_DUMP ("HAILO_TRACE_SIZE_IN_KB_BOUNDED_DUMP")

#define PROFILER_FILE_ENV_VAR ("HAILO_TRACE_PATH")

} /* namespace hailort */

#endif /* HAILO_ENV_VARS_HPP_ */
File renamed without changes.
12 changes: 7 additions & 5 deletions hailort/common/file_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ hailo_status FileReader::read(uint8_t *buffer, size_t n)
return m_fstream->good() ? HAILO_SUCCESS : HAILO_FILE_OPERATION_FAILURE;
}

hailo_status FileReader::read_from_offset(size_t offset, MemoryView &dst, size_t size)
hailo_status FileReader::read_from_offset(uint64_t offset, MemoryView dst, size_t size)
{
assert(nullptr != m_fstream);

Expand All @@ -93,10 +93,12 @@ hailo_status FileReader::open()
{
if (nullptr == m_fstream) { // The first call to open creates the ifstream object
m_fstream = std::make_shared<std::ifstream>(m_file_path, std::ios::in | std::ios::binary);
return m_fstream->good() ? HAILO_SUCCESS : HAILO_OPEN_FILE_FAILURE;
} else {
m_fstream->open(m_file_path, std::ios::in | std::ios::binary);
}
m_fstream->open(m_file_path, std::ios::in | std::ios::binary);
return m_fstream->good() ? HAILO_SUCCESS : HAILO_OPEN_FILE_FAILURE;

CHECK(m_fstream->good(), HAILO_OPEN_FILE_FAILURE, "Failed opening file, path: {}", m_file_path);
return HAILO_SUCCESS;
}

bool FileReader::is_open() const
Expand Down Expand Up @@ -173,7 +175,7 @@ hailo_status BufferReader::read(uint8_t *buffer, size_t n)
return HAILO_SUCCESS;
}

hailo_status BufferReader::read_from_offset(size_t offset, MemoryView &dst, size_t size)
hailo_status BufferReader::read_from_offset(uint64_t offset, MemoryView dst, size_t size)
{
memcpy(dst.data(), m_memview.data() + offset, size);
return HAILO_SUCCESS;
Expand Down
6 changes: 3 additions & 3 deletions hailort/common/file_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SeekableBytesReader
public:
virtual ~SeekableBytesReader() = default;
virtual hailo_status read(uint8_t *buffer, size_t n) = 0;
virtual hailo_status read_from_offset(size_t offset, MemoryView &dst, size_t n) = 0;
virtual hailo_status read_from_offset(uint64_t offset, MemoryView dst, size_t n) = 0;
virtual hailo_status open() = 0;
virtual bool is_open() const = 0;
virtual hailo_status seek(size_t position) = 0;
Expand All @@ -54,7 +54,7 @@ class FileReader : public SeekableBytesReader
FileReader(const std::string &file_path);

virtual hailo_status read(uint8_t *buffer, size_t n);
virtual hailo_status read_from_offset(size_t offset, MemoryView &dst, size_t n);
virtual hailo_status read_from_offset(uint64_t offset, MemoryView dst, size_t n);
virtual hailo_status open();
virtual bool is_open() const;
virtual hailo_status seek(size_t position);
Expand All @@ -78,7 +78,7 @@ class BufferReader : public SeekableBytesReader
BufferReader(const MemoryView &memview);

virtual hailo_status read(uint8_t *buffer, size_t n);
virtual hailo_status read_from_offset(size_t offset, MemoryView &dst, size_t n);
virtual hailo_status read_from_offset(uint64_t offset, MemoryView dst, size_t n);
virtual hailo_status open();
virtual bool is_open() const;
virtual hailo_status seek(size_t position);
Expand Down
Loading

0 comments on commit 3d67325

Please sign in to comment.