Code cleanup for reduced GPU address space

Change-Id: Ibce79ddbe1f03dac1813b5dc2356a9db86b60200
Signed-off-by: Pawel Wilma <pawel.wilma@intel.com>
This commit is contained in:
Pawel Wilma
2018-09-10 12:50:45 +02:00
committed by sys_ocldev
parent 7ec0989eea
commit 8c1db4fb2f
7 changed files with 39 additions and 14 deletions

View File

@@ -342,10 +342,6 @@ class CommandQueueHw : public CommandQueue {
bool slmUsed,
EventBuilder &externalEventBuilder,
std::unique_ptr<PrintfHandler> printfHandler);
bool isFullRangeSvm() {
return this->device->getHardwareInfo().capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress;
}
protected:
MOCKABLE_VIRTUAL void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo){};
MOCKABLE_VIRTUAL bool createAllocationForHostSurface(HostPtrSurface &surface);

View File

@@ -737,12 +737,7 @@ bool CommandQueueHw<GfxFamily>::createAllocationForHostSurface(HostPtrSurface &s
auto memoryManager = device->getCommandStreamReceiver().getMemoryManager();
GraphicsAllocation *allocation = nullptr;
if (!isFullRangeSvm()) {
allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(surface.getSurfaceSize(), surface.getMemoryPointer());
} else {
allocation = memoryManager->allocateGraphicsMemory(surface.getSurfaceSize(), surface.getMemoryPointer());
}
allocation = memoryManager->allocateGraphicsMemoryForHostPtr(surface.getSurfaceSize(), surface.getMemoryPointer(), device->isFullRangeSvm());
if (allocation == nullptr && surface.peekIsPtrCopyAllowed()) {
// Try with no host pointer allocation and copy
allocation = memoryManager->allocateGraphicsMemory(surface.getSurfaceSize(), MemoryConstants::pageSize, false, false);

View File

@@ -27,6 +27,7 @@
#include "runtime/helpers/base_object.h"
#include "runtime/helpers/hw_info.h"
#include "runtime/helpers/engine_node.h"
#include "runtime/memory_manager/memory_constants.h"
#include "runtime/os_interface/performance_counters.h"
#include <vector>
@@ -134,6 +135,9 @@ class Device : public BaseObject<_cl_device_id> {
const HardwareCapabilities &getHardwareCapabilities() { return hardwareCapabilities; }
OsContext *getOsContext() const { return osContext; }
uint32_t getDeviceIndex();
bool isFullRangeSvm() {
return getHardwareInfo().capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress;
}
protected:
Device() = delete;

View File

@@ -130,6 +130,14 @@ class MemoryManager {
}
virtual GraphicsAllocation *allocateGraphicsMemory(size_t size, const void *ptr, bool forcePin);
GraphicsAllocation *allocateGraphicsMemoryForHostPtr(size_t size, void *ptr, bool fullRangeSvm) {
if (fullRangeSvm) {
return allocateGraphicsMemory(size, ptr);
} else {
return allocateGraphicsMemoryForNonSvmHostPtr(size, ptr);
}
}
virtual GraphicsAllocation *allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) = 0;
virtual GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) = 0;

View File

@@ -130,8 +130,8 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(size_t size, size_
}
GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(size_t size, void *cpuPtr) {
auto alignedPtr = alignDown(reinterpret_cast<char *>(cpuPtr), MemoryConstants::pageSize);
auto offsetInPage = reinterpret_cast<char *>(cpuPtr) - alignedPtr;
auto alignedPtr = alignDown(cpuPtr, MemoryConstants::pageSize);
auto offsetInPage = ptrDiff(cpuPtr, alignedPtr);
auto alignedSize = alignSizeWholePage(cpuPtr, size);
auto wddmAllocation = new WddmAllocation(cpuPtr, size, alignedPtr, alignedSize, nullptr, MemoryPool::System4KBPages);