From 4d1015397c3c56181e09bba459ba795656c46d56 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Wed, 7 Oct 2020 11:50:07 -0700 Subject: [PATCH 1/8] [SYCL] Removes any knowledge of specific memory advices from PI API. Signed-off-by: Sergey V Maslov --- sycl/include/CL/sycl/detail/pi.h | 23 +---------------- sycl/plugins/level_zero/pi_level_zero.cpp | 31 +---------------------- 2 files changed, 2 insertions(+), 52 deletions(-) mode change 100644 => 100755 sycl/plugins/level_zero/pi_level_zero.cpp diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index 2a0ae02101dcf..d7f57415b2eba 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -388,27 +388,6 @@ typedef enum { PI_MEM_TYPE_IMAGE1D_BUFFER = CL_MEM_OBJECT_IMAGE1D_BUFFER } _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 -} _pi_mem_advice; - typedef enum { PI_IMAGE_CHANNEL_ORDER_A = CL_A, PI_IMAGE_CHANNEL_ORDER_R = CL_R, @@ -538,7 +517,7 @@ using pi_fp_capabilities = _pi_fp_capabilities; using pi_event_info = _pi_event_info; using pi_command_type = _pi_command_type; using pi_mem_type = _pi_mem_type; -using pi_mem_advice = _pi_mem_advice; +using pi_mem_advice = pi_int32; using pi_image_channel_order = _pi_image_channel_order; using pi_image_channel_type = _pi_image_channel_type; using pi_buffer_create_type = _pi_buffer_create_type; diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp old mode 100644 new mode 100755 index d0cd5c3b91e34..fd3091d073738 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -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 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(Advice); // Get a new command list to be used on this call ze_command_list_handle_t ZeCommandList = nullptr; From 6aea198d102fa0fc1f3d4fc05d152e2886ba6988 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Wed, 7 Oct 2020 20:58:07 -0700 Subject: [PATCH 2/8] [SYCL] fix ABI test Signed-off-by: Sergey V Maslov --- sycl/include/CL/sycl/detail/pi.h | 4 +++- sycl/test/usm/memadvise.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) mode change 100644 => 100755 sycl/include/CL/sycl/detail/pi.h mode change 100644 => 100755 sycl/test/usm/memadvise.cpp diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h old mode 100644 new mode 100755 index d7f57415b2eba..37c3b981f3b3a --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -388,6 +388,8 @@ typedef enum { PI_MEM_TYPE_IMAGE1D_BUFFER = CL_MEM_OBJECT_IMAGE1D_BUFFER } _pi_mem_type; +typedef pi_int32 _pi_mem_advice; + typedef enum { PI_IMAGE_CHANNEL_ORDER_A = CL_A, PI_IMAGE_CHANNEL_ORDER_R = CL_R, @@ -517,7 +519,7 @@ using pi_fp_capabilities = _pi_fp_capabilities; using pi_event_info = _pi_event_info; using pi_command_type = _pi_command_type; using pi_mem_type = _pi_mem_type; -using pi_mem_advice = pi_int32; +using pi_mem_advice = _pi_mem_advice; using pi_image_channel_order = _pi_image_channel_order; using pi_image_channel_type = _pi_image_channel_type; using pi_buffer_create_type = _pi_buffer_create_type; diff --git a/sycl/test/usm/memadvise.cpp b/sycl/test/usm/memadvise.cpp old mode 100644 new mode 100755 index 9b584c045e2e5..3224d78e002bc --- a/sycl/test/usm/memadvise.cpp +++ b/sycl/test/usm/memadvise.cpp @@ -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), 0); Node *s_cur = s_head; for (int i = 0; i < numNodes; i++) { @@ -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), 0); } else { s_cur->pNext = nullptr; } From 4929a2fdec5c0f904e0ac72ef2fb54b78a753cc5 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Wed, 7 Oct 2020 20:58:31 -0700 Subject: [PATCH 3/8] [SYCL] chmod 644 Signed-off-by: Sergey V Maslov --- sycl/include/CL/sycl/detail/pi.h | 0 sycl/test/usm/memadvise.cpp | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 sycl/include/CL/sycl/detail/pi.h mode change 100755 => 100644 sycl/test/usm/memadvise.cpp diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h old mode 100755 new mode 100644 diff --git a/sycl/test/usm/memadvise.cpp b/sycl/test/usm/memadvise.cpp old mode 100755 new mode 100644 From cc5b3635afaeac8352e403e6c7787de9d90d09e3 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Thu, 8 Oct 2020 08:39:00 -0700 Subject: [PATCH 4/8] [SYCL] add comment Signed-off-by: Sergey V Maslov --- sycl/include/CL/sycl/detail/pi.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index 37c3b981f3b3a..e71f4624f3581 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -388,6 +388,7 @@ typedef enum { PI_MEM_TYPE_IMAGE1D_BUFFER = CL_MEM_OBJECT_IMAGE1D_BUFFER } _pi_mem_type; +// Device-specific value opaque in PI API. typedef pi_int32 _pi_mem_advice; typedef enum { From d7f3849de2c8dc6824567ef2da0570678dfae276 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Mon, 12 Oct 2020 08:24:37 -0700 Subject: [PATCH 5/8] [SYCL] make this PR nor breaking ABI Signed-off-by: Sergey V Maslov --- sycl/include/CL/sycl/detail/pi.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index e71f4624f3581..6468e92a53bf7 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -388,8 +388,9 @@ typedef enum { PI_MEM_TYPE_IMAGE1D_BUFFER = CL_MEM_OBJECT_IMAGE1D_BUFFER } _pi_mem_type; -// Device-specific value opaque in PI API. -typedef pi_int32 _pi_mem_advice; +typedef enum { + // Device-specific value opaque in PI API. +} _pi_mem_advice; typedef enum { PI_IMAGE_CHANNEL_ORDER_A = CL_A, From 1e9ebf4b0dca646aa083c148e073d820722360de Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Tue, 13 Oct 2020 00:20:44 -0700 Subject: [PATCH 6/8] [SYCL] add cast Signed-off-by: Sergey V Maslov --- sycl/test/usm/memadvise.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/test/usm/memadvise.cpp b/sycl/test/usm/memadvise.cpp index 3224d78e002bc..7dda09f17b764 100644 --- a/sycl/test/usm/memadvise.cpp +++ b/sycl/test/usm/memadvise.cpp @@ -36,7 +36,7 @@ int main() { if (s_head == nullptr) { return -1; } - q.mem_advise(s_head, sizeof(Node), 0); + q.mem_advise(s_head, sizeof(Node), (pi_mem_advice)0); Node *s_cur = s_head; for (int i = 0; i < numNodes; i++) { @@ -47,7 +47,7 @@ int main() { if (s_cur->pNext == nullptr) { return -1; } - q.mem_advise(s_cur->pNext, sizeof(Node), 0); + q.mem_advise(s_cur->pNext, sizeof(Node), (pi_mem_advice)0); } else { s_cur->pNext = nullptr; } From 60b6753568bb15f51f9821f9b04c9c51fa86f666 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Tue, 13 Oct 2020 00:59:28 -0700 Subject: [PATCH 7/8] [SYCL] make enum non-empty Signed-off-by: Sergey V Maslov --- sycl/include/CL/sycl/detail/pi.h | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 sycl/include/CL/sycl/detail/pi.h diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h old mode 100644 new mode 100755 index 6468e92a53bf7..faeabd0fb40b3 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -390,6 +390,7 @@ typedef enum { typedef enum { // Device-specific value opaque in PI API. + PI_MEM_ADVISE_UNKNOWN } _pi_mem_advice; typedef enum { From 21745dbee081033410c933a8cfd16b64057e0f1d Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Tue, 13 Oct 2020 00:59:47 -0700 Subject: [PATCH 8/8] [SYCL] chmod 644 Signed-off-by: Sergey V Maslov --- sycl/include/CL/sycl/detail/pi.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 sycl/include/CL/sycl/detail/pi.h diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h old mode 100755 new mode 100644