Files
compute-runtime/shared/source/utilities/shared_pool_allocation.h
Fabian Zwoliński 7ef3880793 feature: implement pool allocator for gpuTimestampDeviceBuffer
The patch applies to Level Zero.
Only allocations < 2MB will be fetched from the pool.
Allocations are shared and reused within a given device.

Additionally, I added a new debug flag to control the allocator:
EnableTimestampPoolAllocator

Related-To: NEO-12287
Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
2025-04-02 14:28:56 +02:00

43 lines
938 B
C++

/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <mutex>
namespace NEO {
class GraphicsAllocation;
class SharedPoolAllocation {
public:
SharedPoolAllocation(GraphicsAllocation *graphicsAllocation, size_t offset, size_t size, std::mutex *mtx)
: graphicsAllocation(graphicsAllocation), offset(offset), size(size), mtx(*mtx){};
GraphicsAllocation *getGraphicsAllocation() const {
return graphicsAllocation;
}
size_t getOffset() const {
return offset;
}
size_t getSize() const {
return size;
}
std::unique_lock<std::mutex> obtainSharedAllocationLock() {
return std::unique_lock<std::mutex>(mtx);
}
private:
GraphicsAllocation *graphicsAllocation;
const size_t offset;
const size_t size;
std::mutex &mtx; // This mutex is shared across all users of this GA
};
} // namespace NEO