mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 10:26:29 +08:00
Fix calculations for offseted addresses
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
798256ed61
commit
b32b5784c2
@@ -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; }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user