Skip to content

[SYCL] Removes any knowledge of specific memory advices from PI API. #2607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions sycl/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,24 +389,8 @@ typedef enum {
} _pi_mem_type;

typedef enum {
PI_MEM_ADVICE_SET_READ_MOSTLY = 0, ///< hints that memory will be read from
///< frequently and written to rarely
PI_MEM_ADVICE_CLEAR_READ_MOSTLY, ///< removes the affect of
///< PI_MEM_ADVICE_SET_READ_MOSTLY
PI_MEM_ADVICE_SET_PREFERRED_LOCATION, ///< hints that the preferred memory
///< location is the specified device
PI_MEM_ADVICE_CLEAR_PREFERRED_LOCATION, ///< removes the affect of
///< PI_MEM_ADVICE_SET_PREFERRED_LOCATION
PI_MEM_ADVICE_SET_ACCESSED_BY, ///< hints that memory will be accessed by the
///< specified device
PI_MEM_ADVICE_CLEAR_ACCESSED_BY, ///< removes the affect of
///< PI_MEM_ADVICE_SET_ACCESSED_BY
PI_MEM_ADVICE_SET_NON_ATOMIC_MOSTLY, ///< hints that memory will mostly be
///< accessed non-atomically
PI_MEM_ADVICE_CLEAR_NON_ATOMIC_MOSTLY, ///< removes the affect of
///< PI_MEM_ADVICE_SET_NON_ATOMIC_MOSTLY
PI_MEM_ADVICE_BIAS_CACHED, ///< hints that memory should be cached
PI_MEM_ADVICE_BIAS_UNCACHED ///< hints that memory should not be cached
// Device-specific value opaque in PI API.
PI_MEM_ADVISE_UNKNOWN
} _pi_mem_advice;

typedef enum {
Expand Down
31 changes: 1 addition & 30 deletions sycl/plugins/level_zero/pi_level_zero.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4686,36 +4686,7 @@ pi_result piextUSMEnqueueMemAdvise(pi_queue Queue, const void *Ptr,
// Lock automatically releases when this goes out of scope.
std::lock_guard<std::mutex> lock(Queue->PiQueueMutex);

ze_memory_advice_t ZeAdvice = {};
switch (Advice) {
case PI_MEM_ADVICE_SET_READ_MOSTLY:
ZeAdvice = ZE_MEMORY_ADVICE_SET_READ_MOSTLY;
break;
case PI_MEM_ADVICE_CLEAR_READ_MOSTLY:
ZeAdvice = ZE_MEMORY_ADVICE_CLEAR_READ_MOSTLY;
break;
case PI_MEM_ADVICE_SET_PREFERRED_LOCATION:
ZeAdvice = ZE_MEMORY_ADVICE_SET_PREFERRED_LOCATION;
break;
case PI_MEM_ADVICE_CLEAR_PREFERRED_LOCATION:
ZeAdvice = ZE_MEMORY_ADVICE_CLEAR_PREFERRED_LOCATION;
break;
case PI_MEM_ADVICE_SET_NON_ATOMIC_MOSTLY:
ZeAdvice = ZE_MEMORY_ADVICE_SET_NON_ATOMIC_MOSTLY;
break;
case PI_MEM_ADVICE_CLEAR_NON_ATOMIC_MOSTLY:
ZeAdvice = ZE_MEMORY_ADVICE_CLEAR_NON_ATOMIC_MOSTLY;
break;
case PI_MEM_ADVICE_BIAS_CACHED:
ZeAdvice = ZE_MEMORY_ADVICE_BIAS_CACHED;
break;
case PI_MEM_ADVICE_BIAS_UNCACHED:
ZeAdvice = ZE_MEMORY_ADVICE_BIAS_UNCACHED;
break;
default:
zePrint("piextUSMEnqueueMemAdvise: unexpected memory advise\n");
return PI_INVALID_VALUE;
}
auto ZeAdvice = pi_cast<ze_memory_advice_t>(Advice);

// Get a new command list to be used on this call
ze_command_list_handle_t ZeCommandList = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions sycl/test/usm/memadvise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main() {
if (s_head == nullptr) {
return -1;
}
q.mem_advise(s_head, sizeof(Node), PI_MEM_ADVICE_SET_READ_MOSTLY);
q.mem_advise(s_head, sizeof(Node), (pi_mem_advice)0);
Node *s_cur = s_head;

for (int i = 0; i < numNodes; i++) {
Expand All @@ -47,7 +47,7 @@ int main() {
if (s_cur->pNext == nullptr) {
return -1;
}
q.mem_advise(s_cur->pNext, sizeof(Node), PI_MEM_ADVICE_SET_READ_MOSTLY);
q.mem_advise(s_cur->pNext, sizeof(Node), (pi_mem_advice)0);
} else {
s_cur->pNext = nullptr;
}
Expand Down