Fix calculations for offseted addresses

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2020-12-08 14:03:23 +00:00
committed by Compute-Runtime-Automation
parent 798256ed61
commit b32b5784c2
14 changed files with 346 additions and 169 deletions

View File

@@ -75,7 +75,10 @@ struct DriverHandle : _ze_driver_handle_t {
virtual ze_result_t getHostPointerBaseAddress(void *ptr, void **baseAddress) = 0;
virtual NEO::GraphicsAllocation *findHostPointerAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) = 0;
virtual NEO::GraphicsAllocation *getDriverSystemMemoryAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) = 0;
virtual NEO::GraphicsAllocation *getDriverSystemMemoryAllocation(void *ptr,
size_t size,
uint32_t rootDeviceIndex,
uintptr_t *gpuAddress) = 0;
static DriverHandle *fromHandle(ze_driver_handle_t handle) { return static_cast<DriverHandle *>(handle); }
inline ze_driver_handle_t toHandle() { return this; }

View File

@@ -453,13 +453,27 @@ NEO::GraphicsAllocation *DriverHandleImp::findHostPointerAllocation(void *ptr, s
return nullptr;
}
NEO::GraphicsAllocation *DriverHandleImp::getDriverSystemMemoryAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) {
NEO::GraphicsAllocation *DriverHandleImp::getDriverSystemMemoryAllocation(void *ptr,
size_t size,
uint32_t rootDeviceIndex,
uintptr_t *gpuAddress) {
NEO::SvmAllocationData *allocData = nullptr;
bool allocFound = findAllocationDataForRange(ptr, size, &allocData);
if (allocFound) {
if (gpuAddress != nullptr) {
*gpuAddress = reinterpret_cast<uintptr_t>(ptr);
}
return allocData->gpuAllocations.getGraphicsAllocation(rootDeviceIndex);
}
return findHostPointerAllocation(ptr, size, rootDeviceIndex);
auto allocation = findHostPointerAllocation(ptr, size, rootDeviceIndex);
if (allocation != nullptr) {
if (gpuAddress != nullptr) {
uintptr_t offset = reinterpret_cast<uintptr_t>(ptr) -
reinterpret_cast<uintptr_t>(allocation->getUnderlyingBuffer());
*gpuAddress = static_cast<uintptr_t>(allocation->getGpuAddress()) + offset;
}
}
return allocation;
}
} // namespace L0

View File

@@ -76,7 +76,10 @@ struct DriverHandleImp : public DriverHandle {
ze_result_t getHostPointerBaseAddress(void *ptr, void **baseAddress) override;
virtual NEO::GraphicsAllocation *findHostPointerAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) override;
virtual NEO::GraphicsAllocation *getDriverSystemMemoryAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) override;
virtual NEO::GraphicsAllocation *getDriverSystemMemoryAllocation(void *ptr,
size_t size,
uint32_t rootDeviceIndex,
uintptr_t *gpuAddress) override;
uint32_t parseAffinityMask(std::vector<std::unique_ptr<NEO::Device>> &neoDevices);
void createHostPointerManager();