Skip to content

Commit 7dfaf3b

Browse files
authored
[SYCL] Reject alignment requests > 64KB. (#4263)
This change caps alignment of allocation requests at 64KB. That is the default alignment supported by level_zero, and no other alignments are supported. Signed-off-by: rdeodhar <[email protected]>
1 parent c045995 commit 7dfaf3b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6048,6 +6048,11 @@ pi_result piextUSMDeviceAlloc(void **ResultPtr, pi_context Context,
60486048
pi_device Device,
60496049
pi_usm_mem_properties *Properties, size_t Size,
60506050
pi_uint32 Alignment) {
6051+
// L0 supports alignment up to 64KB and silently ignores higher values.
6052+
// We flag alignment > 64KB as an invalid value.
6053+
if (Alignment > 65536)
6054+
return PI_INVALID_VALUE;
6055+
60516056
pi_platform Plt = Device->Platform;
60526057
std::unique_lock<std::mutex> ContextsLock(Plt->ContextsMutex,
60536058
std::defer_lock);
@@ -6106,6 +6111,11 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context,
61066111
pi_device Device,
61076112
pi_usm_mem_properties *Properties, size_t Size,
61086113
pi_uint32 Alignment) {
6114+
// L0 supports alignment up to 64KB and silently ignores higher values.
6115+
// We flag alignment > 64KB as an invalid value.
6116+
if (Alignment > 65536)
6117+
return PI_INVALID_VALUE;
6118+
61096119
pi_platform Plt = Device->Platform;
61106120
std::unique_lock<std::mutex> ContextsLock(Plt->ContextsMutex,
61116121
std::defer_lock);
@@ -6162,6 +6172,11 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context,
61626172
pi_result piextUSMHostAlloc(void **ResultPtr, pi_context Context,
61636173
pi_usm_mem_properties *Properties, size_t Size,
61646174
pi_uint32 Alignment) {
6175+
// L0 supports alignment up to 64KB and silently ignores higher values.
6176+
// We flag alignment > 64KB as an invalid value.
6177+
if (Alignment > 65536)
6178+
return PI_INVALID_VALUE;
6179+
61656180
pi_platform Plt = Context->Devices[0]->Platform;
61666181
std::unique_lock<std::mutex> ContextsLock(Plt->ContextsMutex,
61676182
std::defer_lock);

0 commit comments

Comments
 (0)