Skip to content

Commit fe909e8

Browse files
authored
[UR][CUDA][HIP] Cleanup use of assertions and die (#18118)
This patch cleans up most of the uses of `die()` in the CUDA and HIP adapters, it was replaced by: * Using regular `assert()` * Using `UR_CHECK_ERROR` * Returning an appropriate error code * Throw an appropriate error code * Return an adapter specific error code with a message
1 parent d653b20 commit fe909e8

22 files changed

+132
-137
lines changed

unified-runtime/source/adapters/cuda/common.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ std::string getCudaVersionString() {
134134
return stream.str();
135135
}
136136

137-
void detail::ur::assertion(bool Condition, const char *Message) {
138-
if (!Condition)
139-
die(Message);
140-
}
141-
142137
// Global variables for ZER_EXT_RESULT_ADAPTER_SPECIFIC_ERROR
143138
thread_local ur_result_t ErrorMessageCode = UR_RESULT_SUCCESS;
144139
thread_local char ErrorMessage[MaxMessageSize]{};

unified-runtime/source/adapters/cuda/common.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ namespace ur {
6464
// Reports error messages
6565
void cuPrint(const char *Message);
6666

67-
void assertion(bool Condition, const char *Message = nullptr);
68-
6967
} // namespace ur
7068
} // namespace detail
7169

unified-runtime/source/adapters/cuda/device.cpp

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
7272
int MaxX = 0, MaxY = 0, MaxZ = 0;
7373
UR_CHECK_ERROR(cuDeviceGetAttribute(
7474
&MaxX, CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X, hDevice->get()));
75-
detail::ur::assertion(MaxX >= 0);
75+
assert(MaxX >= 0);
7676

7777
UR_CHECK_ERROR(cuDeviceGetAttribute(
7878
&MaxY, CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y, hDevice->get()));
79-
detail::ur::assertion(MaxY >= 0);
79+
assert(MaxY >= 0);
8080

8181
UR_CHECK_ERROR(cuDeviceGetAttribute(
8282
&MaxZ, CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z, hDevice->get()));
83-
detail::ur::assertion(MaxZ >= 0);
83+
assert(MaxZ >= 0);
8484

8585
ReturnSizes.Sizes[0] = size_t(MaxX);
8686
ReturnSizes.Sizes[1] = size_t(MaxY);
@@ -95,15 +95,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
9595
int MaxX = 0, MaxY = 0, MaxZ = 0;
9696
UR_CHECK_ERROR(cuDeviceGetAttribute(
9797
&MaxX, CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X, hDevice->get()));
98-
detail::ur::assertion(MaxX >= 0);
98+
assert(MaxX >= 0);
9999

100100
UR_CHECK_ERROR(cuDeviceGetAttribute(
101101
&MaxY, CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y, hDevice->get()));
102-
detail::ur::assertion(MaxY >= 0);
102+
assert(MaxY >= 0);
103103

104104
UR_CHECK_ERROR(cuDeviceGetAttribute(
105105
&MaxZ, CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z, hDevice->get()));
106-
detail::ur::assertion(MaxZ >= 0);
106+
assert(MaxZ >= 0);
107107

108108
ReturnSizes.Sizes[0] = size_t(MaxX);
109109
ReturnSizes.Sizes[1] = size_t(MaxY);
@@ -116,8 +116,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
116116
UR_CHECK_ERROR(cuDeviceGetAttribute(
117117
&MaxWorkGroupSize, CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK,
118118
hDevice->get()));
119-
120-
detail::ur::assertion(MaxWorkGroupSize >= 0);
119+
assert(MaxWorkGroupSize >= 0);
121120

122121
return ReturnValue(size_t(MaxWorkGroupSize));
123122
}
@@ -268,7 +267,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
268267
int ClockFreq = 0;
269268
UR_CHECK_ERROR(cuDeviceGetAttribute(
270269
&ClockFreq, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, hDevice->get()));
271-
detail::ur::assertion(ClockFreq >= 0);
270+
assert(ClockFreq >= 0);
272271
return ReturnValue(static_cast<uint32_t>(ClockFreq) / 1000u);
273272
}
274273
case UR_DEVICE_INFO_ADDRESS_BITS: {
@@ -314,12 +313,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
314313
UR_CHECK_ERROR(cuDeviceGetAttribute(
315314
&TexHeight, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT,
316315
hDevice->get()));
317-
detail::ur::assertion(TexHeight >= 0);
316+
assert(TexHeight >= 0);
318317
int SurfHeight = 0;
319318
UR_CHECK_ERROR(cuDeviceGetAttribute(
320319
&SurfHeight, CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_HEIGHT,
321320
hDevice->get()));
322-
detail::ur::assertion(SurfHeight >= 0);
321+
assert(SurfHeight >= 0);
323322

324323
int Min = std::min(TexHeight, SurfHeight);
325324

@@ -331,12 +330,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
331330
UR_CHECK_ERROR(cuDeviceGetAttribute(
332331
&TexWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH,
333332
hDevice->get()));
334-
detail::ur::assertion(TexWidth >= 0);
333+
assert(TexWidth >= 0);
335334
int SurfWidth = 0;
336335
UR_CHECK_ERROR(cuDeviceGetAttribute(
337336
&SurfWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_WIDTH,
338337
hDevice->get()));
339-
detail::ur::assertion(SurfWidth >= 0);
338+
assert(SurfWidth >= 0);
340339

341340
int Min = std::min(TexWidth, SurfWidth);
342341

@@ -348,12 +347,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
348347
UR_CHECK_ERROR(cuDeviceGetAttribute(
349348
&TexHeight, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT,
350349
hDevice->get()));
351-
detail::ur::assertion(TexHeight >= 0);
350+
assert(TexHeight >= 0);
352351
int SurfHeight = 0;
353352
UR_CHECK_ERROR(cuDeviceGetAttribute(
354353
&SurfHeight, CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT,
355354
hDevice->get()));
356-
detail::ur::assertion(SurfHeight >= 0);
355+
assert(SurfHeight >= 0);
357356

358357
int Min = std::min(TexHeight, SurfHeight);
359358

@@ -365,12 +364,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
365364
UR_CHECK_ERROR(cuDeviceGetAttribute(
366365
&TexWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH,
367366
hDevice->get()));
368-
detail::ur::assertion(TexWidth >= 0);
367+
assert(TexWidth >= 0);
369368
int SurfWidth = 0;
370369
UR_CHECK_ERROR(cuDeviceGetAttribute(
371370
&SurfWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_WIDTH,
372371
hDevice->get()));
373-
detail::ur::assertion(SurfWidth >= 0);
372+
assert(SurfWidth >= 0);
374373

375374
int Min = std::min(TexWidth, SurfWidth);
376375

@@ -382,12 +381,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
382381
UR_CHECK_ERROR(cuDeviceGetAttribute(
383382
&TexDepth, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH,
384383
hDevice->get()));
385-
detail::ur::assertion(TexDepth >= 0);
384+
assert(TexDepth >= 0);
386385
int SurfDepth = 0;
387386
UR_CHECK_ERROR(cuDeviceGetAttribute(
388387
&SurfDepth, CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH,
389388
hDevice->get()));
390-
detail::ur::assertion(SurfDepth >= 0);
389+
assert(SurfDepth >= 0);
391390

392391
int Min = std::min(TexDepth, SurfDepth);
393392

@@ -399,12 +398,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
399398
UR_CHECK_ERROR(cuDeviceGetAttribute(
400399
&TexWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH,
401400
hDevice->get()));
402-
detail::ur::assertion(TexWidth >= 0);
401+
assert(TexWidth >= 0);
403402
int SurfWidth = 0;
404403
UR_CHECK_ERROR(cuDeviceGetAttribute(
405404
&SurfWidth, CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_WIDTH,
406405
hDevice->get()));
407-
detail::ur::assertion(SurfWidth >= 0);
406+
assert(SurfWidth >= 0);
408407

409408
int Min = std::min(TexWidth, SurfWidth);
410409

@@ -473,23 +472,22 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
473472
int CacheSize = 0;
474473
UR_CHECK_ERROR(cuDeviceGetAttribute(
475474
&CacheSize, CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE, hDevice->get()));
476-
detail::ur::assertion(CacheSize >= 0);
475+
assert(CacheSize >= 0);
477476
// The L2 cache is global to the GPU.
478477
return ReturnValue(static_cast<uint64_t>(CacheSize));
479478
}
480479
case UR_DEVICE_INFO_GLOBAL_MEM_SIZE: {
481480
size_t Bytes = 0;
482481
// Runtime API has easy access to this value, driver API info is scarse.
483-
detail::ur::assertion(cuDeviceTotalMem(&Bytes, hDevice->get()) ==
484-
CUDA_SUCCESS);
482+
UR_CHECK_ERROR(cuDeviceTotalMem(&Bytes, hDevice->get()));
485483
return ReturnValue(uint64_t{Bytes});
486484
}
487485
case UR_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE: {
488486
int ConstantMemory = 0;
489487
UR_CHECK_ERROR(cuDeviceGetAttribute(
490488
&ConstantMemory, CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY,
491489
hDevice->get()));
492-
detail::ur::assertion(ConstantMemory >= 0);
490+
assert(ConstantMemory >= 0);
493491

494492
return ReturnValue(static_cast<uint64_t>(ConstantMemory));
495493
}
@@ -519,7 +517,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
519517
UR_CHECK_ERROR(cuDeviceGetAttribute(
520518
&ECCEnabled, CU_DEVICE_ATTRIBUTE_ECC_ENABLED, hDevice->get()));
521519

522-
detail::ur::assertion((ECCEnabled == 0) | (ECCEnabled == 1));
520+
assert((ECCEnabled == 0) | (ECCEnabled == 1));
523521
auto Result = static_cast<bool>(ECCEnabled);
524522
return ReturnValue(Result);
525523
}
@@ -528,7 +526,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
528526
UR_CHECK_ERROR(cuDeviceGetAttribute(
529527
&IsIntegrated, CU_DEVICE_ATTRIBUTE_INTEGRATED, hDevice->get()));
530528

531-
detail::ur::assertion((IsIntegrated == 0) | (IsIntegrated == 1));
529+
assert((IsIntegrated == 0) | (IsIntegrated == 1));
532530
auto result = static_cast<bool>(IsIntegrated);
533531
return ReturnValue(result);
534532
}
@@ -800,24 +798,22 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
800798
case UR_DEVICE_INFO_GLOBAL_MEM_FREE: {
801799
size_t FreeMemory = 0;
802800
size_t TotalMemory = 0;
803-
detail::ur::assertion(cuMemGetInfo(&FreeMemory, &TotalMemory) ==
804-
CUDA_SUCCESS,
805-
"failed cuMemGetInfo() API.");
801+
UR_CHECK_ERROR(cuMemGetInfo(&FreeMemory, &TotalMemory));
806802
return ReturnValue(FreeMemory);
807803
}
808804
case UR_DEVICE_INFO_MEMORY_CLOCK_RATE: {
809805
int Value = 0;
810806
UR_CHECK_ERROR(cuDeviceGetAttribute(
811807
&Value, CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE, hDevice->get()));
812-
detail::ur::assertion(Value >= 0);
808+
assert(Value >= 0);
813809
// Convert kilohertz to megahertz when returning.
814810
return ReturnValue(Value / 1000);
815811
}
816812
case UR_DEVICE_INFO_MEMORY_BUS_WIDTH: {
817813
int Value = 0;
818814
UR_CHECK_ERROR(cuDeviceGetAttribute(
819815
&Value, CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH, hDevice->get()));
820-
detail::ur::assertion(Value >= 0);
816+
assert(Value >= 0);
821817
return ReturnValue(Value);
822818
}
823819
case UR_DEVICE_INFO_MAX_COMPUTE_QUEUE_INDICES: {
@@ -953,17 +949,15 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
953949
int Value = 0;
954950
UR_CHECK_ERROR(cuDeviceGetAttribute(
955951
&Value, CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID, hDevice->get()));
956-
detail::ur::assertion(Value >= 0);
952+
assert(Value >= 0);
957953
return ReturnValue(Value);
958954
}
959955
case UR_DEVICE_INFO_UUID: {
960956
CUuuid UUID;
961957
#if (CUDA_VERSION >= 11040)
962-
detail::ur::assertion(cuDeviceGetUuid_v2(&UUID, hDevice->get()) ==
963-
CUDA_SUCCESS);
958+
UR_CHECK_ERROR(cuDeviceGetUuid_v2(&UUID, hDevice->get()));
964959
#else
965-
detail::ur::assertion(cuDeviceGetUuid(&UUID, hDevice->get()) ==
966-
CUDA_SUCCESS);
960+
UR_CHECK_ERROR(cuDeviceGetUuid(&UUID, hDevice->get()));
967961
#endif
968962
std::array<unsigned char, 16> Name;
969963
std::copy(UUID.bytes, UUID.bytes + 16, Name.begin());
@@ -1046,7 +1040,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10461040
&MaxRegisters, CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK,
10471041
hDevice->get()));
10481042

1049-
detail::ur::assertion(MaxRegisters >= 0);
1043+
assert(MaxRegisters >= 0);
10501044

10511045
return ReturnValue(static_cast<uint32_t>(MaxRegisters));
10521046
}
@@ -1060,7 +1054,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10601054
UR_CHECK_ERROR(
10611055
cuDeviceGetPCIBusId(AddressBuffer, AddressBufferSize, hDevice->get()));
10621056
// CUDA API (8.x - 12.1) guarantees 12 bytes + \0 are written
1063-
detail::ur::assertion(strnlen(AddressBuffer, AddressBufferSize) == 12);
1057+
assert(strnlen(AddressBuffer, AddressBufferSize) == 12);
10641058
return ReturnValue(AddressBuffer,
10651059
strnlen(AddressBuffer, AddressBufferSize - 1) + 1);
10661060
}

unified-runtime/source/adapters/cuda/enqueue.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,11 @@ static size_t imageElementByteSize(CUDA_ARRAY_DESCRIPTOR ArrayDesc) {
11031103
case CU_AD_FORMAT_FLOAT:
11041104
return 4;
11051105
default:
1106-
die("Invalid image format.");
1107-
return 0;
1106+
setErrorMessage("Invalid CUDA format specifier",
1107+
UR_RESULT_ERROR_ADAPTER_SPECIFIC);
1108+
throw UR_RESULT_ERROR_ADAPTER_SPECIFIC;
11081109
}
1110+
return 0;
11091111
}
11101112

11111113
/// General ND memory copy operation for images.

unified-runtime/source/adapters/cuda/event.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,19 @@ urEventWait(uint32_t numEvents, const ur_event_handle_t *phEventWaitList) {
250250
UR_APIEXPORT ur_result_t UR_APICALL urEventRetain(ur_event_handle_t hEvent) {
251251
const auto RefCount = hEvent->incrementReferenceCount();
252252

253-
detail::ur::assertion(RefCount != 0,
254-
"Reference count overflow detected in urEventRetain.");
253+
if (RefCount == 0) {
254+
return UR_RESULT_ERROR_OUT_OF_RESOURCES;
255+
}
255256

256257
return UR_RESULT_SUCCESS;
257258
}
258259

259260
UR_APIEXPORT ur_result_t UR_APICALL urEventRelease(ur_event_handle_t hEvent) {
260261
// double delete or someone is messing with the ref count.
261262
// either way, cannot safely proceed.
262-
detail::ur::assertion(hEvent->getReferenceCount() != 0,
263-
"Reference count overflow detected in urEventRelease.");
263+
if (hEvent->getReferenceCount() == 0) {
264+
return UR_RESULT_ERROR_INVALID_EVENT;
265+
}
264266

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

unified-runtime/source/adapters/cuda/image.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageGetInfoExp(
988988
ChannelOrder = UR_IMAGE_CHANNEL_ORDER_RGBA;
989989
break;
990990
default:
991-
die("Unexpected NumChannels returned by CUDA");
991+
setErrorMessage("Unexpected NumChannels returned by CUDA",
992+
UR_RESULT_ERROR_ADAPTER_SPECIFIC);
993+
return UR_RESULT_ERROR_ADAPTER_SPECIFIC;
992994
}
993995
if (pPropValue) {
994996
((ur_image_format_t *)pPropValue)->channelType = ChannelType;

unified-runtime/source/adapters/cuda/kernel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp(
210210
UR_CHECK_ERROR(cuOccupancyMaxActiveBlocksPerMultiprocessor(
211211
&MaxNumActiveGroupsPerCU, hKernel->get(), localWorkSize,
212212
dynamicSharedMemorySize));
213-
detail::ur::assertion(MaxNumActiveGroupsPerCU >= 0);
213+
assert(MaxNumActiveGroupsPerCU >= 0);
214214
// Handle the case where we can't have all SMs active with at least 1 group
215215
// per SM. In that case, the device is still able to run 1 work-group, hence
216216
// we will manually check if it is possible with the available HW resources.

unified-runtime/source/adapters/cuda/memory.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemRelease(ur_mem_handle_t hMem) {
110110
// error for which it is unclear if the function that reported it succeeded
111111
// or not. Either way, the state of the program is compromised and likely
112112
// unrecoverable.
113-
die("Unrecoverable program state reached in urMemRelease");
113+
setErrorMessage("Error in native free, program state may be "
114+
"compromised.",
115+
UR_RESULT_ERROR_ADAPTER_SPECIFIC);
116+
return UR_RESULT_ERROR_ADAPTER_SPECIFIC;
114117
}
115118

116119
return UR_RESULT_SUCCESS;

unified-runtime/source/adapters/cuda/queue.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,16 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle(
195195
UR_CHECK_ERROR(cuStreamGetFlags(CuStream, &CuFlags));
196196

197197
ur_queue_flags_t Flags = 0;
198-
if (CuFlags == CU_STREAM_DEFAULT)
198+
if (CuFlags == CU_STREAM_DEFAULT) {
199199
Flags = UR_QUEUE_FLAG_USE_DEFAULT_STREAM;
200-
else if (CuFlags == CU_STREAM_NON_BLOCKING)
200+
} else if (CuFlags == CU_STREAM_NON_BLOCKING) {
201201
Flags = UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM;
202-
else
203-
die("Unknown cuda stream");
202+
} else {
203+
setErrorMessage("Incorrect native stream flags, expecting "
204+
"CU_STREAM_DEFAULT or CU_STREAM_NON_BLOCKING",
205+
UR_RESULT_ERROR_ADAPTER_SPECIFIC);
206+
return UR_RESULT_ERROR_ADAPTER_SPECIFIC;
207+
}
204208

205209
auto isNativeHandleOwned =
206210
pProperties ? pProperties->isNativeHandleOwned : false;

unified-runtime/source/adapters/cuda/sampler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ UR_APIEXPORT ur_result_t UR_APICALL
103103
urSamplerRelease(ur_sampler_handle_t hSampler) {
104104
// double delete or someone is messing with the ref count.
105105
// either way, cannot safely proceed.
106-
detail::ur::assertion(
107-
hSampler->getReferenceCount() != 0,
108-
"Reference count overflow detected in urSamplerRelease.");
106+
if (hSampler->getReferenceCount() == 0) {
107+
return UR_RESULT_ERROR_INVALID_SAMPLER;
108+
}
109109

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

0 commit comments

Comments
 (0)