mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
performance(ocl): add usm allocation pooling flag
EnableDeviceUsmAllocationPool and EnableHostUsmAllocationPool for device and host allocations respectively. Pool size will be set to flag value * MB. Allocation size threshold to be pooled is 1MB. Pools are created per context. Related-To: NEO-9700 Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
047438850d
commit
2fe3804cc2
@@ -6,8 +6,12 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
@@ -38,15 +42,17 @@ class BaseSortedPointerWithValueVector {
|
||||
allocations.erase(removeIt);
|
||||
}
|
||||
|
||||
ValueType *get(const void *ptr) {
|
||||
typename Container::iterator getImpl(const void *ptr) {
|
||||
if (allocations.size() == 0) {
|
||||
return nullptr;
|
||||
return allocations.end();
|
||||
}
|
||||
|
||||
if (nullptr == ptr) {
|
||||
return nullptr;
|
||||
return allocations.end();
|
||||
}
|
||||
|
||||
DEBUG_BREAK_IF(allocations.size() > static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
|
||||
int begin = 0;
|
||||
int end = static_cast<int>(allocations.size() - 1);
|
||||
while (end >= begin) {
|
||||
@@ -54,7 +60,7 @@ class BaseSortedPointerWithValueVector {
|
||||
const auto &allocation = allocations[currentPos];
|
||||
|
||||
if (compareFunctor(allocation.second, ptr, allocation.first)) {
|
||||
return allocation.second.get();
|
||||
return allocations.begin() + currentPos;
|
||||
} else if (ptr < allocation.first) {
|
||||
end = currentPos - 1;
|
||||
continue;
|
||||
@@ -63,7 +69,24 @@ class BaseSortedPointerWithValueVector {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return allocations.end();
|
||||
}
|
||||
|
||||
std::unique_ptr<ValueType> extract(const void *ptr) {
|
||||
std::unique_ptr<ValueType> retVal{};
|
||||
auto it = getImpl(ptr);
|
||||
if (it != allocations.end()) {
|
||||
retVal.swap(it->second);
|
||||
allocations.erase(it);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
ValueType *get(const void *ptr) {
|
||||
auto it = getImpl(ptr);
|
||||
if (it != allocations.end()) {
|
||||
return it->second.get();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user