Fix multi thread usage of external host alloc

With this commit OpenCL will track if external host memory is used from
few threads and will secure to update task count in all threads before
destroing allocation.

Resolves: NEO-6807

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka
2022-04-21 08:51:02 +00:00
committed by Compute-Runtime-Automation
parent 1d7b99140c
commit 54eee2a88b
12 changed files with 185 additions and 10 deletions

View File

@@ -15,6 +15,7 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/string.h"
#include "shared/source/memory_manager/graphics_allocation.h"
#include "shared/source/memory_manager/surface.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/test/common/helpers/dispatch_flags_helper.h"
@@ -151,7 +152,12 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
++hostPtrSurfaceCreationMutexLockCount;
return CommandStreamReceiver::obtainHostPtrSurfaceCreationLock();
}
bool createAllocationForHostSurface(HostPtrSurface &surface, bool requiresL3Flush) override {
bool status = CommandStreamReceiver::createAllocationForHostSurface(surface, requiresL3Flush);
if (status)
surface.getAllocation()->hostPtrTaskCountAssignment--;
return status;
}
void postInitFlagsSetup() override {}
static constexpr size_t tagSize = 256;

View File

@@ -51,6 +51,20 @@ class MockGraphicsAllocation : public MemoryAllocation {
}
};
class MockGraphicsAllocationTaskCount : public MockGraphicsAllocation {
public:
uint32_t getTaskCount(uint32_t contextId) const override {
getTaskCountCalleedTimes++;
return MockGraphicsAllocation::getTaskCount(contextId);
}
void updateTaskCount(uint32_t newTaskCount, uint32_t contextId) override {
updateTaskCountCalleedTimes++;
MockGraphicsAllocation::updateTaskCount(newTaskCount, contextId);
}
static uint32_t getTaskCountCalleedTimes;
uint32_t updateTaskCountCalleedTimes = 0;
};
namespace GraphicsAllocationHelper {
static inline MultiGraphicsAllocation toMultiGraphicsAllocation(GraphicsAllocation *graphicsAllocation) {