mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 17:29:14 +08:00
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>
43 lines
938 B
C++
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
|