@@ -73,7 +73,7 @@ SvmMapOperation *SVMAllocsManager::MapOperationsTracker::get(const void *regionP
73
73
void SVMAllocsManager::addInternalAllocationsToResidencyContainer (uint32_t rootDeviceIndex,
74
74
ResidencyContainer &residencyContainer,
75
75
uint32_t requestedTypesMask) {
76
- std::unique_lock<SpinLock > lock (mtx);
76
+ std::shared_lock<std::shared_mutex > lock (mtx);
77
77
for (auto &allocation : this ->SVMAllocs .allocations ) {
78
78
if (rootDeviceIndex >= allocation.second .gpuAllocations .getGraphicsAllocations ().size ()) {
79
79
continue ;
@@ -90,7 +90,7 @@ void SVMAllocsManager::addInternalAllocationsToResidencyContainer(uint32_t rootD
90
90
}
91
91
92
92
void SVMAllocsManager::makeInternalAllocationsResident (CommandStreamReceiver &commandStreamReceiver, uint32_t requestedTypesMask) {
93
- std::unique_lock<SpinLock > lock (mtx);
93
+ std::shared_lock<std::shared_mutex > lock (mtx);
94
94
for (auto &allocation : this ->SVMAllocs .allocations ) {
95
95
if (allocation.second .memoryType & requestedTypesMask) {
96
96
auto gpuAllocation = allocation.second .gpuAllocations .getGraphicsAllocation (commandStreamReceiver.getRootDeviceIndex ());
@@ -163,7 +163,7 @@ void *SVMAllocsManager::createHostUnifiedMemoryAllocation(size_t size,
163
163
allocData.pageSizeForAlignment = pageSizeForAlignment;
164
164
allocData.setAllocId (this ->allocationsCounter ++);
165
165
166
- std::unique_lock<SpinLock > lock (mtx);
166
+ std::unique_lock<std::shared_mutex > lock (mtx);
167
167
this ->SVMAllocs .insert (allocData);
168
168
169
169
return usmPtr;
@@ -227,7 +227,7 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size,
227
227
allocData.device = memoryProperties.device ;
228
228
allocData.setAllocId (this ->allocationsCounter ++);
229
229
230
- std::unique_lock<SpinLock > lock (mtx);
230
+ std::unique_lock<std::shared_mutex > lock (mtx);
231
231
this ->SVMAllocs .insert (allocData);
232
232
return reinterpret_cast <void *>(unifiedMemoryAllocation->getGpuAddress ());
233
233
}
@@ -309,7 +309,7 @@ void *SVMAllocsManager::createUnifiedKmdMigratedAllocation(size_t size, const Sv
309
309
allocData.pageSizeForAlignment = pageSizeForAlignment;
310
310
allocData.setAllocId (this ->allocationsCounter ++);
311
311
312
- std::unique_lock<SpinLock > lock (mtx);
312
+ std::unique_lock<std::shared_mutex > lock (mtx);
313
313
this ->SVMAllocs .insert (allocData);
314
314
return allocationGpu->getUnderlyingBuffer ();
315
315
}
@@ -320,17 +320,17 @@ void SVMAllocsManager::setUnifiedAllocationProperties(GraphicsAllocation *alloca
320
320
}
321
321
322
322
SvmAllocationData *SVMAllocsManager::getSVMAlloc (const void *ptr) {
323
- std::unique_lock<SpinLock > lock (mtx);
323
+ std::shared_lock<std::shared_mutex > lock (mtx);
324
324
return SVMAllocs.get (ptr);
325
325
}
326
326
327
327
void SVMAllocsManager::insertSVMAlloc (const SvmAllocationData &svmAllocData) {
328
- std::unique_lock<SpinLock > lock (mtx);
328
+ std::unique_lock<std::shared_mutex > lock (mtx);
329
329
SVMAllocs.insert (svmAllocData);
330
330
}
331
331
332
332
void SVMAllocsManager::removeSVMAlloc (const SvmAllocationData &svmAllocData) {
333
- std::unique_lock<SpinLock > lock (mtx);
333
+ std::unique_lock<std::shared_mutex > lock (mtx);
334
334
SVMAllocs.remove (svmAllocData);
335
335
}
336
336
@@ -355,7 +355,7 @@ bool SVMAllocsManager::freeSVMAlloc(void *ptr, bool blocking) {
355
355
if (pageFaultManager) {
356
356
pageFaultManager->removeAllocation (ptr);
357
357
}
358
- std::unique_lock<SpinLock > lock (mtx);
358
+ std::unique_lock<std::shared_mutex > lock (mtx);
359
359
if (svmData->gpuAllocations .getAllocationType () == AllocationType::SVM_ZERO_COPY) {
360
360
freeZeroCopySvmAllocation (svmData);
361
361
} else {
@@ -396,7 +396,7 @@ void *SVMAllocsManager::createZeroCopySvmAllocation(size_t size, const SvmAlloca
396
396
}
397
397
allocData.size = size;
398
398
399
- std::unique_lock<SpinLock > lock (mtx);
399
+ std::unique_lock<std::shared_mutex > lock (mtx);
400
400
this ->SVMAllocs .insert (allocData);
401
401
return usmPtr;
402
402
}
@@ -460,7 +460,7 @@ void *SVMAllocsManager::createUnifiedAllocationWithDeviceStorage(size_t size, co
460
460
allocData.size = size;
461
461
allocData.setAllocId (this ->allocationsCounter ++);
462
462
463
- std::unique_lock<SpinLock > lock (mtx);
463
+ std::unique_lock<std::shared_mutex > lock (mtx);
464
464
this ->SVMAllocs .insert (allocData);
465
465
return svmPtr;
466
466
}
@@ -485,7 +485,7 @@ void SVMAllocsManager::freeSvmAllocationWithDeviceStorage(SvmAllocationData *svm
485
485
}
486
486
487
487
bool SVMAllocsManager::hasHostAllocations () {
488
- std::unique_lock<SpinLock > lock (mtx);
488
+ std::shared_lock<std::shared_mutex > lock (mtx);
489
489
for (auto &allocation : this ->SVMAllocs .allocations ) {
490
490
if (allocation.second .memoryType == InternalMemoryType::HOST_UNIFIED_MEMORY) {
491
491
return true ;
@@ -495,7 +495,7 @@ bool SVMAllocsManager::hasHostAllocations() {
495
495
}
496
496
497
497
void SVMAllocsManager::makeIndirectAllocationsResident (CommandStreamReceiver &commandStreamReceiver, uint32_t taskCount) {
498
- std::unique_lock<SpinLock > lock (mtx);
498
+ std::unique_lock<std::shared_mutex > lock (mtx);
499
499
bool parseAllAllocations = false ;
500
500
auto entry = indirectAllocationsResidency.find (&commandStreamReceiver);
501
501
@@ -527,7 +527,7 @@ void SVMAllocsManager::makeIndirectAllocationsResident(CommandStreamReceiver &co
527
527
}
528
528
529
529
void SVMAllocsManager::prepareIndirectAllocationForDestruction (SvmAllocationData *allocationData) {
530
- std::unique_lock<SpinLock > lock (mtx);
530
+ std::unique_lock<std::shared_mutex > lock (mtx);
531
531
if (this ->indirectAllocationsResidency .size () > 0u ) {
532
532
for (auto &internalAllocationsHandling : this ->indirectAllocationsResidency ) {
533
533
auto commandStreamReceiver = internalAllocationsHandling.first ;
@@ -543,7 +543,7 @@ void SVMAllocsManager::prepareIndirectAllocationForDestruction(SvmAllocationData
543
543
}
544
544
545
545
SvmMapOperation *SVMAllocsManager::getSvmMapOperation (const void *ptr) {
546
- std::unique_lock<SpinLock > lock (mtx);
546
+ std::shared_lock<std::shared_mutex > lock (mtx);
547
547
return svmMapOperations.get (ptr);
548
548
}
549
549
@@ -554,12 +554,12 @@ void SVMAllocsManager::insertSvmMapOperation(void *regionSvmPtr, size_t regionSi
554
554
svmMapOperation.offset = offset;
555
555
svmMapOperation.regionSize = regionSize;
556
556
svmMapOperation.readOnlyMap = readOnlyMap;
557
- std::unique_lock<SpinLock > lock (mtx);
557
+ std::unique_lock<std::shared_mutex > lock (mtx);
558
558
svmMapOperations.insert (svmMapOperation);
559
559
}
560
560
561
561
void SVMAllocsManager::removeSvmMapOperation (const void *regionSvmPtr) {
562
- std::unique_lock<SpinLock > lock (mtx);
562
+ std::unique_lock<std::shared_mutex > lock (mtx);
563
563
svmMapOperations.remove (regionSvmPtr);
564
564
}
565
565
0 commit comments