Skip to content

Commit 8b7081e

Browse files
committed
Address feedback - missing breaks in switches, more appropriate error codes or replacing original
error message to use an assert from cassert header and some other minor fixes.
1 parent 3d15f53 commit 8b7081e

21 files changed

+62
-90
lines changed

source/adapters/cuda/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <ur/ur.hpp>
1414

1515
/**
16-
* Call an UR API and, if the result is not UR_RESULT_SUCCESS, automatically
16+
* Call a UR API and, if the result is not UR_RESULT_SUCCESS, automatically
1717
* return from the current function.
1818
*/
1919
#define UR_RETURN_ON_FAILURE(urCall) \

source/adapters/cuda/device.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
557557
UR_CHECK_ERROR(cuDeviceGetAttribute(
558558
&ECCEnabled, CU_DEVICE_ATTRIBUTE_ECC_ENABLED, hDevice->get()));
559559

560-
if ((ECCEnabled != 0) | (ECCEnabled != 1)) {
560+
if ((ECCEnabled != 0) || (ECCEnabled != 1)) {
561561
return UR_RESULT_ERROR_INVALID_OPERATION;
562562
}
563563
auto Result = static_cast<bool>(ECCEnabled);
@@ -568,7 +568,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
568568
UR_CHECK_ERROR(cuDeviceGetAttribute(
569569
&IsIntegrated, CU_DEVICE_ATTRIBUTE_INTEGRATED, hDevice->get()));
570570

571-
if ((IsIntegrated != 0) | (IsIntegrated != 1)) {
571+
if ((IsIntegrated != 0) || (IsIntegrated != 1)) {
572572
return UR_RESULT_ERROR_INVALID_OPERATION;
573573
}
574574
auto result = static_cast<bool>(IsIntegrated);
@@ -851,9 +851,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
851851
case UR_DEVICE_INFO_GLOBAL_MEM_FREE: {
852852
size_t FreeMemory = 0;
853853
size_t TotalMemory = 0;
854-
if (cuMemGetInfo(&FreeMemory, &TotalMemory) != CUDA_SUCCESS) {
855-
return UR_RESULT_ERROR_INVALID_OPERATION;
856-
}
854+
assert(cuMemGetInfo(&FreeMemory, &TotalMemory) != CUDA_SUCCESS &&
855+
"failed cuMemGetInfo() API.");
857856
return ReturnValue(FreeMemory);
858857
}
859858
case UR_DEVICE_INFO_MEMORY_CLOCK_RATE: {

source/adapters/cuda/enqueue.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -844,24 +844,26 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferFill(
844844
}
845845

846846
static ur_result_t imageElementByteSize(CUDA_ARRAY_DESCRIPTOR ArrayDesc,
847-
int *Size) {
847+
unsigned int *Size) {
848848
switch (ArrayDesc.Format) {
849849
case CU_AD_FORMAT_UNSIGNED_INT8:
850850
case CU_AD_FORMAT_SIGNED_INT8:
851851
*Size = 1;
852+
break;
852853
case CU_AD_FORMAT_UNSIGNED_INT16:
853854
case CU_AD_FORMAT_SIGNED_INT16:
854855
case CU_AD_FORMAT_HALF:
855856
*Size = 2;
857+
break;
856858
case CU_AD_FORMAT_UNSIGNED_INT32:
857859
case CU_AD_FORMAT_SIGNED_INT32:
858860
case CU_AD_FORMAT_FLOAT:
859861
*Size = 4;
862+
break;
860863
default:
861-
return UR_RESULT_ERROR_INVALID_IMAGE_SIZE;
864+
return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR;
862865
*Size = 0;
863866
}
864-
return UR_RESULT_SUCCESS;
865867
}
866868

867869
/// General ND memory copy operation for images (where N > 1).
@@ -957,7 +959,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageRead(
957959
CUDA_ARRAY_DESCRIPTOR ArrayDesc;
958960
UR_CHECK_ERROR(cuArrayGetDescriptor(&ArrayDesc, Array));
959961

960-
int ElementByteSize = 0;
962+
unsigned int ElementByteSize = 0;
961963
UR_RETURN_ON_FAILURE(imageElementByteSize(ArrayDesc, &ElementByteSize));
962964

963965
size_t ByteOffsetX = origin.x * ElementByteSize * ArrayDesc.NumChannels;
@@ -1030,7 +1032,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageWrite(
10301032
CUDA_ARRAY_DESCRIPTOR ArrayDesc;
10311033
UR_CHECK_ERROR(cuArrayGetDescriptor(&ArrayDesc, Array));
10321034

1033-
int ElementByteSize = 0;
1035+
unsigned int ElementByteSize = 0;
10341036
UR_RETURN_ON_FAILURE(imageElementByteSize(ArrayDesc, &ElementByteSize));
10351037

10361038
size_t ByteOffsetX = origin.x * ElementByteSize * ArrayDesc.NumChannels;
@@ -1110,7 +1112,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageCopy(
11101112
UR_ASSERT(SrcArrayDesc.NumChannels == DstArrayDesc.NumChannels,
11111113
UR_RESULT_ERROR_INVALID_MEM_OBJECT);
11121114

1113-
int ElementByteSize = 0;
1115+
unsigned int ElementByteSize = 0;
11141116
UR_RETURN_ON_FAILURE(imageElementByteSize(SrcArrayDesc, &ElementByteSize));
11151117

11161118
size_t DstByteOffsetX =

source/adapters/cuda/event.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ ur_result_t ur_event_handle_t_::record() {
120120

121121
try {
122122
EventID = Queue->getNextEventID();
123-
if (EventID == 0) {
124-
return UR_RESULT_ERROR_INVALID_EVENT;
125-
}
123+
assert(EventID == 0 && "Unrecoverable program state reached in event identifier overflow.");
126124
UR_CHECK_ERROR(cuEventRecord(EvEnd, Stream));
127125
} catch (ur_result_t error) {
128126
Result = error;
@@ -245,19 +243,16 @@ urEventWait(uint32_t numEvents, const ur_event_handle_t *phEventWaitList) {
245243
UR_APIEXPORT ur_result_t UR_APICALL urEventRetain(ur_event_handle_t hEvent) {
246244
const auto RefCount = hEvent->incrementReferenceCount();
247245

248-
if (RefCount == 0) {
249-
return UR_RESULT_ERROR_INVALID_OPERATION;
250-
}
246+
assert(RefCount == 0 &&
247+
"Reference count overflow detected in urEventRetain.");
251248

252249
return UR_RESULT_SUCCESS;
253250
}
254251

255252
UR_APIEXPORT ur_result_t UR_APICALL urEventRelease(ur_event_handle_t hEvent) {
256253
// double delete or someone is messing with the ref count.
257254
// either way, cannot safely proceed.
258-
if (hEvent->getReferenceCount() == 0) {
259-
return UR_RESULT_ERROR_INVALID_OPERATION;
260-
}
255+
assert(hEvent->getReferenceCount() == 0 && "Unrecoverable program state reached in urEventRetain.");
261256

262257
// decrement ref count. If it is 0, delete the event.
263258
if (hEvent->decrementReferenceCount() == 0) {

source/adapters/cuda/memory.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemRelease(ur_mem_handle_t hMem) {
144144
Result = UR_RESULT_ERROR_OUT_OF_RESOURCES;
145145
}
146146

147-
if (Result != UR_RESULT_SUCCESS) {
148-
// A reported CUDA error is either an implementation or an asynchronous CUDA
149-
// error for which it is unclear if the function that reported it succeeded
150-
// or not. Either way, the state of the program is compromised and likely
151-
// unrecoverable.
152-
return UR_RESULT_ERROR_INVALID_OPERATION;
153-
}
147+
// A reported CUDA error is either an implementation or an asynchronous CUDA
148+
// error for which it is unclear if the function that reported it succeeded
149+
// or not. Either way, the state of the program is compromised and likely
150+
// unrecoverable.
151+
assert(Result != UR_RESULT_SUCCESS && "Unrecoverable program state reached in urMemRelease.");
154152

155153
return UR_RESULT_SUCCESS;
156154
}
@@ -306,7 +304,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate(
306304
PixelTypeSizeBytes = 4;
307305
break;
308306
default:
309-
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
307+
return UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR;
310308
}
311309

312310
// When a dimension isn't used pImageDesc has the size set to 1

source/adapters/cuda/queue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
265265
} else if (CuFlags == CU_STREAM_NON_BLOCKING) {
266266
Flags = UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM;
267267
} else {
268-
return UR_RESULT_ERROR_INVALID_OPERATION;
268+
assert(!"Unknown cuda stream.");
269269
}
270270

271271
std::vector<CUstream> ComputeCuStreams(1, CuStream);

source/adapters/cuda/sampler.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ UR_APIEXPORT ur_result_t UR_APICALL
8484
urSamplerRelease(ur_sampler_handle_t hSampler) {
8585
// double delete or someone is messing with the ref count.
8686
// either way, cannot safely proceed.
87-
if (hSampler->getReferenceCount() == 0) {
88-
return UR_RESULT_ERROR_INVALID_OPERATION;
89-
}
87+
assert (hSampler->getReferenceCount() == 0 && "Reference count overflow detected in urSamplerRelease.");
9088

9189
// decrement ref count. If it is 0, delete the sampler.
9290
if (hSampler->decrementReferenceCount() == 0) {

source/adapters/hip/common.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,22 @@ ur_result_t urGetLastResult(ur_platform_handle_t, const char **ppMessage) {
179179
return ErrorMessageCode;
180180
}
181181

182-
ur_result_t GetHipFormatPixelSize(hipArray_Format Format, int *Size) {
182+
ur_result_t imageElementByteSize(hipArray_Format Format, unsigned int *Size) {
183183
switch (Format) {
184184
case HIP_AD_FORMAT_UNSIGNED_INT8:
185185
case HIP_AD_FORMAT_SIGNED_INT8:
186186
*Size = 1;
187+
break;
187188
case HIP_AD_FORMAT_UNSIGNED_INT16:
188189
case HIP_AD_FORMAT_SIGNED_INT16:
189190
case HIP_AD_FORMAT_HALF:
190191
*Size = 2;
192+
break;
191193
case HIP_AD_FORMAT_UNSIGNED_INT32:
192194
case HIP_AD_FORMAT_SIGNED_INT32:
193195
case HIP_AD_FORMAT_FLOAT:
194196
*Size = 4;
197+
break;
195198
default:
196199
return UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED;
197200
}

source/adapters/hip/common.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <ur/ur.hpp>
1717

1818
/**
19-
* Call an UR API and, if the result is not UR_RESULT_SUCCESS, automatically
19+
* Call a UR API and, if the result is not UR_RESULT_SUCCESS, automatically
2020
* return from the current function.
2121
*/
2222
#define UR_RETURN_ON_FAILURE(urCall) \
@@ -170,8 +170,8 @@ template <typename T> class ReleaseGuard {
170170
// HIP error for which it is unclear if the function that reported it
171171
// succeeded or not. Either way, the state of the program is compromised
172172
// and likely unrecoverable.
173-
detail::ur::hipPrint(
174-
"Unrecoverable program state reached in piMemRelease");
173+
assert(
174+
!"Unrecoverable program state reached in piMemRelease");
175175
}
176176
}
177177
}
@@ -189,4 +189,4 @@ template <typename T> class ReleaseGuard {
189189
void dismiss() { Captive = nullptr; }
190190
};
191191

192-
ur_result_t GetHipFormatPixelSize(hipArray_Format Format, int *Size);
192+
ur_result_t imageElementByteSize(hipArray_Format Format, int *Size);

source/adapters/hip/device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
475475
UR_CHECK_ERROR(hipDeviceGetAttribute(
476476
&EccEnabled, hipDeviceAttributeEccEnabled, hDevice->get()));
477477

478-
if ((EccEnabled != 0) | (EccEnabled != 1)) {
478+
if ((EccEnabled != 0) || (EccEnabled != 1)) {
479479
return UR_RESULT_ERROR_INVALID_OPERATION;
480480
}
481481
auto Result = static_cast<bool>(EccEnabled);

source/adapters/hip/enqueue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageRead(
884884
getArrayDesc(Array, Format, NumChannels);
885885

886886
int ElementByteSize = 0;
887-
UR_RETURN_ON_FAILURE(GetHipFormatPixelSize(Format, &ElementByteSize));
887+
UR_RETURN_ON_FAILURE(imageElementByteSize(Format, &ElementByteSize));
888888

889889
size_t ByteOffsetX = origin.x * ElementByteSize * NumChannels;
890890
size_t BytesToCopy = ElementByteSize * NumChannels * region.depth;
@@ -953,7 +953,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageWrite(
953953
getArrayDesc(Array, Format, NumChannels);
954954

955955
int ElementByteSize = 0;
956-
UR_RETURN_ON_FAILURE(GetHipFormatPixelSize(Format, &ElementByteSize));
956+
UR_RETURN_ON_FAILURE(imageElementByteSize(Format, &ElementByteSize));
957957

958958
size_t ByteOffsetX = origin.x * ElementByteSize * NumChannels;
959959
size_t BytesToCopy = ElementByteSize * NumChannels * region.depth;
@@ -1034,7 +1034,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageCopy(
10341034
UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR);
10351035

10361036
int ElementByteSize = 0;
1037-
UR_RETURN_ON_FAILURE(GetHipFormatPixelSize(SrcFormat, &ElementByteSize));
1037+
UR_RETURN_ON_FAILURE(imageElementByteSize(SrcFormat, &ElementByteSize));
10381038

10391039
size_t DstByteOffsetX = dstOrigin.x * ElementByteSize * SrcNumChannels;
10401040
size_t SrcByteOffsetX = srcOrigin.x * ElementByteSize * DstNumChannels;

source/adapters/hip/event.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ ur_result_t ur_event_handle_t_::record() {
142142

143143
try {
144144
EventId = Queue->getNextEventId();
145-
if (EventId == 0) {
146-
return UR_RESULT_ERROR_INVALID_OPERATION;
147-
}
145+
assert (EventId == 0 && "Unrecoverable program state reached in event identifier overflow.");
148146
UR_CHECK_ERROR(hipEventRecord(EvEnd, Stream));
149147
Result = UR_RESULT_SUCCESS;
150148
} catch (ur_result_t Error) {
@@ -274,19 +272,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventSetCallback(ur_event_handle_t,
274272
UR_APIEXPORT ur_result_t UR_APICALL urEventRetain(ur_event_handle_t hEvent) {
275273
const auto RefCount = hEvent->incrementReferenceCount();
276274

277-
if (RefCount == 0) {
278-
return UR_RESULT_ERROR_INVALID_OPERATION;
279-
}
275+
assert(RefCount == 0 && "Reference count overflow detected in urEventRetain.");
280276

281277
return UR_RESULT_SUCCESS;
282278
}
283279

284280
UR_APIEXPORT ur_result_t UR_APICALL urEventRelease(ur_event_handle_t hEvent) {
285281
// double delete or someone is messing with the ref count.
286282
// either way, cannot safely proceed.
287-
if (hEvent->getReferenceCount() == 0) {
288-
return UR_RESULT_ERROR_INVALID_OPERATION;
289-
}
283+
assert(hEvent->getReferenceCount() == 0 && "Reference count overflow detected in urEventRelease.");
290284

291285
// decrement ref count. If it is 0, delete the event.
292286
if (hEvent->decrementReferenceCount() == 0) {

source/adapters/hip/memory.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemRelease(ur_mem_handle_t hMem) {
9292
// error for which it is unclear if the function that reported it succeeded
9393
// or not. Either way, the state of the program is compromised and likely
9494
// unrecoverable.
95-
return UR_RESULT_ERROR_INVALID_OPERATION;
95+
assert(!"Unrecoverable program state reached in urMemRelease");
9696
}
9797

9898
return UR_RESULT_SUCCESS;
@@ -281,9 +281,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemGetInfo(ur_mem_handle_t hMemory,
281281
#else
282282
HIP_ARRAY3D_DESCRIPTOR ArrayDescriptor;
283283
UR_CHECK_ERROR(hipArray3DGetDescriptor(&ArrayDescriptor, Mem.Array));
284-
auto PixelSize = 0;
284+
int PixelSize = 0;
285285
UR_RETURN_ON_FAILURE(
286-
GetHipFormatPixelSize(ArrayDescriptor.Format, &PixelSize));
286+
imageElementByteSize(ArrayDescriptor.Format, &PixelSize));
287287
const auto PixelSizeBytes = PixelSize * ArrayDescriptor.NumChannels;
288288
const auto ImageSizeBytes =
289289
PixelSizeBytes *
@@ -565,7 +565,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo(ur_mem_handle_t hMemory,
565565
return ReturnValue(ArrayInfo.Depth);
566566
case UR_IMAGE_INFO_ELEMENT_SIZE: {
567567
int Size = 0;
568-
UR_RETURN_ON_FAILURE(GetHipFormatPixelSize(ArrayInfo.Format, &Size));
568+
UR_RETURN_ON_FAILURE(imageElementByteSize(ArrayInfo.Format, &Size));
569569
return ReturnValue(Size);
570570
}
571571
case UR_IMAGE_INFO_ROW_PITCH:

source/adapters/hip/queue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
280280
} else if (HIPFlags == hipStreamNonBlocking) {
281281
Flags = UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM;
282282
} else {
283-
return UR_RESULT_ERROR_INVALID_OPERATION;
283+
assert(!"Unknown hip stream.");
284284
}
285285

286286
std::vector<hipStream_t> ComputeHIPStreams(1, HIPStream);

source/adapters/hip/sampler.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ ur_result_t urSamplerRetain(ur_sampler_handle_t hSampler) {
6969
ur_result_t urSamplerRelease(ur_sampler_handle_t hSampler) {
7070
// double delete or someone is messing with the ref count.
7171
// either way, cannot safely proceed.
72-
if (hSampler->getReferenceCount() == 0) {
73-
return UR_RESULT_ERROR_INVALID_OPERATION;
74-
}
72+
assert(hSampler->getReferenceCount() == 0 && "Reference count overflow detected in urSamplerRelease.");
7573

7674
// decrement ref count. If it is 0, delete the sampler.
7775
if (hSampler->decrementReferenceCount() == 0) {

source/adapters/level_zero/context.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,7 @@ ur_context_handle_t_::decrementUnreleasedEventsInPool(ur_event_handle_t Event) {
566566
getZeEventPoolCache(Event->isHostVisible(), Event->isProfilingEnabled());
567567

568568
// Put the empty pool to the cache of the pools.
569-
if (NumEventsUnreleasedInEventPool[Event->ZeEventPool] == 0) {
570-
return UR_RESULT_ERROR_INVALID_OPERATION;
571-
}
569+
assert(NumEventsUnreleasedInEventPool[Event->ZeEventPool] == 0 && "Invalid event release: event pool doesn't have unreleased events");
572570
if (--NumEventsUnreleasedInEventPool[Event->ZeEventPool] == 0) {
573571
if (ZePoolCache->front() != Event->ZeEventPool) {
574572
ZePoolCache->push_back(Event->ZeEventPool);

source/adapters/level_zero/event.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,7 @@ ur_result_t ur_event_handle_t_::getOrCreateHostVisibleEvent(
512512
this->Mutex);
513513

514514
if (!HostVisibleEvent) {
515-
if (UrQueue->ZeEventsScope != OnDemandHostVisibleProxy) {
516-
return UR_RESULT_ERROR_INVALID_EVENT;
517-
}
515+
assert(UrQueue->ZeEventsScope != OnDemandHostVisibleProxy && "getOrCreateHostVisibleEvent: missing host-visible event");
518516

519517
// Submit the command(s) signalling the proxy event to the queue.
520518
// We have to first submit a wait for the device-only event for which this
@@ -560,9 +558,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventWait(
560558
//
561559
ur_event_handle_t_ *Event =
562560
ur_cast<ur_event_handle_t_ *>(EventWaitList[I]);
563-
if (!Event->hasExternalRefs()) {
564-
return UR_RESULT_ERROR_INVALID_OPERATION;
565-
}
561+
assert(!Event->hasExternalRefs() && "urEventsWait must not be called for an internal event");
566562

567563
ze_event_handle_t ZeHostVisibleEvent;
568564
if (auto Res = Event->getOrCreateHostVisibleEvent(ZeHostVisibleEvent))
@@ -587,15 +583,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventWait(
587583
ur_cast<ur_event_handle_t_ *>(EventWaitList[I]);
588584
{
589585
std::shared_lock<ur_shared_mutex> EventLock(Event->Mutex);
590-
if (!Event->hasExternalRefs()) {
591-
return UR_RESULT_ERROR_INVALID_OPERATION;
592-
}
586+
assert(!Event->hasExternalRefs() && "urEventWait must not be called for an internal event");
593587

594588
if (!Event->Completed) {
595589
auto HostVisibleEvent = Event->HostVisibleEvent;
596-
if (!HostVisibleEvent) {
597-
return UR_RESULT_ERROR_INVALID_EVENT;
598-
}
590+
assert(!HostVisibleEvent && "The host-visible proxy event missing");
599591

600592
ze_event_handle_t ZeEvent = HostVisibleEvent->ZeEvent;
601593
urPrint("ZeEvent = %#llx\n", ur_cast<std::uintptr_t>(ZeEvent));

0 commit comments

Comments
 (0)