From 9ca5bb0bc18845da8a5dd72b2df591fc650e77f7 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 09:04:37 -0400
Subject: [PATCH 01/14] sycl canary test

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 58 ++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 test/parallel_api/sycl_canary.pass.cpp

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
new file mode 100644
index 00000000000..1bbc20f7577
--- /dev/null
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -0,0 +1,58 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Copyright (C) Intel Corporation
+//
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+// This file incorporates work covered by the following copyright and permission
+// notice:
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+//
+//===----------------------------------------------------------------------===//
+
+// This test is a simple standalone SYCL test which is meant to prove that the SYCL installation is correct.
+// If this test fails, it means that the SYCL environment has not be configured properly.
+
+#if __has_include(<sycl/sycl.hpp>)
+#    include <sycl/sycl.hpp>
+#else
+#    include <CL/sycl.hpp>
+#endif
+
+// Combine SYCL runtime library version
+#if defined(__LIBSYCL_MAJOR_VERSION) && defined(__LIBSYCL_MINOR_VERSION) && defined(__LIBSYCL_PATCH_VERSION)
+#    define TEST_LIBSYCL_VERSION                                                                                    \
+        (__LIBSYCL_MAJOR_VERSION * 10000 + __LIBSYCL_MINOR_VERSION * 100 + __LIBSYCL_PATCH_VERSION)
+#else
+#    define TEST_LIBSYCL_VERSION 0
+#endif
+
+
+inline auto default_selector =
+#    if TEST_LIBSYCL_VERSION >= 60000
+        sycl::default_selector_v;
+#    else
+        sycl::default_selector{};
+#    endif
+
+void
+test()
+{
+    sycl::queue q(default_selector);
+    {
+        q.submit([&](sycl::handler& cgh) {
+            cgh.single_task([=]() {});
+        });
+    }
+}
+
+int
+main()
+{
+    test();
+
+    return 0;
+}
\ No newline at end of file

From 1a40ff4d2f87f4cd6b6c3d98f8ee2affe0dce45f Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 10:57:36 -0400
Subject: [PATCH 02/14] adding a kernel name

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 1bbc20f7577..4cf2acd0413 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -38,13 +38,15 @@ inline auto default_selector =
         sycl::default_selector{};
 #    endif
 
+class canary_test_name;
+
 void
 test()
 {
     sycl::queue q(default_selector);
     {
         q.submit([&](sycl::handler& cgh) {
-            cgh.single_task([=]() {});
+            cgh.single_task<canary_test_name>([=]() {});
         });
     }
 }

From 18febfc33497e8151bd22426f30af983825129cd Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 11:41:23 -0400
Subject: [PATCH 03/14] protecting SYCL code with guards

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 4cf2acd0413..53a158b5fe8 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -16,12 +16,23 @@
 // This test is a simple standalone SYCL test which is meant to prove that the SYCL installation is correct.
 // If this test fails, it means that the SYCL environment has not be configured properly.
 
+#if ((defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)) &&                                         \
+     (__has_include(<sycl/sycl.hpp>) || __has_include(<CL/sycl.hpp>))) &&                                             \
+    (!defined(ONEDPL_USE_DPCPP_BACKEND) || ONEDPL_USE_DPCPP_BACKEND != 0)
+#define TEST_DPCPP_BACKEND_PRESENT 1
+#else
+#define TEST_DPCPP_BACKEND_PRESENT 0
+#endif
+
+#if TEST_DPCPP_BACKEND_PRESENT
+
 #if __has_include(<sycl/sycl.hpp>)
 #    include <sycl/sycl.hpp>
 #else
 #    include <CL/sycl.hpp>
 #endif
 
+
 // Combine SYCL runtime library version
 #if defined(__LIBSYCL_MAJOR_VERSION) && defined(__LIBSYCL_MINOR_VERSION) && defined(__LIBSYCL_PATCH_VERSION)
 #    define TEST_LIBSYCL_VERSION                                                                                    \
@@ -50,11 +61,13 @@ test()
         });
     }
 }
+#endif // TEST_DPCPP_BACKEND_PRESENT
 
 int
 main()
 {
+#if TEST_DPCPP_BACKEND_PRESENT
     test();
-
+#endif
     return 0;
 }
\ No newline at end of file

From fb9221a37c519604d6b2bb683c73cc868cbbc091 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 16:21:25 -0400
Subject: [PATCH 04/14] Address review feedback

Signed-off-by: Dan Hoeflinger
<dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 53a158b5fe8..0a461e951de 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -5,17 +5,14 @@
 //
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
-// This file incorporates work covered by the following copyright and permission
-// notice:
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-//
 //===----------------------------------------------------------------------===//
 
 // This test is a simple standalone SYCL test which is meant to prove that the SYCL installation is correct.
 // If this test fails, it means that the SYCL environment has not be configured properly.
 
+#include <cstdlib>
+#include <iostream>
+
 #if ((defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)) &&                                         \
      (__has_include(<sycl/sycl.hpp>) || __has_include(<CL/sycl.hpp>))) &&                                             \
     (!defined(ONEDPL_USE_DPCPP_BACKEND) || ONEDPL_USE_DPCPP_BACKEND != 0)
@@ -41,6 +38,7 @@
 #    define TEST_LIBSYCL_VERSION 0
 #endif
 
+#define _SKIP_RETURN_CODE 77
 
 inline auto default_selector =
 #    if TEST_LIBSYCL_VERSION >= 60000
@@ -55,11 +53,9 @@ void
 test()
 {
     sycl::queue q(default_selector);
-    {
-        q.submit([&](sycl::handler& cgh) {
-            cgh.single_task<canary_test_name>([=]() {});
-        });
-    }
+    q.submit([&](sycl::handler& cgh) {
+        cgh.single_task<canary_test_name>([=]() {});
+    });
 }
 #endif // TEST_DPCPP_BACKEND_PRESENT
 
@@ -69,5 +65,11 @@ main()
 #if TEST_DPCPP_BACKEND_PRESENT
     test();
 #endif
-    return 0;
+    if (std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST") != nullptr)
+    {
+        std::cout << "Skipped\n";
+        return _SKIP_RETURN_CODE;
+    }
+    else
+        return 0;
 }
\ No newline at end of file

From 5e41eda1612a462d0d7cf02359090e2348c61758 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 16:32:15 -0400
Subject: [PATCH 05/14] adding comment

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 0a461e951de..5fa208ac333 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -67,6 +67,8 @@ main()
 #endif
     if (std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST") != nullptr)
     {
+        // This environment variable allows our main CI run to skip this test and not count it toward oneDPL's test
+        // statistics, while still allowing non-ci test runs to have this as a enviornment health indicater.
         std::cout << "Skipped\n";
         return _SKIP_RETURN_CODE;
     }

From 08f679aab238ed42b4c5f3799994718a1251840b Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 16:36:56 -0400
Subject: [PATCH 06/14] spelling fix

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 5fa208ac333..094bbb446d9 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -68,7 +68,7 @@ main()
     if (std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST") != nullptr)
     {
         // This environment variable allows our main CI run to skip this test and not count it toward oneDPL's test
-        // statistics, while still allowing non-ci test runs to have this as a enviornment health indicater.
+        // statistics, while still allowing non-ci test runs to have this as a environment health indicater.
         std::cout << "Skipped\n";
         return _SKIP_RETURN_CODE;
     }

From 6d538d78336af7db91a14ab4b8261375ee09f200 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 16:43:02 -0400
Subject: [PATCH 07/14] EOL

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 094bbb446d9..197dd100db2 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -74,4 +74,4 @@ main()
     }
     else
         return 0;
-}
\ No newline at end of file
+}

From 82f07a2e1d45d0e6918373e4c1a5effe026be9bd Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 17:00:22 -0400
Subject: [PATCH 08/14] windows quirks

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 197dd100db2..6583b469671 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -13,6 +13,11 @@
 #include <cstdlib>
 #include <iostream>
 
+#if _MSC_VER
+// algorithm is required as a workaround for a bug on windows with sycl includes not including it for std::iter_swap
+#   include <algorithm>
+#endif
+
 #if ((defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)) &&                                         \
      (__has_include(<sycl/sycl.hpp>) || __has_include(<CL/sycl.hpp>))) &&                                             \
     (!defined(ONEDPL_USE_DPCPP_BACKEND) || ONEDPL_USE_DPCPP_BACKEND != 0)
@@ -65,7 +70,21 @@ main()
 #if TEST_DPCPP_BACKEND_PRESENT
     test();
 #endif
-    if (std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST") != nullptr)
+
+#if _MSC_VER
+   char *pValue;
+   size_t len;
+   errno_t err = _dupenv_s( &pValue, &len, "_ONEDPL_SKIP_SYCL_CANARY_TEST" );
+    if (err)
+    {
+        std::cout << "Environment variable gather failed\n";
+        return 1;
+    } 
+#else
+    const char* pValue = std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST");
+#endif
+    bool __skip_sycl_canary_test = (pValue != nullptr);
+    if (__skip_sycl_canary_test)
     {
         // This environment variable allows our main CI run to skip this test and not count it toward oneDPL's test
         // statistics, while still allowing non-ci test runs to have this as a environment health indicater.

From 731c05638c4c1aa204a7be9c1691c5305cecb310 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 17:02:03 -0400
Subject: [PATCH 09/14] moving test inside non-skipped branch

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 6583b469671..50fbf2be6e5 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -67,9 +67,6 @@ test()
 int
 main()
 {
-#if TEST_DPCPP_BACKEND_PRESENT
-    test();
-#endif
 
 #if _MSC_VER
    char *pValue;
@@ -92,5 +89,10 @@ main()
         return _SKIP_RETURN_CODE;
     }
     else
+    {
+#if TEST_DPCPP_BACKEND_PRESENT
+        test();
+#endif
         return 0;
+    }
 }

From 6abd78eeb43eb83ceac63d13d5c4aa112b73e927 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 17:13:44 -0400
Subject: [PATCH 10/14] rearrange logic to show "skipped" when not dpcpp
 backend

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 50fbf2be6e5..1313ad95226 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -26,6 +26,8 @@
 #define TEST_DPCPP_BACKEND_PRESENT 0
 #endif
 
+#define _SKIP_RETURN_CODE 77
+
 #if TEST_DPCPP_BACKEND_PRESENT
 
 #if __has_include(<sycl/sycl.hpp>)
@@ -43,8 +45,6 @@
 #    define TEST_LIBSYCL_VERSION 0
 #endif
 
-#define _SKIP_RETURN_CODE 77
-
 inline auto default_selector =
 #    if TEST_LIBSYCL_VERSION >= 60000
         sycl::default_selector_v;
@@ -81,18 +81,15 @@ main()
     const char* pValue = std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST");
 #endif
     bool __skip_sycl_canary_test = (pValue != nullptr);
-    if (__skip_sycl_canary_test)
-    {
-        // This environment variable allows our main CI run to skip this test and not count it toward oneDPL's test
-        // statistics, while still allowing non-ci test runs to have this as a environment health indicater.
-        std::cout << "Skipped\n";
-        return _SKIP_RETURN_CODE;
-    }
-    else
+    // This environment variable allows our main CI run to skip this test and not count it toward oneDPL's test
+    // statistics, while still allowing non-ci test runs to have this as a environment health indicater.
+    if (!__skip_sycl_canary_test)
     {
 #if TEST_DPCPP_BACKEND_PRESENT
         test();
-#endif
         return 0;
+#endif
     }
+    std::cout << "Skipped\n";
+    return _SKIP_RETURN_CODE;
 }

From f83b897e46bd3b5271ec02ecafcd6dd97e37e835 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 17:18:52 -0400
Subject: [PATCH 11/14] avoiding env var stuff if no need.

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 1313ad95226..8a42c12510d 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -10,13 +10,10 @@
 // This test is a simple standalone SYCL test which is meant to prove that the SYCL installation is correct.
 // If this test fails, it means that the SYCL environment has not be configured properly.
 
-#include <cstdlib>
 #include <iostream>
 
-#if _MSC_VER
-// algorithm is required as a workaround for a bug on windows with sycl includes not including it for std::iter_swap
-#   include <algorithm>
-#endif
+#define _SKIP_RETURN_CODE 77
+
 
 #if ((defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)) &&                                         \
      (__has_include(<sycl/sycl.hpp>) || __has_include(<CL/sycl.hpp>))) &&                                             \
@@ -26,10 +23,15 @@
 #define TEST_DPCPP_BACKEND_PRESENT 0
 #endif
 
-#define _SKIP_RETURN_CODE 77
-
 #if TEST_DPCPP_BACKEND_PRESENT
 
+#include <cstdlib>
+
+#if _MSC_VER
+// algorithm is required as a workaround for a bug on windows with sycl includes not including it for std::iter_swap
+#   include <algorithm>
+#endif
+
 #if __has_include(<sycl/sycl.hpp>)
 #    include <sycl/sycl.hpp>
 #else
@@ -67,7 +69,7 @@ test()
 int
 main()
 {
-
+#if TEST_DPCPP_BACKEND_PRESENT
 #if _MSC_VER
    char *pValue;
    size_t len;
@@ -77,19 +79,18 @@ main()
         std::cout << "Environment variable gather failed\n";
         return 1;
     } 
-#else
+#else // _MSC_VER
     const char* pValue = std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST");
-#endif
+#endif // _MSC_VER
     bool __skip_sycl_canary_test = (pValue != nullptr);
     // This environment variable allows our main CI run to skip this test and not count it toward oneDPL's test
     // statistics, while still allowing non-ci test runs to have this as a environment health indicater.
     if (!__skip_sycl_canary_test)
     {
-#if TEST_DPCPP_BACKEND_PRESENT
         test();
         return 0;
-#endif
     }
+#endif // TEST_DPCPP_BACKEND_PRESENT
     std::cout << "Skipped\n";
     return _SKIP_RETURN_CODE;
 }

From b32ba8aeb8dd0e1679054c313f76e2c0ad55bb67 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Fri, 6 Sep 2024 17:27:01 -0400
Subject: [PATCH 12/14] restricting workaround to a specific icx version

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 8a42c12510d..32f6d09055a 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -27,8 +27,9 @@
 
 #include <cstdlib>
 
-#if _MSC_VER
-// algorithm is required as a workaround for a bug on windows with sycl includes not including it for std::iter_swap
+#if _MSC_VER && __INTEL_LLVM_COMPILER <= 20240000
+// Algorithm is required as a workaround for a bug on windows before icx 2024.0.0 with sycl headers
+// not including the appropriate headers for std::iter_swap
 #   include <algorithm>
 #endif
 

From 707993bcc67398a930979167e6376ba1bb35a947 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Wed, 11 Sep 2024 11:14:36 -0400
Subject: [PATCH 13/14] making a trivial parallel launch for sycl kernel;
 formatting

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 79 +++++++++++++++-----------
 1 file changed, 46 insertions(+), 33 deletions(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 32f6d09055a..16721cab51b 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -14,56 +14,70 @@
 
 #define _SKIP_RETURN_CODE 77
 
-
-#if ((defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)) &&                                         \
+#if ((defined(CL_SYCL_LANGUAGE_VERSION) || defined(SYCL_LANGUAGE_VERSION)) &&                                          \
      (__has_include(<sycl/sycl.hpp>) || __has_include(<CL/sycl.hpp>))) &&                                             \
     (!defined(ONEDPL_USE_DPCPP_BACKEND) || ONEDPL_USE_DPCPP_BACKEND != 0)
-#define TEST_DPCPP_BACKEND_PRESENT 1
+#    define TEST_DPCPP_BACKEND_PRESENT 1
 #else
-#define TEST_DPCPP_BACKEND_PRESENT 0
+#    define TEST_DPCPP_BACKEND_PRESENT 0
 #endif
 
 #if TEST_DPCPP_BACKEND_PRESENT
 
-#include <cstdlib>
+#    include <cstdlib>
 
-#if _MSC_VER && __INTEL_LLVM_COMPILER <= 20240000
+#    if _MSC_VER && __INTEL_LLVM_COMPILER <= 20240000
 // Algorithm is required as a workaround for a bug on windows before icx 2024.0.0 with sycl headers
 // not including the appropriate headers for std::iter_swap
-#   include <algorithm>
-#endif
-
-#if __has_include(<sycl/sycl.hpp>)
-#    include <sycl/sycl.hpp>
-#else
-#    include <CL/sycl.hpp>
-#endif
+#        include <algorithm>
+#    endif
 
+#    if __has_include(<sycl/sycl.hpp>)
+#        include <sycl/sycl.hpp>
+#    else
+#        include <CL/sycl.hpp>
+#    endif
 
 // Combine SYCL runtime library version
-#if defined(__LIBSYCL_MAJOR_VERSION) && defined(__LIBSYCL_MINOR_VERSION) && defined(__LIBSYCL_PATCH_VERSION)
-#    define TEST_LIBSYCL_VERSION                                                                                    \
-        (__LIBSYCL_MAJOR_VERSION * 10000 + __LIBSYCL_MINOR_VERSION * 100 + __LIBSYCL_PATCH_VERSION)
-#else
-#    define TEST_LIBSYCL_VERSION 0
-#endif
+#    if defined(__LIBSYCL_MAJOR_VERSION) && defined(__LIBSYCL_MINOR_VERSION) && defined(__LIBSYCL_PATCH_VERSION)
+#        define TEST_LIBSYCL_VERSION                                                                                   \
+            (__LIBSYCL_MAJOR_VERSION * 10000 + __LIBSYCL_MINOR_VERSION * 100 + __LIBSYCL_PATCH_VERSION)
+#    else
+#        define TEST_LIBSYCL_VERSION 0
+#    endif
 
 inline auto default_selector =
 #    if TEST_LIBSYCL_VERSION >= 60000
-        sycl::default_selector_v;
+    sycl::default_selector_v;
 #    else
-        sycl::default_selector{};
+    sycl::default_selector{};
 #    endif
 
 class canary_test_name;
 
-void
+int
 test()
 {
+    const int count = 10;
     sycl::queue q(default_selector);
+    sycl::buffer<int> buf(count);
     q.submit([&](sycl::handler& cgh) {
-        cgh.single_task<canary_test_name>([=]() {});
+        sycl::accessor acc(buf, cgh, sycl::write_only);
+        cgh.parallel_for<canary_test_name>(sycl::range</*dim=*/1>(count), [=](sycl::item</*dim=*/1> __item_id) {
+            auto __idx = __item_id.get_linear_id();
+            acc[__idx] = __idx;
+        });
     });
+    auto host_acc = buf.get_access<sycl::access::mode::read>();
+    for (int i = 0; i < count; ++i)
+    {
+        if (host_acc[i] != i)
+        {
+            std::cout << "Failed\n";
+            return 1;
+        }
+    }
+    return 0;
 }
 #endif // TEST_DPCPP_BACKEND_PRESENT
 
@@ -71,25 +85,24 @@ int
 main()
 {
 #if TEST_DPCPP_BACKEND_PRESENT
-#if _MSC_VER
-   char *pValue;
-   size_t len;
-   errno_t err = _dupenv_s( &pValue, &len, "_ONEDPL_SKIP_SYCL_CANARY_TEST" );
+#    if _MSC_VER
+    char* pValue;
+    size_t len;
+    errno_t err = _dupenv_s(&pValue, &len, "_ONEDPL_SKIP_SYCL_CANARY_TEST");
     if (err)
     {
         std::cout << "Environment variable gather failed\n";
         return 1;
-    } 
-#else // _MSC_VER
+    }
+#    else  // _MSC_VER
     const char* pValue = std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST");
-#endif // _MSC_VER
+#    endif // _MSC_VER
     bool __skip_sycl_canary_test = (pValue != nullptr);
     // This environment variable allows our main CI run to skip this test and not count it toward oneDPL's test
     // statistics, while still allowing non-ci test runs to have this as a environment health indicater.
     if (!__skip_sycl_canary_test)
     {
-        test();
-        return 0;
+        return test();
     }
 #endif // TEST_DPCPP_BACKEND_PRESENT
     std::cout << "Skipped\n";

From 19ab25c71dbd9a1018ab7f6d5c1f0889341ab713 Mon Sep 17 00:00:00 2001
From: Dan Hoeflinger <dan.hoeflinger@intel.com>
Date: Wed, 11 Sep 2024 14:33:29 -0400
Subject: [PATCH 14/14] get_host_access, naming conventions, formatting

Signed-off-by: Dan Hoeflinger <dan.hoeflinger@intel.com>
---
 test/parallel_api/sycl_canary.pass.cpp | 29 ++++++++++++++++++--------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/test/parallel_api/sycl_canary.pass.cpp b/test/parallel_api/sycl_canary.pass.cpp
index 16721cab51b..e4e5f8a933b 100644
--- a/test/parallel_api/sycl_canary.pass.cpp
+++ b/test/parallel_api/sycl_canary.pass.cpp
@@ -53,6 +53,17 @@ inline auto default_selector =
     sycl::default_selector{};
 #    endif
 
+template <typename _Buf>
+auto
+__get_host_access(_Buf&& __buf)
+{
+#    if TEST_LIBSYCL_VERSION >= 60200
+    return std::forward<_Buf>(__buf).get_host_access(sycl::read_only);
+#    else
+    return std::forward<_Buf>(__buf).template get_access<sycl::access::mode::read>();
+#    endif
+}
+
 class canary_test_name;
 
 int
@@ -63,12 +74,12 @@ test()
     sycl::buffer<int> buf(count);
     q.submit([&](sycl::handler& cgh) {
         sycl::accessor acc(buf, cgh, sycl::write_only);
-        cgh.parallel_for<canary_test_name>(sycl::range</*dim=*/1>(count), [=](sycl::item</*dim=*/1> __item_id) {
-            auto __idx = __item_id.get_linear_id();
-            acc[__idx] = __idx;
+        cgh.parallel_for<canary_test_name>(sycl::range</*dim=*/1>(count), [=](sycl::item</*dim=*/1> item_id) {
+            auto idx = item_id.get_linear_id();
+            acc[idx] = idx;
         });
     });
-    auto host_acc = buf.get_access<sycl::access::mode::read>();
+    auto host_acc = __get_host_access(buf);
     for (int i = 0; i < count; ++i)
     {
         if (host_acc[i] != i)
@@ -86,21 +97,21 @@ main()
 {
 #if TEST_DPCPP_BACKEND_PRESENT
 #    if _MSC_VER
-    char* pValue;
+    char* env_value = nullptr;
     size_t len;
-    errno_t err = _dupenv_s(&pValue, &len, "_ONEDPL_SKIP_SYCL_CANARY_TEST");
+    errno_t err = _dupenv_s(&env_value, &len, "_ONEDPL_SKIP_SYCL_CANARY_TEST");
     if (err)
     {
         std::cout << "Environment variable gather failed\n";
         return 1;
     }
 #    else  // _MSC_VER
-    const char* pValue = std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST");
+    const char* env_value = std::getenv("_ONEDPL_SKIP_SYCL_CANARY_TEST");
 #    endif // _MSC_VER
-    bool __skip_sycl_canary_test = (pValue != nullptr);
+    bool skip_sycl_canary_test = (env_value != nullptr);
     // This environment variable allows our main CI run to skip this test and not count it toward oneDPL's test
     // statistics, while still allowing non-ci test runs to have this as a environment health indicater.
-    if (!__skip_sycl_canary_test)
+    if (!skip_sycl_canary_test)
     {
         return test();
     }