Files
compute-runtime/shared/source/utilities/pool_allocator_traits.h
Fabian Zwoliński c0abff9cf2 refactor: introduce generic pool allocator using traits pattern
Related-To: NEO-12287
Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
2025-10-28 13:21:03 +01:00

37 lines
1.2 KiB
C++

/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/constants.h"
#include "shared/source/memory_manager/allocation_properties.h"
#include <concepts>
namespace NEO {
class Device;
template <typename T>
concept PoolTraits = requires(Device *d, size_t s) {
{ T::allocationType } -> std::convertible_to<AllocationType>;
{ T::maxAllocationSize } -> std::convertible_to<size_t>;
{ T::defaultPoolSize } -> std::convertible_to<size_t>;
{ T::poolAlignment } -> std::convertible_to<size_t>;
{ T::createAllocationProperties(d, s) } -> std::same_as<AllocationProperties>;
};
struct TimestampPoolTraits {
static constexpr AllocationType allocationType = AllocationType::gpuTimestampDeviceBuffer;
static constexpr size_t maxAllocationSize = 2 * MemoryConstants::megaByte;
static constexpr size_t defaultPoolSize = 4 * MemoryConstants::megaByte;
static constexpr size_t poolAlignment = MemoryConstants::pageSize2M;
static AllocationProperties createAllocationProperties(Device *device, size_t poolSize);
};
} // namespace NEO