@@ -311,8 +311,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMHostAlloc(
311
311
// L0 supports alignment up to 64KB and silently ignores higher values.
312
312
// We flag alignment > 64KB as an invalid value.
313
313
// L0 spec says that alignment values that are not powers of 2 are invalid.
314
- if (Align > 65536 || (Align & (Align - 1 )) != 0 )
315
- return UR_RESULT_ERROR_INVALID_VALUE;
314
+ // If alignment == 0, then we are allowing the L0 driver to choose the
315
+ // alignment so no need to check.
316
+ if (Align > 0 ) {
317
+ if (Align > 65536 || (Align & (Align - 1 )) != 0 )
318
+ return UR_RESULT_ERROR_INVALID_VALUE;
319
+ }
316
320
317
321
ur_platform_handle_t Plt = Context->getPlatform ();
318
322
// If indirect access tracking is enabled then lock the mutex which is
@@ -381,8 +385,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMDeviceAlloc(
381
385
// L0 supports alignment up to 64KB and silently ignores higher values.
382
386
// We flag alignment > 64KB as an invalid value.
383
387
// L0 spec says that alignment values that are not powers of 2 are invalid.
384
- if (Alignment > 65536 || (Alignment & (Alignment - 1 )) != 0 )
385
- return UR_RESULT_ERROR_INVALID_VALUE;
388
+ // If alignment == 0, then we are allowing the L0 driver to choose the
389
+ // alignment so no need to check.
390
+ if (Alignment > 0 ) {
391
+ if (Alignment > 65536 || (Alignment & (Alignment - 1 )) != 0 )
392
+ return UR_RESULT_ERROR_INVALID_VALUE;
393
+ }
386
394
387
395
ur_platform_handle_t Plt = Device->Platform ;
388
396
@@ -482,8 +490,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMSharedAlloc(
482
490
// L0 supports alignment up to 64KB and silently ignores higher values.
483
491
// We flag alignment > 64KB as an invalid value.
484
492
// L0 spec says that alignment values that are not powers of 2 are invalid.
485
- if (Alignment > 65536 || (Alignment & (Alignment - 1 )) != 0 )
486
- return UR_RESULT_ERROR_INVALID_VALUE;
493
+ // If alignment == 0, then we are allowing the L0 driver to choose the
494
+ // alignment so no need to check.
495
+ if (Alignment > 0 ) {
496
+ if (Alignment > 65536 || (Alignment & (Alignment - 1 )) != 0 )
497
+ return UR_RESULT_ERROR_INVALID_VALUE;
498
+ }
487
499
488
500
ur_platform_handle_t Plt = Device->Platform ;
489
501
0 commit comments