Skip to content
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
4 changes: 4 additions & 0 deletions sycl/doc/syclcompat/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
**⚠️ DEPRECATION NOTICE ⚠️**

**SYCLcompat is deprecated and will be removed in a future release. Users are encouraged to migrate to native SYCL APIs or alternative compatibility solutions. The `syclcompat` namespace has been marked with `[[deprecated]]` attribute.**

# SYCLcompat

SYCLcompat is a header-only library that intends to help developers familiar
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#include <syclcompat/traits.hpp>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {

/// Atomically add the value operand to the value at the addr and assign the
/// result to the value at addr.
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/defs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ template <int Arg> class syclcompat_kernel_scalar;
SYCLCOMPAT_MAKE_VERSION(SYCLCOMPAT_MAJOR_VERSION, SYCLCOMPAT_MINOR_VERSION, \
SYCLCOMPAT_PATCH_VERSION)

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {
enum error_code { success = 0, backend_error = 1, default_error = 999 };
/// A dummy function introduced to assist auto migration.
/// The SYCLomatic user should replace it with a real error-handling function.
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include <sycl/properties/queue_properties.hpp>
#include <sycl/queue.hpp>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {

namespace detail {
static void parse_version_string(const std::string &ver, int &major,
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/dims.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <sycl/range.hpp>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {

class dim3 {
public:
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/group_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <syclcompat/defs.hpp>
#include <syclcompat/math.hpp>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {
namespace group {
namespace detail {

Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/id_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <sycl/ext/oneapi/free_function_queries.hpp>
#include <sycl/nd_item.hpp>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {

using sycl::ext::oneapi::this_work_item::get_nd_item;

Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include <sycl/nd_range.hpp>
#include <sycl/queue.hpp>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {

typedef void (*kernel_functor)(sycl::queue &, const sycl::nd_range<3> &,
unsigned int, void **, void **);
Expand Down
10 changes: 5 additions & 5 deletions sycl/include/syclcompat/launch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <syclcompat/dims.hpp>
#include <syclcompat/launch_policy.hpp>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {

namespace detail {

Expand Down Expand Up @@ -120,8 +120,8 @@ launch(const dim3 &grid, const dim3 &threads, Args... args) {

} // namespace syclcompat

namespace syclcompat::experimental {

namespace [[deprecated("syclcompat is deprecated")]] syclcompat {
namespace experimental {
namespace detail {

template <auto F, typename LaunchPolicy, typename... Args>
Expand All @@ -145,7 +145,6 @@ sycl::event launch(LaunchPolicy launch_policy, sycl::queue q, Args... args) {
}
});
}

}


Expand All @@ -161,4 +160,5 @@ sycl::event launch(LaunchPolicy launch_policy, Args... args) {
return launch<F>(launch_policy, get_default_queue(), args...);
}

} // namespace syclcompat::experimental
} // namespace experimental
} // namespace syclcompat
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/launch_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <syclcompat/dims.hpp>
#include <syclcompat/traits.hpp>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {
namespace experimental {

namespace sycl_exp = sycl::ext::oneapi::experimental;
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include <sycl/ext/oneapi/experimental/complex/complex.hpp>
#include <syclcompat/traits.hpp>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {
namespace detail {

namespace complex_namespace = sycl::ext::oneapi::experimental;
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#error "Only support Windows and Linux."
#endif

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {

template <typename AllocT>
#ifdef __SYCL_DEVICE_ONLY__
Expand Down
18 changes: 18 additions & 0 deletions sycl/include/syclcompat/syclcompat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@

#pragma once

// MSVC ignores [[deprecated]] attribute on namespace unless compiled with
// /W3 or above.
#ifdef _MSC_VER
#define __SYCLCOMPAT_STRINGIFY(x) #x
#define __SYCLCOMPAT_TOSTRING(x) __SYCLCOMPAT_STRINGIFY(x)

#define __SYCLCOMPAT_WARNING(msg) \
__pragma(message(__FILE__ \
"(" __SYCLCOMPAT_TOSTRING(__LINE__) "): warning: " msg))

__SYCLCOMPAT_WARNING("syclcompat is deprecated and the deprecation warnings "
"are ignored unless compiled with /W3 or above.")

#undef __SYCLCOMPAT_WARNING
#undef __SYCLCOMPAT_TOSTRING
#undef __SYCLCOMPAT_STRINGIFY
#endif
Comment on lines +25 to +41
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that this isn't of much help as SYCL headers are treated as system headers and warnings are suppressed from them. Another option is to use #warning instead of pragma but not all MSVC versions support #warning, as it's a C++23 feature.
@aelovikov-intel suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how that's an issue: https://godbolt.org/z/YG75Kx5rE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this Godbolt accurately describes our compilation toolchain. I was debugging the failure in the new test I added (sycl/test/syclcompat/warnings_deprecated_msvc.cpp) and that when I found that no warning is being thrown for MSVC. Instead of including the header via -fsycl, if I explicitly include the header -I, then the warning is thrown properly (so the problem isn't with macros).
I also saw that we faced the same problem in #6808 as well.
In clang driver, do you know if we explicitly suppress warnings from system headers somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What warning? On the namespace syclcompat? pragma message isn't a warning, just a message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline. The problem was with clang-cl's imitation of MSVC's option. See https://godbolt.org/z/96aG1K1G8 - clang-cl's interpretation of /external:W0 is different from that of MSVC and the clang-cl also disables pragma messages with /external:W0.
Also, clang-cl, unlike MSVC, do not ignore [[deprecated]] attribute and so, I've modified warnings_deprecated.cpp test to also run on windows.


#include <syclcompat/atomic.hpp>
#include <syclcompat/defs.hpp>
#include <syclcompat/device.hpp>
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <sycl/nd_range.hpp>
#include <type_traits>

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {

// Equivalent to C++20's std::type_identity (used to create non-deduced
// contexts)
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/syclcompat/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ __SYCL_CONVERGENT__ extern SYCL_EXTERNAL __SYCL_EXPORT
__spirv_GroupNonUniformShuffleUp(__spv::Scope::Flag, T, unsigned) noexcept;
#endif

namespace syclcompat {
namespace [[deprecated("syclcompat is deprecated")]] syclcompat {

namespace detail {

Expand Down
50 changes: 50 additions & 0 deletions sycl/test/syclcompat/warnings_deprecated.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Test to verify that syclcompat namespace and APIs generate deprecation
// warnings.

// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,warning %s -Wall -Wextra

#include <syclcompat/syclcompat.hpp>

int main() {
// Test deprecated namespace
// expected-warning@+1{{'syclcompat' is deprecated}}
syclcompat::dim3 grid(1, 1, 1);

// expected-warning@+1{{'syclcompat' is deprecated}}
auto queue = syclcompat::get_default_queue();

// Test deprecated memory APIs
// expected-warning@+1{{'syclcompat' is deprecated}}
void *ptr = syclcompat::malloc(1024);

// expected-warning@+1{{'syclcompat' is deprecated}}
syclcompat::free(ptr);

// Test deprecated utility APIs
// expected-warning@+1{{'syclcompat' is deprecated}}
auto device_count = syclcompat::device_count();

// expected-warning@+1{{'syclcompat' is deprecated}}
syclcompat::wait();

// Test deprecated atomic APIs
int value = 42;
int operand = 10;
// expected-warning@+1{{'syclcompat' is deprecated}}
syclcompat::atomic_fetch_add(&value, operand);

// Test deprecated math APIs
// expected-warning@+1{{'syclcompat' is deprecated}}
auto result = syclcompat::max(1, 2);

// Test deprecated device APIs
// expected-warning@+1{{'syclcompat' is deprecated}}
syclcompat::device_info info;

// Test deprecated experimental APIs
// expected-warning@+1{{'syclcompat' is deprecated}}
syclcompat::experimental::launch_policy my_config(
sycl::nd_range<1>{{32}, {32}});

return 0;
}
Loading