@@ -673,6 +673,15 @@ void Event::resetInOrderTimestampNode(NEO::TagNodeBase *newNode) {
673
673
inOrderTimestampNode = newNode;
674
674
}
675
675
676
+ NEO::GraphicsAllocation *Event::getExternalCounterAllocationFromAddress (uint64_t *address) const {
677
+ NEO::SvmAllocationData *allocData = nullptr ;
678
+ if (!address || !device->getDriverHandle ()->findAllocationDataForRange (address, sizeof (uint64_t ), allocData)) {
679
+ return nullptr ;
680
+ }
681
+
682
+ return allocData->gpuAllocations .getGraphicsAllocation (device->getRootDeviceIndex ());
683
+ }
684
+
676
685
ze_result_t Event::enableExtensions (const EventDescriptor &eventDescriptor) {
677
686
bool interruptMode = false ;
678
687
bool kmdWaitMode = false ;
@@ -699,31 +708,31 @@ ze_result_t Event::enableExtensions(const EventDescriptor &eventDescriptor) {
699
708
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
700
709
}
701
710
702
- NEO::SvmAllocationData *externalHostAllocData = nullptr ;
703
- if (!device->getDriverHandle ()->findAllocationDataForRange (externalSyncAllocProperties->hostAddress , sizeof (uint64_t ), externalHostAllocData)) {
711
+ auto deviceAlloc = getExternalCounterAllocationFromAddress (externalSyncAllocProperties->deviceAddress );
712
+ auto hostAlloc = getExternalCounterAllocationFromAddress (externalSyncAllocProperties->hostAddress );
713
+
714
+ if (!hostAlloc) {
704
715
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
705
716
}
706
717
707
- auto allocation = externalHostAllocData->gpuAllocations .getGraphicsAllocation (device->getRootDeviceIndex ());
708
- auto inOrderExecInfo = NEO::InOrderExecInfo::createFromExternalAllocation (*device->getNEODevice (), nullptr , castToUint64 (externalSyncAllocProperties->deviceAddress ),
709
- allocation, externalSyncAllocProperties->hostAddress , externalSyncAllocProperties->completionValue , 1 , 1 );
718
+ auto inOrderExecInfo = NEO::InOrderExecInfo::createFromExternalAllocation (*device->getNEODevice (), deviceAlloc, castToUint64 (externalSyncAllocProperties->deviceAddress ),
719
+ hostAlloc, externalSyncAllocProperties->hostAddress , externalSyncAllocProperties->completionValue , 1 , 1 );
710
720
updateInOrderExecState (inOrderExecInfo, externalSyncAllocProperties->completionValue , 0 );
711
721
} else if (extendedDesc->stype == ZEX_STRUCTURE_COUNTER_BASED_EVENT_EXTERNAL_STORAGE_ALLOC_PROPERTIES) {
712
722
auto externalStorageProperties = reinterpret_cast <const zex_counter_based_event_external_storage_properties_t *>(extendedDesc);
713
723
714
- NEO::SvmAllocationData *externalDeviceAllocData = nullptr ;
715
- if (!externalStorageProperties-> deviceAddress || !device-> getDriverHandle ()-> findAllocationDataForRange (externalStorageProperties-> deviceAddress , sizeof ( uint64_t ), externalDeviceAllocData) ||
716
- externalStorageProperties->incrementValue == 0 ) {
724
+ auto deviceAlloc = getExternalCounterAllocationFromAddress (externalStorageProperties-> deviceAddress ) ;
725
+
726
+ if (!deviceAlloc || externalStorageProperties->incrementValue == 0 ) {
717
727
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
718
728
}
719
729
720
- auto allocation = externalDeviceAllocData->gpuAllocations .getGraphicsAllocation (device->getRootDeviceIndex ());
721
- auto offset = ptrDiff (externalStorageProperties->deviceAddress , allocation->getGpuAddress ());
730
+ auto offset = ptrDiff (externalStorageProperties->deviceAddress , deviceAlloc->getGpuAddress ());
722
731
723
- auto hostAddress = ptrOffset (device->getNEODevice ()->getMemoryManager ()->lockResource (allocation ), offset);
732
+ auto hostAddress = ptrOffset (device->getNEODevice ()->getMemoryManager ()->lockResource (deviceAlloc ), offset);
724
733
725
- auto inOrderExecInfo = NEO::InOrderExecInfo::createFromExternalAllocation (*device->getNEODevice (), allocation , castToUint64 (externalStorageProperties->deviceAddress ),
726
- allocation , reinterpret_cast <uint64_t *>(hostAddress), externalStorageProperties->completionValue , 1 , 1 );
734
+ auto inOrderExecInfo = NEO::InOrderExecInfo::createFromExternalAllocation (*device->getNEODevice (), deviceAlloc , castToUint64 (externalStorageProperties->deviceAddress ),
735
+ deviceAlloc , reinterpret_cast <uint64_t *>(hostAddress), externalStorageProperties->completionValue , 1 , 1 );
727
736
728
737
updateInOrderExecState (inOrderExecInfo, externalStorageProperties->completionValue , 0 );
729
738
0 commit comments