Skip to content

Commit

Permalink
[SYCL] Reject alignment requests > 64KB. (#4263)
Browse files Browse the repository at this point in the history
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 <rajiv.deodhar@intel.com>
  • Loading branch information
rdeodhar committed Aug 10, 2021
1 parent c045995 commit 7dfaf3b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6048,6 +6048,11 @@ pi_result piextUSMDeviceAlloc(void **ResultPtr, pi_context Context,
pi_device Device,
pi_usm_mem_properties *Properties, size_t Size,
pi_uint32 Alignment) {
// L0 supports alignment up to 64KB and silently ignores higher values.
// We flag alignment > 64KB as an invalid value.
if (Alignment > 65536)
return PI_INVALID_VALUE;

pi_platform Plt = Device->Platform;
std::unique_lock<std::mutex> ContextsLock(Plt->ContextsMutex,
std::defer_lock);
Expand Down Expand Up @@ -6106,6 +6111,11 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context,
pi_device Device,
pi_usm_mem_properties *Properties, size_t Size,
pi_uint32 Alignment) {
// L0 supports alignment up to 64KB and silently ignores higher values.
// We flag alignment > 64KB as an invalid value.
if (Alignment > 65536)
return PI_INVALID_VALUE;

pi_platform Plt = Device->Platform;
std::unique_lock<std::mutex> ContextsLock(Plt->ContextsMutex,
std::defer_lock);
Expand Down Expand Up @@ -6162,6 +6172,11 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context,
pi_result piextUSMHostAlloc(void **ResultPtr, pi_context Context,
pi_usm_mem_properties *Properties, size_t Size,
pi_uint32 Alignment) {
// L0 supports alignment up to 64KB and silently ignores higher values.
// We flag alignment > 64KB as an invalid value.
if (Alignment > 65536)
return PI_INVALID_VALUE;

pi_platform Plt = Context->Devices[0]->Platform;
std::unique_lock<std::mutex> ContextsLock(Plt->ContextsMutex,
std::defer_lock);
Expand Down

0 comments on commit 7dfaf3b

Please sign in to comment.