/* * Copyright (C) 2025 Intel Corporation * * SPDX-License-Identifier: MIT * */ #pragma once #include "shared/source/helpers/constants.h" #include "shared/source/helpers/non_copyable_or_moveable.h" #include "shared/source/utilities/buffer_pool_allocator.h" #include "shared/source/utilities/shared_pool_allocation.h" #include "shared/source/utilities/stackvec.h" #include namespace NEO { class GraphicsAllocation; class Device; using SharedTimestampAllocation = SharedPoolAllocation; class TimestampPool : public AbstractBuffersPool { using BaseType = AbstractBuffersPool; public: TimestampPool(Device *device, size_t poolSize); TimestampPool(const TimestampPool &) = delete; TimestampPool &operator=(const TimestampPool &) = delete; TimestampPool(TimestampPool &&pool) noexcept; TimestampPool &operator=(TimestampPool &&) = delete; ~TimestampPool() override; SharedTimestampAllocation *allocate(size_t size); const StackVec &getAllocationsVector(); private: Device *device; StackVec stackVec; std::unique_ptr mtx; }; class TimestampPoolAllocator : public AbstractBuffersAllocator { public: TimestampPoolAllocator(Device *device); bool isEnabled() const; SharedTimestampAllocation *requestGraphicsAllocationForTimestamp(size_t size); void freeSharedTimestampAllocation(SharedTimestampAllocation *sharedTimestampAllocation); size_t getDefaultPoolSize() const { return defaultPoolSize; } private: SharedTimestampAllocation *allocateFromPools(size_t size); size_t alignToPoolSize(size_t size) const; const size_t maxAllocationSize = 2 * MemoryConstants::megaByte; const size_t defaultPoolSize = 4 * MemoryConstants::megaByte; const size_t poolAlignment = MemoryConstants::pageSize2M; Device *device; std::mutex allocatorMtx; }; static_assert(NEO::NonCopyable); } // namespace NEO