mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Move majority of utilities to the core dir
Related-To: NEO-3677 Change-Id: If2e876028b765ad3ecf5f75db8755623b82955b8 Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
1902523df2
commit
2e8e6bdb18
@ -8,6 +8,7 @@
|
||||
#include "api.h"
|
||||
|
||||
#include "core/helpers/aligned_memory.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
#include "runtime/accelerators/intel_motion_estimation.h"
|
||||
#include "runtime/api/additional_extensions.h"
|
||||
#include "runtime/aub/aub_center.h"
|
||||
@ -41,7 +42,6 @@
|
||||
#include "runtime/tracing/tracing_api.h"
|
||||
#include "runtime/tracing/tracing_notify.h"
|
||||
#include "runtime/utilities/api_intercept.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
#include "config.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/utilities/range.h"
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
||||
#include "runtime/builtin_kernels_simulation/scheduler_simulation.h"
|
||||
@ -29,7 +30,6 @@
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/program/block_kernel_manager.h"
|
||||
#include "runtime/program/printf_handler.h"
|
||||
#include "runtime/utilities/range.h"
|
||||
#include "runtime/utilities/tag_allocator.h"
|
||||
|
||||
#include "hw_cmds.h"
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
#include "core/command_stream/linear_stream.h"
|
||||
#include "core/utilities/idlist.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
#include "runtime/helpers/properties_helper.h"
|
||||
#include "runtime/memory_manager/residency_container.h"
|
||||
#include "runtime/utilities/idlist.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
|
||||
#include <vector>
|
||||
namespace NEO {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "runtime/utilities/arrayref.h"
|
||||
#include "core/utilities/arrayref.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "runtime/event/event.h"
|
||||
|
||||
#include "core/helpers/aligned_memory.h"
|
||||
#include "core/utilities/range.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
#include "public/cl_ext_private.h"
|
||||
#include "runtime/api/cl_types.h"
|
||||
#include "runtime/command_queue/command_queue.h"
|
||||
@ -22,8 +24,6 @@
|
||||
#include "runtime/mem_obj/mem_obj.h"
|
||||
#include "runtime/memory_manager/internal_allocation_storage.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "runtime/utilities/range.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
#include "runtime/utilities/tag_allocator.h"
|
||||
|
||||
#define OCLRT_NUM_TIMESTAMP_BITS (32)
|
||||
|
@ -6,6 +6,9 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/utilities/arrayref.h"
|
||||
#include "core/utilities/idlist.h"
|
||||
#include "core/utilities/iflist.h"
|
||||
#include "runtime/api/cl_types.h"
|
||||
#include "runtime/event/hw_timestamps.h"
|
||||
#include "runtime/helpers/base_object.h"
|
||||
@ -13,9 +16,6 @@
|
||||
#include "runtime/helpers/task_information.h"
|
||||
#include "runtime/os_interface/os_time.h"
|
||||
#include "runtime/os_interface/performance_counters.h"
|
||||
#include "runtime/utilities/arrayref.h"
|
||||
#include "runtime/utilities/idlist.h"
|
||||
#include "runtime/utilities/iflist.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
@ -6,8 +6,8 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/utilities/arrayref.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
#include "core/utilities/arrayref.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/utilities/iflist.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/utilities/iflist.h"
|
||||
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
#include "core/memory_manager/memory_constants.h"
|
||||
#include "core/utilities/reference_tracked_object.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/os_interface/device_factory.h"
|
||||
#include "runtime/utilities/reference_tracked_object.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
@ -8,8 +8,8 @@
|
||||
#pragma once
|
||||
#include "core/helpers/abort.h"
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
#include "core/utilities/reference_tracked_object.h"
|
||||
#include "runtime/api/dispatch.h"
|
||||
#include "runtime/utilities/reference_tracked_object.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
@ -8,11 +8,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/helpers/vec.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
#include "runtime/built_ins/builtins_dispatch_builder.h"
|
||||
#include "runtime/helpers/registered_method_dispatcher.h"
|
||||
#include "runtime/mem_obj/mem_obj.h"
|
||||
#include "runtime/memory_manager/surface.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/utilities/reference_tracked_object.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
#include "runtime/helpers/completion_stamp.h"
|
||||
#include "runtime/utilities/reference_tracked_object.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
|
||||
namespace NEO {
|
||||
struct FlushStampTrackingObj : public ReferenceTrackedObject<FlushStampTrackingObj> {
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "CL/cl_ext.h"
|
||||
#endif
|
||||
|
||||
#include "core/utilities/arrayref.h"
|
||||
#include "runtime/gmm_helper/gmm_lib.h"
|
||||
#include "runtime/utilities/arrayref.h"
|
||||
|
||||
namespace NEO {
|
||||
enum GFX3DSTATE_SURFACEFORMAT : unsigned short {
|
||||
|
@ -7,13 +7,13 @@
|
||||
|
||||
#pragma once
|
||||
#include "core/command_stream/linear_stream.h"
|
||||
#include "core/utilities/iflist.h"
|
||||
#include "runtime/helpers/blit_commands_helper.h"
|
||||
#include "runtime/helpers/completion_stamp.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/helpers/properties_helper.h"
|
||||
#include "runtime/helpers/timestamp_packet.h"
|
||||
#include "runtime/indirect_heap/indirect_heap.h"
|
||||
#include "runtime/utilities/iflist.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/utilities/idlist.h"
|
||||
#include "core/utilities/idlist.h"
|
||||
|
||||
namespace NEO {
|
||||
class DeferrableDeletion : public IDNode<DeferrableDeletion> {
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/utilities/idlist.h"
|
||||
#include "core/utilities/idlist.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include "core/helpers/ptr_math.h"
|
||||
#include "core/memory_manager/host_ptr_defines.h"
|
||||
#include "core/memory_manager/memory_constants.h"
|
||||
#include "core/utilities/idlist.h"
|
||||
#include "runtime/memory_manager/memory_pool.h"
|
||||
#include "runtime/utilities/idlist.h"
|
||||
|
||||
#include "engine_limits.h"
|
||||
#include "storage_info.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "core/helpers/aligned_memory.h"
|
||||
#include "core/helpers/basic_math.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/event/event.h"
|
||||
#include "runtime/event/hw_timestamps.h"
|
||||
@ -27,7 +28,6 @@
|
||||
#include "runtime/memory_manager/internal_allocation_storage.h"
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/os_interface/os_interface.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
#include "core/helpers/aligned_memory.h"
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
#include "runtime/os_interface/linux/drm_memory_manager.h"
|
||||
#include "runtime/os_interface/linux/drm_neo.h"
|
||||
#include "runtime/os_interface/linux/os_time_linux.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include "drm_neo.h"
|
||||
|
||||
#include "core/memory_manager/memory_constants.h"
|
||||
#include "core/utilities/directory.h"
|
||||
#include "runtime/os_interface/os_inc_base.h"
|
||||
#include "runtime/utilities/directory.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
#include "core/command_stream/preemption_mode.h"
|
||||
#include "core/utilities/reference_tracked_object.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
#include "runtime/utilities/reference_tracked_object.h"
|
||||
|
||||
#include "engine_node.h"
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "core/helpers/interlocked_max.h"
|
||||
#include "core/os_interface/windows/debug_registry_reader.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
#include "runtime/command_stream/preemption.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/gmm_helper/gmm.h"
|
||||
@ -26,7 +27,6 @@
|
||||
#include "runtime/os_interface/windows/wddm_residency_allocations_container.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "runtime/sku_info/operations/sku_info_receiver.h"
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
|
||||
#include "gmm_memory.h"
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/utilities/numeric.h"
|
||||
#include "core/utilities/numeric.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -7,44 +7,22 @@
|
||||
set(RUNTIME_SRCS_UTILITIES_BASE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api_intercept.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/arrayref.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/directory.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/iflist.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/idlist.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/numeric.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/perf_profiler.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/perf_profiler.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/range.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/reference_tracked_object.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/stackvec.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tag_allocator.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/timer_util.h
|
||||
)
|
||||
|
||||
get_property(NEO_CORE_UTILITIES GLOBAL PROPERTY NEO_CORE_UTILITIES)
|
||||
list(APPEND RUNTIME_SRCS_UTILITIES_BASE ${NEO_CORE_UTILITIES})
|
||||
|
||||
set(RUNTIME_SRCS_UTILITIES_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/directory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/timer_util.cpp
|
||||
)
|
||||
|
||||
get_property(NEO_CORE_UTILITIES_WINDOWS GLOBAL PROPERTY NEO_CORE_UTILITIES_WINDOWS)
|
||||
list(APPEND RUNTIME_SRCS_UTILITIES_WINDOWS ${NEO_CORE_UTILITIES_WINDOWS})
|
||||
|
||||
set(RUNTIME_SRCS_UTILITIES_LINUX
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/directory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/timer_util.cpp
|
||||
)
|
||||
|
||||
get_property(NEO_CORE_UTILITIES_LINUX GLOBAL PROPERTY NEO_CORE_UTILITIES_LINUX)
|
||||
list(APPEND RUNTIME_SRCS_UTILITIES_LINUX ${NEO_CORE_UTILITIES_LINUX})
|
||||
|
||||
set_property(GLOBAL PROPERTY RUNTIME_SRCS_UTILITIES_BASE ${RUNTIME_SRCS_UTILITIES_BASE})
|
||||
|
||||
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_UTILITIES_BASE})
|
||||
set_property(GLOBAL PROPERTY RUNTIME_SRCS_UTILITIES_BASE ${RUNTIME_SRCS_UTILITIES_BASE})
|
||||
set_property(GLOBAL PROPERTY RUNTIME_SRCS_UTILITIES_LINUX ${RUNTIME_SRCS_UTILITIES_LINUX})
|
||||
if(WIN32)
|
||||
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_UTILITIES_WINDOWS})
|
||||
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${NEO_CORE_UTILITIES_WINDOWS})
|
||||
else()
|
||||
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_UTILITIES_LINUX})
|
||||
target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${NEO_CORE_UTILITIES_LINUX})
|
||||
endif()
|
||||
|
@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
template <typename DataType>
|
||||
class ArrayRef {
|
||||
public:
|
||||
using iterator = DataType *;
|
||||
using const_iterator = const DataType *;
|
||||
|
||||
template <typename IteratorType>
|
||||
ArrayRef(IteratorType b, IteratorType e) {
|
||||
if (b != nullptr) {
|
||||
this->b = &*b;
|
||||
this->e = &*(e - 1) + 1;
|
||||
} else {
|
||||
this->b = nullptr;
|
||||
this->e = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename IteratorType>
|
||||
ArrayRef(IteratorType b, size_t s)
|
||||
: ArrayRef(b, b + s) {
|
||||
}
|
||||
|
||||
template <typename SequentialContainerType>
|
||||
ArrayRef(SequentialContainerType &ctr)
|
||||
: b(&*ctr.begin()), e(&*(ctr.end() - 1) + 1) {
|
||||
}
|
||||
|
||||
template <size_t Size>
|
||||
ArrayRef(DataType (&array)[Size])
|
||||
: b(&array[0]), e(&array[Size]) {
|
||||
}
|
||||
|
||||
ArrayRef() = default;
|
||||
|
||||
size_t size() const {
|
||||
return e - b;
|
||||
}
|
||||
|
||||
DataType &operator[](std::size_t idx) {
|
||||
return b[idx];
|
||||
}
|
||||
|
||||
const DataType &operator[](std::size_t idx) const {
|
||||
return b[idx];
|
||||
}
|
||||
|
||||
iterator begin() {
|
||||
return b;
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return b;
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return e;
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return e;
|
||||
}
|
||||
|
||||
void swap(ArrayRef &rhs) {
|
||||
std::swap(b, rhs.b);
|
||||
std::swap(e, rhs.e);
|
||||
}
|
||||
|
||||
operator ArrayRef<const DataType>() {
|
||||
return ArrayRef<const DataType>(b, e);
|
||||
}
|
||||
|
||||
private:
|
||||
DataType *b = nullptr;
|
||||
DataType *e = nullptr;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool operator==(const ArrayRef<T> &lhs,
|
||||
const ArrayRef<T> &rhs) {
|
||||
if (lhs.size() != rhs.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto lhsIt = lhs.begin();
|
||||
auto lhsEnd = lhs.end();
|
||||
auto rhsIt = rhs.begin();
|
||||
|
||||
for (; lhsIt != lhsEnd; ++lhsIt, ++rhsIt) {
|
||||
if (*lhsIt != *rhsIt) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Directory {
|
||||
public:
|
||||
static std::vector<std::string> getFiles(const std::string &path);
|
||||
};
|
||||
}; // namespace NEO
|
@ -1,471 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename NodeObjectType>
|
||||
struct IDNode {
|
||||
IDNode()
|
||||
: prev(nullptr),
|
||||
next(nullptr) {
|
||||
}
|
||||
|
||||
void insertOneNext(NodeObjectType &nd) {
|
||||
nd.next = next;
|
||||
if (next != nullptr) {
|
||||
next->prev = &nd;
|
||||
}
|
||||
nd.prev = static_cast<NodeObjectType *>(this);
|
||||
next = &nd;
|
||||
}
|
||||
|
||||
void insertOnePrev(NodeObjectType &nd) {
|
||||
if (prev != nullptr) {
|
||||
prev->next = &nd;
|
||||
}
|
||||
nd.next = static_cast<NodeObjectType *>(this);
|
||||
nd.prev = prev;
|
||||
prev = &nd;
|
||||
}
|
||||
|
||||
NodeObjectType *slice() {
|
||||
NodeObjectType *rest = next;
|
||||
next = nullptr;
|
||||
if (rest != nullptr) {
|
||||
rest->prev = nullptr;
|
||||
}
|
||||
return rest;
|
||||
}
|
||||
|
||||
void insertAllNext(NodeObjectType &rhs) {
|
||||
NodeObjectType *rhsTail = rhs.getTail();
|
||||
rhsTail->next = next;
|
||||
if (next != nullptr) {
|
||||
next->prev = rhsTail;
|
||||
}
|
||||
rhs.prev = static_cast<NodeObjectType *>(this);
|
||||
next = &rhs;
|
||||
}
|
||||
|
||||
NodeObjectType *getTail() {
|
||||
NodeObjectType *curr = static_cast<NodeObjectType *>(this);
|
||||
while (curr->next != nullptr) {
|
||||
curr = curr->next;
|
||||
}
|
||||
return curr;
|
||||
}
|
||||
|
||||
NodeObjectType *getHead() {
|
||||
NodeObjectType *curr = static_cast<NodeObjectType *>(this);
|
||||
while (curr->prev != nullptr) {
|
||||
curr = curr->prev;
|
||||
}
|
||||
return curr;
|
||||
}
|
||||
|
||||
std::unique_ptr<NodeObjectType> deleteThisAndAllNext() {
|
||||
NodeObjectType *curr = this->next;
|
||||
while (curr != nullptr) {
|
||||
auto n = curr->next;
|
||||
delete curr;
|
||||
curr = n;
|
||||
}
|
||||
if (this->prev != nullptr) {
|
||||
this->prev->next = nullptr;
|
||||
}
|
||||
this->next = nullptr;
|
||||
return std::unique_ptr<NodeObjectType>(static_cast<NodeObjectType *>(this));
|
||||
}
|
||||
|
||||
std::unique_ptr<NodeObjectType> deleteThisAndAllPrev() {
|
||||
NodeObjectType *curr = this->prev;
|
||||
while (curr != nullptr) {
|
||||
auto n = curr->prev;
|
||||
delete curr;
|
||||
curr = n;
|
||||
}
|
||||
if (this->next != nullptr) {
|
||||
this->next->prev = nullptr;
|
||||
}
|
||||
this->prev = nullptr;
|
||||
return std::unique_ptr<NodeObjectType>(static_cast<NodeObjectType *>(this));
|
||||
}
|
||||
|
||||
std::unique_ptr<NodeObjectType> deleteThisAndAllConnected() {
|
||||
deleteThisAndAllNext().release();
|
||||
return deleteThisAndAllPrev();
|
||||
}
|
||||
|
||||
size_t countSuccessors() const {
|
||||
const NodeObjectType *curr = static_cast<const NodeObjectType *>(this);
|
||||
size_t successors = 0;
|
||||
while (curr->next != nullptr) {
|
||||
curr = curr->next;
|
||||
++successors;
|
||||
}
|
||||
return successors;
|
||||
}
|
||||
|
||||
size_t countPredecessors() const {
|
||||
const NodeObjectType *curr = static_cast<const NodeObjectType *>(this);
|
||||
size_t successors = 0;
|
||||
while (curr->prev != nullptr) {
|
||||
curr = curr->prev;
|
||||
++successors;
|
||||
}
|
||||
return successors;
|
||||
}
|
||||
|
||||
size_t countThisAndAllConnected() const {
|
||||
return 1 + countPredecessors() + countSuccessors();
|
||||
}
|
||||
|
||||
bool isPredecessorOf(NodeObjectType &rhs) const {
|
||||
NodeObjectType *curr = next;
|
||||
while (curr != nullptr) {
|
||||
if (curr == &rhs) {
|
||||
return true;
|
||||
}
|
||||
curr = curr->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isSuccessorOf(NodeObjectType &lhs) const {
|
||||
NodeObjectType *curr = prev;
|
||||
while (curr != nullptr) {
|
||||
if (curr == &lhs) {
|
||||
return true;
|
||||
}
|
||||
curr = curr->prev;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isConnectedWith(NodeObjectType &node) const {
|
||||
if (this == &node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isSuccessorOf(node) || isPredecessorOf(node);
|
||||
}
|
||||
|
||||
NodeObjectType *prev;
|
||||
NodeObjectType *next;
|
||||
};
|
||||
|
||||
template <typename NodeObjectType, bool ThreadSafe = true, bool OwnsNodes = false, bool SupportRecursiveLock = true>
|
||||
class IDList {
|
||||
public:
|
||||
using ThisType = IDList<NodeObjectType, ThreadSafe, OwnsNodes, SupportRecursiveLock>;
|
||||
|
||||
IDList()
|
||||
: head(nullptr), tail(nullptr), locked(), spinLockedListener(nullptr) {
|
||||
locked.clear(std::memory_order_release);
|
||||
}
|
||||
|
||||
IDList(NodeObjectType *node)
|
||||
: head(node), tail(nullptr), locked(), spinLockedListener(nullptr) {
|
||||
locked.clear(std::memory_order_release);
|
||||
head = node;
|
||||
if (node == nullptr) {
|
||||
tail = nullptr;
|
||||
} else {
|
||||
tail = node->getTail();
|
||||
}
|
||||
}
|
||||
|
||||
~IDList() {
|
||||
this->cleanup();
|
||||
}
|
||||
|
||||
IDList(const IDList &) = delete;
|
||||
IDList &operator=(const IDList &) = delete;
|
||||
|
||||
void pushFrontOne(NodeObjectType &node) {
|
||||
processLocked<ThisType, &ThisType::pushFrontOneImpl>(&node);
|
||||
}
|
||||
|
||||
void pushTailOne(NodeObjectType &node) {
|
||||
processLocked<ThisType, &ThisType::pushTailOneImpl>(&node);
|
||||
}
|
||||
|
||||
std::unique_ptr<NodeObjectType> removeOne(NodeObjectType &node) {
|
||||
return std::unique_ptr<NodeObjectType>(processLocked<ThisType, &ThisType::removeOneImpl>(&node));
|
||||
}
|
||||
|
||||
std::unique_ptr<NodeObjectType> removeFrontOne() {
|
||||
return std::unique_ptr<NodeObjectType>(processLocked<ThisType, &ThisType::removeFrontOneImpl>(nullptr));
|
||||
}
|
||||
|
||||
NodeObjectType *detachSequence(NodeObjectType &first, NodeObjectType &last) {
|
||||
return processLocked<ThisType, &ThisType::detachSequenceImpl>(&first, &last);
|
||||
}
|
||||
|
||||
NodeObjectType *detachNodes() {
|
||||
return processLocked<ThisType, &ThisType::detachNodesImpl>();
|
||||
}
|
||||
|
||||
void splice(NodeObjectType &nodes) {
|
||||
processLocked<ThisType, &ThisType::spliceImpl>(&nodes);
|
||||
}
|
||||
|
||||
void deleteAll() {
|
||||
NodeObjectType *nodes = detachNodes();
|
||||
nodes->deleteThisAndAllNext();
|
||||
}
|
||||
|
||||
NodeObjectType *peekHead() {
|
||||
return processLocked<ThisType, &ThisType::peekHeadImpl>();
|
||||
}
|
||||
|
||||
NodeObjectType *peekTail() {
|
||||
return processLocked<ThisType, &ThisType::peekTailImpl>();
|
||||
}
|
||||
|
||||
bool peekIsEmpty() {
|
||||
return (peekHead() == nullptr);
|
||||
}
|
||||
|
||||
bool peekContains(NodeObjectType &node) {
|
||||
return (processLocked<ThisType, &ThisType::peekContainsImpl>(&node) != nullptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
NodeObjectType *peekHeadImpl(NodeObjectType *, void *) {
|
||||
return head;
|
||||
}
|
||||
NodeObjectType *peekTailImpl(NodeObjectType *, void *) {
|
||||
return tail;
|
||||
}
|
||||
template <bool C = OwnsNodes>
|
||||
typename std::enable_if<C, void>::type cleanup() {
|
||||
if (head != nullptr) {
|
||||
head->deleteThisAndAllNext();
|
||||
}
|
||||
head = nullptr;
|
||||
tail = nullptr;
|
||||
}
|
||||
|
||||
template <bool C = OwnsNodes>
|
||||
typename std::enable_if<!C, void>::type cleanup() {
|
||||
;
|
||||
}
|
||||
|
||||
void notifySpinLocked() {
|
||||
if (spinLockedListener != nullptr) {
|
||||
(*spinLockedListener)(*this);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, NodeObjectType *(T::*Process)(NodeObjectType *node1, void *data), bool C1 = ThreadSafe, bool C2 = SupportRecursiveLock>
|
||||
typename std::enable_if<C1 && !C2, NodeObjectType *>::type processLocked(NodeObjectType *node1 = nullptr, void *data = nullptr) {
|
||||
while (locked.test_and_set(std::memory_order_acquire)) {
|
||||
notifySpinLocked();
|
||||
}
|
||||
|
||||
NodeObjectType *ret = nullptr;
|
||||
try {
|
||||
ret = (static_cast<T *>(this)->*Process)(node1, data);
|
||||
} catch (...) {
|
||||
locked.clear(std::memory_order_release);
|
||||
throw;
|
||||
}
|
||||
|
||||
locked.clear(std::memory_order_release);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T, NodeObjectType *(T::*Process)(NodeObjectType *node1, void *data), bool C1 = ThreadSafe, bool C2 = SupportRecursiveLock>
|
||||
typename std::enable_if<C1 && C2, NodeObjectType *>::type processLocked(NodeObjectType *node1 = nullptr, void *data = nullptr) {
|
||||
std::thread::id currentThreadId = std::this_thread::get_id();
|
||||
if (lockOwner == currentThreadId) {
|
||||
return (static_cast<T *>(this)->*Process)(node1, data);
|
||||
}
|
||||
|
||||
while (locked.test_and_set(std::memory_order_acquire)) {
|
||||
notifySpinLocked();
|
||||
}
|
||||
|
||||
lockOwner = currentThreadId;
|
||||
|
||||
NodeObjectType *ret = nullptr;
|
||||
try {
|
||||
ret = (static_cast<T *>(this)->*Process)(node1, data);
|
||||
} catch (...) {
|
||||
lockOwner = std::thread::id();
|
||||
locked.clear(std::memory_order_release);
|
||||
throw;
|
||||
}
|
||||
|
||||
lockOwner = std::thread::id();
|
||||
locked.clear(std::memory_order_release);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T, NodeObjectType *(T::*Process)(NodeObjectType *node, void *data), bool C = ThreadSafe>
|
||||
typename std::enable_if<!C, NodeObjectType *>::type processLocked(NodeObjectType *node = nullptr, void *data = nullptr) {
|
||||
return (this->*Process)(node, data);
|
||||
}
|
||||
|
||||
NodeObjectType *pushFrontOneImpl(NodeObjectType *node, void *) {
|
||||
if (head == nullptr) {
|
||||
DEBUG_BREAK_IF(tail != nullptr);
|
||||
pushTailOneImpl(node, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
node->prev = nullptr;
|
||||
node->next = head;
|
||||
head->prev = node;
|
||||
head = node;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NodeObjectType *pushTailOneImpl(NodeObjectType *node, void *) {
|
||||
if (tail == nullptr) {
|
||||
DEBUG_BREAK_IF(head != nullptr);
|
||||
node->prev = nullptr;
|
||||
node->next = nullptr;
|
||||
head = node;
|
||||
tail = node;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
node->next = nullptr;
|
||||
node->prev = tail;
|
||||
tail->next = node;
|
||||
tail = node;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NodeObjectType *removeOneImpl(NodeObjectType *node, void *) {
|
||||
if (node->prev != nullptr) {
|
||||
node->prev->next = node->next;
|
||||
}
|
||||
if (node->next != nullptr) {
|
||||
node->next->prev = node->prev;
|
||||
}
|
||||
if (tail == node) {
|
||||
tail = node->prev;
|
||||
}
|
||||
if (head == node) {
|
||||
head = node->next;
|
||||
}
|
||||
node->prev = nullptr;
|
||||
node->next = nullptr;
|
||||
return node;
|
||||
}
|
||||
|
||||
NodeObjectType *removeFrontOneImpl(NodeObjectType *, void *) {
|
||||
if (head == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return removeOneImpl(head, nullptr);
|
||||
}
|
||||
|
||||
NodeObjectType *detachSequenceImpl(NodeObjectType *node, void *data) {
|
||||
NodeObjectType *first = node;
|
||||
NodeObjectType *last = static_cast<NodeObjectType *>(data);
|
||||
if (first == last) {
|
||||
return removeOneImpl(first, nullptr);
|
||||
}
|
||||
|
||||
if (first->prev != nullptr) {
|
||||
first->prev->next = last->next;
|
||||
}
|
||||
|
||||
if (last->next != nullptr) {
|
||||
last->next->prev = first->prev;
|
||||
}
|
||||
|
||||
if (head == first) {
|
||||
head = last->next;
|
||||
}
|
||||
|
||||
if (tail == last) {
|
||||
tail = first->prev;
|
||||
}
|
||||
|
||||
first->prev = nullptr;
|
||||
last->next = nullptr;
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
NodeObjectType *detachNodesImpl(NodeObjectType *, void *) {
|
||||
NodeObjectType *rest = head;
|
||||
head = nullptr;
|
||||
tail = nullptr;
|
||||
return rest;
|
||||
}
|
||||
|
||||
NodeObjectType *spliceImpl(NodeObjectType *node, void *) {
|
||||
if (tail == nullptr) {
|
||||
DEBUG_BREAK_IF(head != nullptr);
|
||||
head = node;
|
||||
node->prev = nullptr;
|
||||
tail = node->getTail();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
tail->next = node;
|
||||
node->prev = tail;
|
||||
tail = node->getTail();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NodeObjectType *peekContainsImpl(NodeObjectType *node, void *) {
|
||||
NodeObjectType *curr = head;
|
||||
while (curr != nullptr) {
|
||||
if (curr == node) {
|
||||
return node;
|
||||
}
|
||||
curr = curr->next;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NodeObjectType *head;
|
||||
NodeObjectType *tail;
|
||||
|
||||
std::atomic_flag locked;
|
||||
std::atomic<std::thread::id> lockOwner;
|
||||
void (*spinLockedListener)(ThisType &list);
|
||||
};
|
||||
|
||||
template <typename NodeObjectType>
|
||||
struct IDNodeRef : IDNode<IDNodeRef<NodeObjectType>> {
|
||||
IDNodeRef(NodeObjectType *ref)
|
||||
: ref(ref) {
|
||||
}
|
||||
NodeObjectType *ref;
|
||||
};
|
||||
|
||||
template <typename NodeObjectType, bool ThreadSafe = true, bool OwnsNodes = true>
|
||||
class IDRefList : public IDList<IDNodeRef<NodeObjectType>, ThreadSafe, OwnsNodes> {
|
||||
public:
|
||||
void pushRefFrontOne(NodeObjectType &node) {
|
||||
auto refNode = std::unique_ptr<IDNodeRef<NodeObjectType>>(new IDNodeRef<NodeObjectType>(&node));
|
||||
this->pushFrontOne(*refNode);
|
||||
refNode.release();
|
||||
}
|
||||
};
|
||||
} // namespace NEO
|
@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename NodeObjectType, bool Atomic>
|
||||
struct PtrType {
|
||||
};
|
||||
|
||||
template <typename NodeObjectType>
|
||||
struct PtrType<NodeObjectType, true> {
|
||||
using type = std::atomic<NodeObjectType *>;
|
||||
};
|
||||
|
||||
template <typename NodeObjectType>
|
||||
struct PtrType<NodeObjectType, false> {
|
||||
using type = NodeObjectType *;
|
||||
};
|
||||
|
||||
template <typename NodeObjectType, bool Atomic>
|
||||
using PtrType_t = typename PtrType<NodeObjectType, Atomic>::type;
|
||||
|
||||
template <typename NodeObjectType>
|
||||
struct IFNode {
|
||||
IFNode()
|
||||
: next(nullptr) {
|
||||
}
|
||||
|
||||
void insertOneNext(NodeObjectType &nd) {
|
||||
nd.next = next;
|
||||
next = &nd;
|
||||
}
|
||||
|
||||
NodeObjectType *slice() {
|
||||
NodeObjectType *rest = next;
|
||||
next = nullptr;
|
||||
return rest;
|
||||
}
|
||||
|
||||
void insertAllNext(NodeObjectType &rhs) {
|
||||
NodeObjectType *rhsTail = rhs.getTail();
|
||||
rhsTail->next = next;
|
||||
next = &rhs;
|
||||
}
|
||||
|
||||
NodeObjectType *getTail() {
|
||||
NodeObjectType *curr = static_cast<NodeObjectType *>(this);
|
||||
while (curr->next != nullptr) {
|
||||
curr = curr->next;
|
||||
}
|
||||
return curr;
|
||||
}
|
||||
|
||||
std::unique_ptr<NodeObjectType> deleteThisAndAllNext() {
|
||||
NodeObjectType *curr = this->next;
|
||||
while (curr != nullptr) {
|
||||
auto n = curr->next;
|
||||
delete curr;
|
||||
curr = n;
|
||||
}
|
||||
this->next = nullptr;
|
||||
return std::unique_ptr<NodeObjectType>(static_cast<NodeObjectType *>(this));
|
||||
}
|
||||
|
||||
size_t countSuccessors() const {
|
||||
const NodeObjectType *curr = static_cast<const NodeObjectType *>(this);
|
||||
size_t successors = 0;
|
||||
while (curr->next != nullptr) {
|
||||
curr = curr->next;
|
||||
++successors;
|
||||
}
|
||||
return successors;
|
||||
}
|
||||
|
||||
NodeObjectType *next;
|
||||
};
|
||||
|
||||
template <typename NodeObjectType, bool ThreadSafe = true, bool OwnsNodes = false>
|
||||
class IFList {
|
||||
public:
|
||||
IFList()
|
||||
: head(nullptr) {
|
||||
}
|
||||
|
||||
IFList(NodeObjectType *node) {
|
||||
head = node;
|
||||
}
|
||||
|
||||
~IFList() {
|
||||
this->cleanup();
|
||||
}
|
||||
|
||||
IFList(const IFList &) = delete;
|
||||
IFList &operator=(const IFList &) = delete;
|
||||
|
||||
template <bool C = ThreadSafe>
|
||||
typename std::enable_if<C, void>::type pushFrontOne(NodeObjectType &node) {
|
||||
node.next = head;
|
||||
compareExchangeHead(node.next, &node);
|
||||
}
|
||||
|
||||
template <bool C = ThreadSafe>
|
||||
typename std::enable_if<C, NodeObjectType *>::type detachNodes() {
|
||||
NodeObjectType *rest = head;
|
||||
compareExchangeHead(rest, nullptr);
|
||||
return rest;
|
||||
}
|
||||
|
||||
template <bool C = ThreadSafe>
|
||||
typename std::enable_if<!C, void>::type pushFrontOne(NodeObjectType &node) {
|
||||
node.next = head;
|
||||
head = &node;
|
||||
}
|
||||
|
||||
template <bool C = ThreadSafe>
|
||||
typename std::enable_if<!C, NodeObjectType *>::type detachNodes() {
|
||||
NodeObjectType *rest = head;
|
||||
head = nullptr;
|
||||
return rest;
|
||||
}
|
||||
|
||||
template <bool C = ThreadSafe>
|
||||
typename std::enable_if<!C, void>::type splice(NodeObjectType &nodes) {
|
||||
if (head == nullptr) {
|
||||
head = &nodes;
|
||||
} else {
|
||||
head->getTail()->next = &nodes;
|
||||
}
|
||||
}
|
||||
|
||||
void deleteAll() {
|
||||
NodeObjectType *nodes = detachNodes();
|
||||
if (nodes != nullptr) {
|
||||
nodes->deleteThisAndAllNext();
|
||||
}
|
||||
}
|
||||
|
||||
NodeObjectType *peekHead() {
|
||||
return head;
|
||||
}
|
||||
|
||||
bool peekIsEmpty() {
|
||||
return (peekHead() == nullptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
template <bool C = OwnsNodes>
|
||||
typename std::enable_if<C, void>::type cleanup() {
|
||||
deleteAll();
|
||||
}
|
||||
|
||||
template <bool C = OwnsNodes>
|
||||
typename std::enable_if<!C, void>::type cleanup() {
|
||||
;
|
||||
}
|
||||
|
||||
template <bool C = ThreadSafe>
|
||||
typename std::enable_if<C, void>::type compareExchangeHead(NodeObjectType *&expected, NodeObjectType *desired) {
|
||||
while (!std::atomic_compare_exchange_weak(&head, &expected, desired)) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
PtrType_t<NodeObjectType, ThreadSafe> head;
|
||||
};
|
||||
|
||||
template <typename NodeObjectType>
|
||||
struct IFNodeRef : IFNode<IFNodeRef<NodeObjectType>> {
|
||||
IFNodeRef(NodeObjectType *ref)
|
||||
: ref(ref) {
|
||||
}
|
||||
NodeObjectType *ref;
|
||||
};
|
||||
|
||||
template <typename NodeObjectType, bool ThreadSafe = true, bool OwnsNodes = true>
|
||||
class IFRefList : public IFList<IFNodeRef<NodeObjectType>, ThreadSafe, OwnsNodes> {
|
||||
public:
|
||||
void pushRefFrontOne(NodeObjectType &node) {
|
||||
auto up = std::unique_ptr<IFNodeRef<NodeObjectType>>(new IFNodeRef<NodeObjectType>(&node));
|
||||
this->pushFrontOne(*up);
|
||||
up.release();
|
||||
}
|
||||
};
|
||||
} // namespace NEO
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/utilities/directory.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <dirent.h>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
std::vector<std::string> Directory::getFiles(const std::string &path) {
|
||||
std::vector<std::string> files;
|
||||
|
||||
DIR *dir = opendir(path.c_str());
|
||||
if (dir == nullptr) {
|
||||
return files;
|
||||
}
|
||||
|
||||
struct dirent *entry = nullptr;
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (entry->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string fullPath;
|
||||
fullPath += path;
|
||||
fullPath += "/";
|
||||
fullPath += entry->d_name;
|
||||
|
||||
files.push_back(fullPath);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
return files;
|
||||
}
|
||||
}; // namespace NEO
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/utilities/timer_util.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Timer::TimerImpl {
|
||||
|
||||
public:
|
||||
TimerImpl() {
|
||||
}
|
||||
|
||||
~TimerImpl() {
|
||||
}
|
||||
|
||||
void start() {
|
||||
*((std::chrono::high_resolution_clock::time_point *)&m_startTime) = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void end() {
|
||||
*((std::chrono::high_resolution_clock::time_point *)&m_endTime) = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
long long int get() {
|
||||
long long int nanosecondTime = 0;
|
||||
std::chrono::duration<double> diffTime = std::chrono::duration_cast<std::chrono::duration<double>>(*(reinterpret_cast<std::chrono::high_resolution_clock::time_point *>(&m_endTime)) - *(reinterpret_cast<std::chrono::high_resolution_clock::time_point *>(&m_startTime)));
|
||||
nanosecondTime = (long long int)(diffTime.count() * (double)1000000000.0);
|
||||
return nanosecondTime;
|
||||
}
|
||||
|
||||
long long getStart() {
|
||||
long long ret = (long long)(reinterpret_cast<std::chrono::high_resolution_clock::time_point *>(&m_startTime)->time_since_epoch().count());
|
||||
return ret;
|
||||
}
|
||||
|
||||
long long getEnd() {
|
||||
long long ret = (long long)(reinterpret_cast<std::chrono::high_resolution_clock::time_point *>(&m_endTime)->time_since_epoch().count());
|
||||
return ret;
|
||||
}
|
||||
|
||||
TimerImpl &operator=(const TimerImpl &t) {
|
||||
m_startTime = t.m_startTime;
|
||||
return *this;
|
||||
}
|
||||
|
||||
static void setFreq() {
|
||||
}
|
||||
|
||||
private:
|
||||
std::chrono::high_resolution_clock::time_point m_startTime;
|
||||
std::chrono::high_resolution_clock::time_point m_endTime;
|
||||
};
|
||||
|
||||
Timer::Timer() {
|
||||
timerImpl = new TimerImpl();
|
||||
}
|
||||
|
||||
Timer::~Timer() {
|
||||
delete timerImpl;
|
||||
}
|
||||
|
||||
void Timer::start() {
|
||||
timerImpl->start();
|
||||
}
|
||||
|
||||
void Timer::end() {
|
||||
timerImpl->end();
|
||||
}
|
||||
|
||||
long long int Timer::get() {
|
||||
return timerImpl->get();
|
||||
}
|
||||
|
||||
long long Timer::getStart() {
|
||||
return timerImpl->getStart();
|
||||
}
|
||||
|
||||
long long Timer::getEnd() {
|
||||
return timerImpl->getEnd();
|
||||
}
|
||||
|
||||
Timer &Timer::operator=(const Timer &t) {
|
||||
*timerImpl = *(t.timerImpl);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Timer::setFreq() {
|
||||
TimerImpl::setFreq();
|
||||
}
|
||||
}; // namespace NEO
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <uint8_t NumBits>
|
||||
struct StorageType;
|
||||
|
||||
template <>
|
||||
struct StorageType<8> {
|
||||
using Type = uint8_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StorageType<16> {
|
||||
using Type = uint16_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StorageType<32> {
|
||||
using Type = uint32_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct StorageType<64> {
|
||||
using Type = uint64_t;
|
||||
};
|
||||
|
||||
template <uint8_t NumBits>
|
||||
struct StorageType {
|
||||
using Type = typename StorageType<NumBits + 1>::Type;
|
||||
};
|
||||
|
||||
template <uint8_t NumBits>
|
||||
using StorageTypeT = typename StorageType<NumBits>::Type;
|
||||
|
||||
template <uint8_t IntegerBits, uint8_t FractionalBits, uint8_t TotalBits = IntegerBits + FractionalBits>
|
||||
struct UnsignedFixedPointValue {
|
||||
UnsignedFixedPointValue(float v) {
|
||||
fromFloatingPoint(v);
|
||||
}
|
||||
|
||||
StorageTypeT<TotalBits> &getRawAccess() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
static constexpr float getMaxRepresentableFloat() {
|
||||
return getMaxRepresentableFloatingPointValue<float>();
|
||||
}
|
||||
|
||||
float asFloat() {
|
||||
return asFloatPointType<float>();
|
||||
}
|
||||
|
||||
protected:
|
||||
template <typename FloatingType>
|
||||
static constexpr FloatingType getMaxRepresentableFloatingPointValue() {
|
||||
return static_cast<FloatingType>(
|
||||
static_cast<FloatingType>((1U << IntegerBits) - 1) + (static_cast<FloatingType>((1U << FractionalBits) - 1) / (1U << FractionalBits)));
|
||||
}
|
||||
|
||||
template <typename FloatingType>
|
||||
void fromFloatingPoint(FloatingType val) {
|
||||
auto maxFloatVal = getMaxRepresentableFloatingPointValue<FloatingType>();
|
||||
// clamp to [0, maxFloatVal]
|
||||
val = (val < FloatingType{0}) ? FloatingType{0} : val;
|
||||
val = (val > maxFloatVal) ? maxFloatVal : val;
|
||||
|
||||
// scale to fixed point representation
|
||||
this->storage = static_cast<StorageTypeT<TotalBits>>(val * (1U << FractionalBits));
|
||||
}
|
||||
|
||||
template <typename FloatingType>
|
||||
FloatingType asFloatPointType() {
|
||||
return static_cast<FloatingType>(storage) / (1U << FractionalBits);
|
||||
}
|
||||
|
||||
StorageTypeT<TotalBits> storage = 0;
|
||||
};
|
||||
|
||||
using FixedU4D8 = UnsignedFixedPointValue<4, 8>;
|
||||
} // namespace NEO
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "runtime/utilities/perf_profiler.h"
|
||||
|
||||
#include "runtime/utilities/stackvec.h"
|
||||
#include "core/utilities/stackvec.h"
|
||||
|
||||
#include "os_inc.h"
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/utilities/timer_util.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/utilities/timer_util.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <fstream>
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <iterator>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename DataType>
|
||||
struct Range {
|
||||
using iterator = DataType *;
|
||||
using const_iterator = const DataType *;
|
||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||
|
||||
Range(DataType *base, size_t count)
|
||||
: begIt(base), endIt(base + count) {
|
||||
}
|
||||
|
||||
template <typename SequentialContainerT, typename BeginT = decltype(((SequentialContainerT *)nullptr)->size())>
|
||||
Range(SequentialContainerT &container)
|
||||
: Range(&*container.begin(), container.size()) {
|
||||
}
|
||||
|
||||
template <typename T, size_t S>
|
||||
Range(T (&base)[S])
|
||||
: Range(&base[0], S) {
|
||||
}
|
||||
|
||||
iterator begin() {
|
||||
return begIt;
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
return endIt;
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
return begIt;
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
return endIt;
|
||||
}
|
||||
|
||||
reverse_iterator rbegin() {
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator rbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
reverse_iterator rend() {
|
||||
return reverse_iterator(end()) + (endIt - begIt);
|
||||
}
|
||||
|
||||
const_reverse_iterator rend() const {
|
||||
return const_reverse_iterator(end()) + (endIt - begIt);
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return begIt == endIt;
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
return endIt - begIt;
|
||||
}
|
||||
|
||||
iterator begIt;
|
||||
iterator endIt;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline Range<T> CreateRange(T *base, size_t count) {
|
||||
return Range<T>(base, count);
|
||||
}
|
||||
} // namespace NEO
|
@ -1,178 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
template <typename CT = int32_t>
|
||||
class RefCounter {
|
||||
public:
|
||||
RefCounter()
|
||||
: val(0) {
|
||||
}
|
||||
|
||||
CT peek() const {
|
||||
CT curr = val.load();
|
||||
DEBUG_BREAK_IF(curr < 0);
|
||||
return curr;
|
||||
}
|
||||
|
||||
void inc() {
|
||||
CT curr = ++val;
|
||||
DEBUG_BREAK_IF(curr < 1);
|
||||
((void)(curr));
|
||||
}
|
||||
|
||||
bool dec() {
|
||||
CT curr = --val;
|
||||
DEBUG_BREAK_IF(curr < 0);
|
||||
return (curr == 0);
|
||||
}
|
||||
|
||||
CT decAndReturnCurrent() {
|
||||
return --val;
|
||||
}
|
||||
|
||||
bool peekIsZero() const {
|
||||
return (val == 0);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::atomic<CT> val;
|
||||
};
|
||||
|
||||
template <typename DerivedClass>
|
||||
class ReferenceTrackedObject;
|
||||
|
||||
template <typename DataType>
|
||||
class unique_ptr_if_unused : public std::unique_ptr<DataType, void (*)(DataType *)> {
|
||||
using DeleterFuncType = void (*)(DataType *);
|
||||
|
||||
public:
|
||||
unique_ptr_if_unused()
|
||||
: std::unique_ptr<DataType, DeleterFuncType>(nullptr, dontDelete) {
|
||||
}
|
||||
|
||||
unique_ptr_if_unused(DataType *ptr, bool unused, DeleterFuncType customDeleter = nullptr)
|
||||
: std::unique_ptr<DataType, DeleterFuncType>(ptr, unused ? chooseDeleter(ptr, customDeleter) : dontDelete) {
|
||||
}
|
||||
|
||||
bool isUnused() const {
|
||||
return (this->get_deleter() != dontDelete);
|
||||
}
|
||||
|
||||
private:
|
||||
static DeleterFuncType chooseDeleter(DataType *inPtr, DeleterFuncType customDeleter) {
|
||||
DeleterFuncType deleter = customDeleter;
|
||||
if (customDeleter == nullptr) {
|
||||
deleter = getObjDeleter(inPtr);
|
||||
}
|
||||
|
||||
if (deleter == nullptr) {
|
||||
deleter = &doDelete;
|
||||
}
|
||||
|
||||
return deleter;
|
||||
}
|
||||
|
||||
template <typename DT = DataType>
|
||||
static typename std::enable_if<std::is_base_of<ReferenceTrackedObject<DataType>, DT>::value, DeleterFuncType>::type getObjDeleter(DataType *inPtr) {
|
||||
if (inPtr != nullptr) {
|
||||
return inPtr->getCustomDeleter();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename DT = DataType>
|
||||
static typename std::enable_if<!std::is_base_of<ReferenceTrackedObject<DataType>, DT>::value, DeleterFuncType>::type getObjDeleter(DataType *inPtr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void doDelete(DataType *ptr) {
|
||||
delete ptr;
|
||||
}
|
||||
|
||||
static void dontDelete(DataType *ptr) {
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
// This class is needed for having both internal and external (api)
|
||||
// reference counters
|
||||
// Note : we need both counters because an OCL app can release an OCL object
|
||||
// while this object is still needed/valid (e.g. events with callbacks),
|
||||
// so we need to have a way of tracking internal usage of these object.
|
||||
// At the same time, we can't use one refcount for both internal and external
|
||||
// (retain/release api) usage because an OCL application can query object's
|
||||
// refcount (this refcount should not be contaminated by our internal usage models)
|
||||
// Note : internal refcount accumulates also api refcounts (i.e. incrementing/decrementing
|
||||
// api refcount will increment/decrement internal refcount as well) - so, object
|
||||
// deletion is based on single/atomic decision "if(--internalRefcount == 0)"
|
||||
template <typename DerivedClass>
|
||||
class ReferenceTrackedObject {
|
||||
public:
|
||||
virtual ~ReferenceTrackedObject();
|
||||
|
||||
int32_t getRefInternalCount() const {
|
||||
return refInternal.peek();
|
||||
}
|
||||
|
||||
void incRefInternal() {
|
||||
refInternal.inc();
|
||||
}
|
||||
|
||||
unique_ptr_if_unused<DerivedClass> decRefInternal() {
|
||||
auto customDeleter = tryGetCustomDeleter();
|
||||
auto current = refInternal.decAndReturnCurrent();
|
||||
bool unused = (current == 0);
|
||||
UNRECOVERABLE_IF(current < 0);
|
||||
return unique_ptr_if_unused<DerivedClass>(static_cast<DerivedClass *>(this), unused, customDeleter);
|
||||
}
|
||||
|
||||
int32_t getRefApiCount() const {
|
||||
return refApi.peek();
|
||||
}
|
||||
|
||||
void incRefApi() {
|
||||
refApi.inc();
|
||||
refInternal.inc();
|
||||
}
|
||||
|
||||
unique_ptr_if_unused<DerivedClass> decRefApi() {
|
||||
refApi.dec();
|
||||
return decRefInternal();
|
||||
}
|
||||
|
||||
using DeleterFuncType = void (*)(DerivedClass *);
|
||||
DeleterFuncType getCustomDeleter() const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool peekHasZeroRefcounts() const {
|
||||
return refInternal.peekIsZero();
|
||||
}
|
||||
|
||||
private:
|
||||
DeleterFuncType tryGetCustomDeleter() const {
|
||||
const DerivedClass *asDerivedObj = static_cast<const DerivedClass *>(this);
|
||||
return asDerivedObj->getCustomDeleter();
|
||||
}
|
||||
|
||||
RefCounter<> refInternal;
|
||||
RefCounter<> refApi;
|
||||
};
|
||||
template <typename DerivedClass>
|
||||
inline ReferenceTrackedObject<DerivedClass>::~ReferenceTrackedObject() {
|
||||
DEBUG_BREAK_IF(refInternal.peek() > 1);
|
||||
}
|
||||
} // namespace NEO
|
@ -1,337 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
template <typename DataType, size_t OnStackCapacity>
|
||||
class StackVec {
|
||||
public:
|
||||
using iterator = DataType *;
|
||||
using const_iterator = const DataType *;
|
||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||
|
||||
static const size_t onStackCaps = OnStackCapacity;
|
||||
|
||||
StackVec() = default;
|
||||
|
||||
template <typename ItType>
|
||||
StackVec(ItType beginIt, ItType endIt)
|
||||
: dynamicMem(nullptr) {
|
||||
size_t count = (endIt - beginIt);
|
||||
if (count > OnStackCapacity) {
|
||||
dynamicMem = new std::vector<DataType>(beginIt, endIt);
|
||||
return;
|
||||
}
|
||||
|
||||
while (beginIt != endIt) {
|
||||
push_back(*beginIt);
|
||||
++beginIt;
|
||||
}
|
||||
onStackSize = count;
|
||||
}
|
||||
|
||||
StackVec(const StackVec &rhs)
|
||||
: dynamicMem(nullptr) {
|
||||
if (onStackCaps < rhs.size()) {
|
||||
dynamicMem = new std::vector<DataType>(rhs.begin(), rhs.end());
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &v : rhs) {
|
||||
push_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
explicit StackVec(size_t initialSize)
|
||||
: StackVec() {
|
||||
resize(initialSize);
|
||||
}
|
||||
|
||||
StackVec(std::initializer_list<DataType> init) {
|
||||
reserve(init.size());
|
||||
for (const auto &obj : init) {
|
||||
push_back(obj);
|
||||
}
|
||||
}
|
||||
|
||||
StackVec &operator=(const StackVec &rhs) {
|
||||
clear();
|
||||
|
||||
if (this->dynamicMem != nullptr) {
|
||||
this->dynamicMem->insert(dynamicMem->end(), rhs.begin(), rhs.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (onStackCaps < rhs.size()) {
|
||||
this->dynamicMem = new std::vector<DataType>(rhs.begin(), rhs.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
for (const auto &v : rhs) {
|
||||
push_back(v);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
StackVec(StackVec &&rhs)
|
||||
: dynamicMem(nullptr) {
|
||||
if (rhs.dynamicMem != nullptr) {
|
||||
std::swap(this->dynamicMem, rhs.dynamicMem);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto &v : rhs) {
|
||||
push_back(v);
|
||||
}
|
||||
}
|
||||
|
||||
StackVec &operator=(StackVec &&rhs) {
|
||||
clear();
|
||||
|
||||
if (rhs.dynamicMem != nullptr) {
|
||||
std::swap(this->dynamicMem, rhs.dynamicMem);
|
||||
return *this;
|
||||
}
|
||||
|
||||
if (this->dynamicMem != nullptr) {
|
||||
this->dynamicMem->insert(this->dynamicMem->end(), rhs.begin(), rhs.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
for (const auto &v : rhs) {
|
||||
push_back(v);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
~StackVec() {
|
||||
if (dynamicMem != nullptr) {
|
||||
delete dynamicMem;
|
||||
return;
|
||||
}
|
||||
clear();
|
||||
}
|
||||
|
||||
size_t size() const {
|
||||
if (dynamicMem) {
|
||||
return dynamicMem->size();
|
||||
}
|
||||
return onStackSize;
|
||||
}
|
||||
|
||||
size_t capacity() const {
|
||||
if (dynamicMem) {
|
||||
return dynamicMem->capacity();
|
||||
}
|
||||
return OnStackCapacity;
|
||||
}
|
||||
|
||||
void reserve(size_t newCapacity) {
|
||||
if (newCapacity > onStackCaps) {
|
||||
ensureDynamicMem();
|
||||
dynamicMem->reserve(newCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
if (dynamicMem) {
|
||||
dynamicMem->clear();
|
||||
return;
|
||||
}
|
||||
clearStackObjects();
|
||||
}
|
||||
|
||||
void push_back(const DataType &v) { // NOLINT
|
||||
if (onStackSize == onStackCaps) {
|
||||
ensureDynamicMem();
|
||||
}
|
||||
|
||||
if (dynamicMem) {
|
||||
dynamicMem->push_back(v);
|
||||
return;
|
||||
}
|
||||
|
||||
new (onStackMem + onStackSize) DataType(v);
|
||||
++onStackSize;
|
||||
}
|
||||
|
||||
DataType &operator[](std::size_t idx) {
|
||||
if (dynamicMem) {
|
||||
return (*dynamicMem)[idx];
|
||||
}
|
||||
return *(onStackMem + idx);
|
||||
}
|
||||
|
||||
const DataType &operator[](std::size_t idx) const {
|
||||
if (dynamicMem) {
|
||||
return (*dynamicMem)[idx];
|
||||
}
|
||||
return *(onStackMem + idx);
|
||||
}
|
||||
|
||||
iterator begin() {
|
||||
if (dynamicMem) {
|
||||
return dynamicMem->data();
|
||||
}
|
||||
|
||||
return onStackMem;
|
||||
}
|
||||
|
||||
reverse_iterator rbegin() {
|
||||
return reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_reverse_iterator crbegin() const {
|
||||
return const_reverse_iterator(end());
|
||||
}
|
||||
|
||||
const_iterator begin() const {
|
||||
if (dynamicMem) {
|
||||
return dynamicMem->data();
|
||||
}
|
||||
|
||||
return onStackMem;
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
if (dynamicMem) {
|
||||
return dynamicMem->data() + dynamicMem->size();
|
||||
}
|
||||
|
||||
return onStackMem + onStackSize;
|
||||
}
|
||||
|
||||
reverse_iterator rend() {
|
||||
return reverse_iterator(begin());
|
||||
}
|
||||
|
||||
const_reverse_iterator crend() const {
|
||||
return const_reverse_iterator(begin());
|
||||
}
|
||||
|
||||
const_iterator end() const {
|
||||
if (dynamicMem) {
|
||||
return dynamicMem->data() + dynamicMem->size();
|
||||
}
|
||||
|
||||
return onStackMem + onStackSize;
|
||||
}
|
||||
|
||||
void resize(size_t newSize) {
|
||||
this->resizeImpl(newSize, nullptr);
|
||||
}
|
||||
|
||||
void resize(size_t newSize, const DataType &value) {
|
||||
resizeImpl(newSize, &value);
|
||||
}
|
||||
|
||||
private:
|
||||
void resizeImpl(size_t newSize, const DataType *value) {
|
||||
// new size does not fit into internal mem
|
||||
if (newSize > onStackCaps) {
|
||||
ensureDynamicMem();
|
||||
}
|
||||
|
||||
// memory already backed by stl vector
|
||||
if (dynamicMem != nullptr) {
|
||||
if (value != nullptr) {
|
||||
dynamicMem->resize(newSize, *value);
|
||||
} else {
|
||||
dynamicMem->resize(newSize);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (newSize <= onStackSize) {
|
||||
// trim elements
|
||||
clearStackObjects(newSize, onStackSize - newSize);
|
||||
onStackSize = newSize;
|
||||
return;
|
||||
}
|
||||
|
||||
// add new elements
|
||||
if (value != nullptr) {
|
||||
// copy-construct elements
|
||||
while (onStackSize < newSize) {
|
||||
new (onStackMem + onStackSize) DataType(*value);
|
||||
++onStackSize;
|
||||
}
|
||||
} else {
|
||||
// default-construct elements
|
||||
while (onStackSize < newSize) {
|
||||
new (onStackMem + onStackSize) DataType();
|
||||
++onStackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ensureDynamicMem() {
|
||||
if (dynamicMem == nullptr) {
|
||||
dynamicMem = new std::vector<DataType>();
|
||||
if (onStackSize > 0) {
|
||||
dynamicMem->reserve(onStackSize);
|
||||
for (auto it = onStackMem, end = onStackMem + onStackSize; it != end; ++it) {
|
||||
dynamicMem->push_back(std::move(*it));
|
||||
}
|
||||
clearStackObjects();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void clearStackObjects() {
|
||||
clearStackObjects(0, onStackSize);
|
||||
onStackSize = 0;
|
||||
}
|
||||
|
||||
void clearStackObjects(size_t offset, size_t count) {
|
||||
UNRECOVERABLE_IF(offset + count > onStackSize);
|
||||
for (auto it = onStackMem + offset, end = onStackMem + offset + count; it != end; ++it) {
|
||||
it->~DataType();
|
||||
}
|
||||
}
|
||||
|
||||
alignas(alignof(DataType)) char onStackMemRawBytes[sizeof(DataType[onStackCaps])];
|
||||
std::vector<DataType> *dynamicMem = nullptr;
|
||||
DataType *const onStackMem = reinterpret_cast<DataType *const>(onStackMemRawBytes);
|
||||
size_t onStackSize = 0;
|
||||
};
|
||||
|
||||
template <typename T, size_t LhsStackCaps, size_t RhsStackCaps>
|
||||
bool operator==(const StackVec<T, LhsStackCaps> &lhs,
|
||||
const StackVec<T, RhsStackCaps> &rhs) {
|
||||
if (lhs.size() != rhs.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto lhsIt = lhs.begin();
|
||||
auto lhsEnd = lhs.end();
|
||||
auto rhsIt = rhs.begin();
|
||||
|
||||
for (; lhsIt != lhsEnd; ++lhsIt, ++rhsIt) {
|
||||
if (*lhsIt != *rhsIt) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T, size_t LhsStackCaps, size_t RhsStackCaps>
|
||||
bool operator!=(const StackVec<T, LhsStackCaps> &lhs,
|
||||
const StackVec<T, RhsStackCaps> &rhs) {
|
||||
return false == (lhs == rhs);
|
||||
}
|
@ -8,8 +8,8 @@
|
||||
#pragma once
|
||||
#include "core/helpers/aligned_memory.h"
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
#include "core/utilities/idlist.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
#include "runtime/utilities/idlist.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <type_traits>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Timer {
|
||||
public:
|
||||
Timer();
|
||||
Timer(const Timer &) = delete;
|
||||
|
||||
~Timer();
|
||||
|
||||
void start();
|
||||
|
||||
void end();
|
||||
|
||||
long long int get();
|
||||
|
||||
long long getStart();
|
||||
long long getEnd();
|
||||
|
||||
Timer &operator=(const Timer &t);
|
||||
|
||||
static void setFreq();
|
||||
|
||||
private:
|
||||
class TimerImpl;
|
||||
TimerImpl *timerImpl;
|
||||
};
|
||||
}; // namespace NEO
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/utilities/directory.h"
|
||||
|
||||
#include "core/os_interface/windows/windows_wrapper.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
std::vector<std::string> Directory::getFiles(const std::string &path) {
|
||||
std::vector<std::string> files;
|
||||
std::string newPath;
|
||||
|
||||
WIN32_FIND_DATAA ffd;
|
||||
HANDLE hFind = INVALID_HANDLE_VALUE;
|
||||
|
||||
if (path.c_str()[path.size() - 1] == '/') {
|
||||
return files;
|
||||
} else {
|
||||
newPath = path + "/*";
|
||||
}
|
||||
|
||||
hFind = FindFirstFileA(newPath.c_str(), &ffd);
|
||||
|
||||
if (INVALID_HANDLE_VALUE == hFind) {
|
||||
return files;
|
||||
}
|
||||
|
||||
do {
|
||||
files.push_back(path + "/" + ffd.cFileName);
|
||||
} while (FindNextFileA(hFind, &ffd) != 0);
|
||||
|
||||
FindClose(hFind);
|
||||
return files;
|
||||
}
|
||||
}; // namespace NEO
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/utilities/timer_util.h"
|
||||
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
#include "core/os_interface/windows/windows_wrapper.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class Timer::TimerImpl {
|
||||
public:
|
||||
TimerImpl() {
|
||||
memset(&m_startTime, 0, sizeof(LARGE_INTEGER));
|
||||
memset(&m_endTime, 0, sizeof(LARGE_INTEGER));
|
||||
}
|
||||
|
||||
~TimerImpl() {
|
||||
}
|
||||
|
||||
LARGE_INTEGER start() {
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&m_startTime);
|
||||
return m_startTime;
|
||||
}
|
||||
|
||||
LARGE_INTEGER end() {
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)&m_endTime);
|
||||
return m_endTime;
|
||||
}
|
||||
|
||||
long long int get() {
|
||||
auto timeDelta = (double)(m_endTime.QuadPart - m_startTime.QuadPart);
|
||||
timeDelta /= (double)mFrequency.QuadPart;
|
||||
timeDelta *= 1000000000.0;
|
||||
|
||||
if (m_endTime.QuadPart < m_startTime.QuadPart) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
}
|
||||
return (long long)timeDelta;
|
||||
}
|
||||
|
||||
long long getStart() {
|
||||
return (long long)(((LARGE_INTEGER *)&m_startTime)->QuadPart);
|
||||
}
|
||||
|
||||
long long getEnd() {
|
||||
|
||||
return (long long)(((LARGE_INTEGER *)&m_endTime)->QuadPart);
|
||||
}
|
||||
|
||||
TimerImpl &operator=(const TimerImpl &t) {
|
||||
m_startTime = t.m_startTime;
|
||||
return *this;
|
||||
}
|
||||
|
||||
static void setFreq() {
|
||||
QueryPerformanceFrequency(&mFrequency);
|
||||
}
|
||||
|
||||
public:
|
||||
static LARGE_INTEGER mFrequency;
|
||||
|
||||
private:
|
||||
LARGE_INTEGER m_startTime;
|
||||
LARGE_INTEGER m_endTime;
|
||||
};
|
||||
|
||||
LARGE_INTEGER Timer::TimerImpl::mFrequency = {
|
||||
{{0}},
|
||||
};
|
||||
|
||||
Timer::Timer() {
|
||||
timerImpl = new TimerImpl();
|
||||
}
|
||||
|
||||
Timer::~Timer() {
|
||||
delete timerImpl;
|
||||
}
|
||||
|
||||
void Timer::start() {
|
||||
timerImpl->start();
|
||||
}
|
||||
|
||||
void Timer::end() {
|
||||
timerImpl->end();
|
||||
}
|
||||
|
||||
long long int Timer::get() {
|
||||
return timerImpl->get();
|
||||
}
|
||||
|
||||
long long Timer::getStart() {
|
||||
return timerImpl->getStart();
|
||||
}
|
||||
|
||||
long long Timer::getEnd() {
|
||||
return timerImpl->getEnd();
|
||||
}
|
||||
|
||||
Timer &Timer::operator=(const Timer &t) {
|
||||
*timerImpl = *(t.timerImpl);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Timer::setFreq() {
|
||||
TimerImpl::setFreq();
|
||||
}
|
||||
}; // namespace NEO
|
Reference in New Issue
Block a user