mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 01:04:57 +08:00
Add allocation ID to be retrieved by L0 getMemAllocProperties
zeMemGetAllocProperties() specifies an ID for the allocation can be retrieved by the application. This can be used by applications to identify the allocation throughout the application lifetime. We were currently returning as id the same allocation address. This patch fixes it to return a true unique identifier for the allocation. Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
05b161fffc
commit
522d2550ee
@@ -160,6 +160,7 @@ void *SVMAllocsManager::createHostUnifiedMemoryAllocation(size_t size,
|
||||
allocData.memoryType = memoryProperties.memoryType;
|
||||
allocData.allocationFlagsProperty = memoryProperties.allocationFlags;
|
||||
allocData.device = nullptr;
|
||||
allocData.setAllocId(this->allocationsCounter++);
|
||||
|
||||
std::unique_lock<SpinLock> lock(mtx);
|
||||
this->SVMAllocs.insert(allocData);
|
||||
@@ -220,6 +221,7 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size,
|
||||
allocData.memoryType = memoryProperties.memoryType;
|
||||
allocData.allocationFlagsProperty = memoryProperties.allocationFlags;
|
||||
allocData.device = memoryProperties.device;
|
||||
allocData.setAllocId(this->allocationsCounter++);
|
||||
|
||||
std::unique_lock<SpinLock> lock(mtx);
|
||||
this->SVMAllocs.insert(allocData);
|
||||
@@ -297,6 +299,7 @@ void *SVMAllocsManager::createUnifiedKmdMigratedAllocation(size_t size, const Sv
|
||||
allocData.cpuAllocation = nullptr;
|
||||
allocData.device = unifiedMemoryProperties.device;
|
||||
allocData.size = size;
|
||||
allocData.setAllocId(this->allocationsCounter++);
|
||||
|
||||
std::unique_lock<SpinLock> lock(mtx);
|
||||
this->SVMAllocs.insert(allocData);
|
||||
@@ -442,6 +445,7 @@ void *SVMAllocsManager::createUnifiedAllocationWithDeviceStorage(size_t size, co
|
||||
allocData.cpuAllocation = allocationCpu;
|
||||
allocData.device = unifiedMemoryProperties.device;
|
||||
allocData.size = size;
|
||||
allocData.setAllocId(this->allocationsCounter++);
|
||||
|
||||
std::unique_lock<SpinLock> lock(mtx);
|
||||
this->SVMAllocs.insert(allocData);
|
||||
|
||||
@@ -33,6 +33,7 @@ struct SvmAllocationData {
|
||||
this->device = svmAllocData.device;
|
||||
this->size = svmAllocData.size;
|
||||
this->memoryType = svmAllocData.memoryType;
|
||||
this->allocId = svmAllocData.allocId;
|
||||
for (auto allocation : svmAllocData.gpuAllocations.getGraphicsAllocations()) {
|
||||
if (allocation) {
|
||||
this->gpuAllocations.addAllocation(allocation);
|
||||
@@ -46,9 +47,17 @@ struct SvmAllocationData {
|
||||
InternalMemoryType memoryType = InternalMemoryType::SVM;
|
||||
MemoryProperties allocationFlagsProperty;
|
||||
Device *device = nullptr;
|
||||
void setAllocId(uint32_t id) {
|
||||
allocId = id;
|
||||
}
|
||||
|
||||
uint32_t getAllocId() {
|
||||
return allocId;
|
||||
}
|
||||
|
||||
protected:
|
||||
const uint32_t maxRootDeviceIndex;
|
||||
uint32_t allocId = std::numeric_limits<uint32_t>::max();
|
||||
};
|
||||
|
||||
struct SvmMapOperation {
|
||||
@@ -139,6 +148,7 @@ class SVMAllocsManager {
|
||||
void *createUnifiedAllocationWithDeviceStorage(size_t size, const SvmAllocationProperties &svmProperties, const UnifiedMemoryProperties &unifiedMemoryProperties);
|
||||
void freeSvmAllocationWithDeviceStorage(SvmAllocationData *svmData);
|
||||
bool hasHostAllocations();
|
||||
std::atomic<uint32_t> allocationsCounter = 0;
|
||||
|
||||
protected:
|
||||
void *createZeroCopySvmAllocation(size_t size, const SvmAllocationProperties &svmProperties,
|
||||
|
||||
Reference in New Issue
Block a user