-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01e4c7f
commit 3d67325
Showing
357 changed files
with
7,489 additions
and
3,690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
build/ | ||
build-*x86_64/ | ||
build-*aarch64/ | ||
dist/ | ||
/external/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.