Skip to content

Commit

Permalink
Add CMake option to disable SYCL [[deprecations]]
Browse files Browse the repository at this point in the history
  • Loading branch information
fknorr committed Jan 2, 2024
1 parent b08e334 commit c3e9bbb
Show file tree
Hide file tree
Showing 21 changed files with 126 additions and 99 deletions.
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,9 @@ FetchContent_MakeAvailable(nlohmann_json)

include(CheckTypeSize)
check_type_size(_Float16 FLOAT16 BUILTIN_TYPES_ONLY LANGUAGE CXX)
if (HAVE_FLOAT16)
set(SIMSYCL_FEATURE_HALF_TYPE 1)
else ()
set(SIMSYCL_FEATURE_HALF_TYPE 0)
endif()
set (SIMSYCL_FEATURE_HALF_TYPE ${HAVE_FLOAT16})

option(SIMSYCL_ANNOTATE_SYCL_DEPRECATIONS "Wether to annotate deprecated SYCL APIs with [[deprecated]]" ON)
set(SIMSYCL_ENABLE_ASAN OFF CACHE BOOL "Whether to enable address sanitizer")
set(SIMSYCL_CHECK_MODE "SIMSYCL_CHECK_ABORT" CACHE STRING "Check mode to use")

Expand Down
1 change: 1 addition & 0 deletions cmake/simsycl-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ include("${CMAKE_CURRENT_LIST_DIR}/simsycl-targets.cmake")

set(CMAKE_MODULE_PATH "${SIMSYCL_ORIGINAL_CMAKE_MODULE_PATH}")

set(SIMSYCL_ANNOTATE_SYCL_DEPRECATIONS "@SIMSYCL_ANNOTATE_SYCL_DEPRECATIONS@")
set(SIMSYCL_FEATURE_HALF_TYPE "@SIMSYCL_FEATURE_HALF_TYPE@")
set(SIMSYCL_CHECK_MODE "@SIMSYCL_CHECK_MODE@")
set(SIMSYCL_ENABLE_ASAN "@SIMSYCL_ENABLE_ASAN@")
3 changes: 2 additions & 1 deletion include/simsycl/config.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#define SIMSYCL_VERSION_MINOR @SIMSYCL_VERSION_MINOR@
#define SIMSYCL_VERSION_PATCH @SIMSYCL_VERSION_PATCH@

#define SIMSYCL_FEATURE_HALF_TYPE @SIMSYCL_FEATURE_HALF_TYPE@
#cmakedefine01 SIMSYCL_ANNOTATE_SYCL_DEPRECATIONS
#cmakedefine01 SIMSYCL_FEATURE_HALF_TYPE

#ifndef SIMSYCL_CHECK_MODE
#define SIMSYCL_CHECK_MODE @SIMSYCL_CHECK_MODE@
Expand Down
10 changes: 10 additions & 0 deletions include/simsycl/detail/preprocessor.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <simsycl/config.hh>

// it is frequently necessary to use deprecated functionality to implment deprecated functionality
// this macro is used to suppress warnings in these cases, in a cross-platform way

Expand All @@ -11,3 +13,11 @@
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#define SIMSYCL_STOP_IGNORING_DEPRECATIONS _Pragma("GCC diagnostic pop")
#endif

#if SIMSYCL_ANNOTATE_SYCL_DEPRECATIONS
#define SIMSYCL_DETAIL_DEPRECATED_IN_SYCL [[deprecated("deprecated in SYCL 2020")]]
#define SIMSYCL_DETAIL_DEPRECATED_IN_SYCL_V(message) [[deprecated("deprecated in SYCL 2020: " message)]]
#else
#define SIMSYCL_DETAIL_DEPRECATED_IN_SYCL
#define SIMSYCL_DETAIL_DEPRECATED_IN_SYCL_V(message)
#endif
25 changes: 14 additions & 11 deletions include/simsycl/sycl/accessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ class accessor : public simsycl::detail::property_interface {

size_type max_size() const noexcept { return std::numeric_limits<size_t>::max() / sizeof(DataT); }

[[deprecated]] size_t get_size() const { return byte_size(); }
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL size_t get_size() const { return byte_size(); }

[[deprecated]] size_t get_count() const { return size(); }
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL size_t get_count() const { return size(); }

bool empty() const noexcept { return m_access_range.size() == 0; }

Expand All @@ -312,7 +312,8 @@ class accessor : public simsycl::detail::property_interface {
return m_buffer[detail::get_linear_index(m_access_range, index)];
}

[[deprecated]] atomic<DataT, access::address_space::global_space> operator[](id<Dimensions> index) const
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL atomic<DataT, access::address_space::global_space> operator[](
id<Dimensions> index) const
requires(AccessMode == access_mode::atomic);

decltype(auto) operator[](size_t index) const
Expand Down Expand Up @@ -502,9 +503,9 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy

size_type max_size() const noexcept { return 1; }

[[deprecated]] size_t get_size() const { return byte_size(); }
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL size_t get_size() const { return byte_size(); }

[[deprecated]] size_t get_count() const { return size(); }
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL size_t get_count() const { return size(); }

bool empty() const noexcept { return false; }

Expand Down Expand Up @@ -534,7 +535,7 @@ class accessor<DataT, 0, AccessMode, AccessTarget, IsPlaceholder> : public simsy
return *this;
}

[[deprecated]] operator atomic<DataT, access::address_space::global_space>() const
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL operator atomic<DataT, access::address_space::global_space>() const
requires(AccessMode == access_mode::atomic);

std::add_pointer_t<value_type> get_pointer() const noexcept {
Expand Down Expand Up @@ -626,7 +627,9 @@ class local_accessor final : public simsycl::detail::property_interface {

decltype(auto) operator[](size_t index) const { return detail::subscript<Dimensions>(*this, index); }

[[deprecated]] local_ptr<DataT> get_pointer() const noexcept { return local_ptr<DataT>(get_allocation()); }
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL local_ptr<DataT> get_pointer() const noexcept {
return local_ptr<DataT>(get_allocation());
}

template<access::decorated IsDecorated>
accessor_ptr<IsDecorated> get_multi_ptr() const noexcept {
Expand Down Expand Up @@ -697,9 +700,9 @@ class local_accessor<DataT, 0> final : public simsycl::detail::property_interfac

size_type max_size() const noexcept { return 1; }

[[deprecated]] size_t get_size() const { return byte_size(); }
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL size_t get_size() const { return byte_size(); }

[[deprecated]] size_t get_count() const { return 1; }
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL size_t get_count() const { return 1; }

bool empty() const noexcept { return false; }

Expand Down Expand Up @@ -922,9 +925,9 @@ class host_accessor<DataT, 0, AccessMode> : public simsycl::detail::property_int

size_type max_size() const noexcept { return 1; }

[[deprecated]] size_t get_size() const { return byte_size(); }
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL size_t get_size() const { return byte_size(); }

[[deprecated]] size_t get_count() const { return size(); }
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL size_t get_count() const { return size(); }

bool empty() const noexcept { return false; }

Expand Down
4 changes: 2 additions & 2 deletions include/simsycl/sycl/buffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ class buffer final : public detail::reference_type<buffer<T, Dimensions, Allocat
SIMSYCL_START_IGNORING_DEPRECATIONS

template<access_mode Mode>
[[deprecated]] accessor<T, Dimensions, Mode, target::host_buffer> get_access() {
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL accessor<T, Dimensions, Mode, target::host_buffer> get_access() {
accessor<T, Dimensions, Mode, target::host_buffer>(*this);
}

template<access_mode Mode>
[[deprecated]] accessor<T, Dimensions, Mode, target::host_buffer> get_access(
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL accessor<T, Dimensions, Mode, target::host_buffer> get_access(
range<Dimensions> access_range, id<Dimensions> access_offset = {}) {
accessor<T, Dimensions, Mode, target::host_buffer>(*this, access_range, access_offset);
}
Expand Down
2 changes: 1 addition & 1 deletion include/simsycl/sycl/device.hh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class device final : public detail::reference_type<device, detail::device_state>

bool has(aspect asp) const;

[[deprecated]] bool has_extension(const std::string &extension) const;
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL bool has_extension(const std::string &extension) const;

template<info::partition_property Prop,
std::enable_if_t<Prop == info::partition_property::partition_equally, int> = 0>
Expand Down
30 changes: 19 additions & 11 deletions include/simsycl/sycl/enums.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "../detail/preprocessor.hh"

namespace simsycl::sycl {

enum class addressing_mode { mirrored_repeat, repeat, clamp_to_edge, clamp, none };
Expand All @@ -18,9 +20,9 @@ enum class access_mode {
read,
write,
read_write,
discard_write [[deprecated]],
discard_read_write [[deprecated]],
atomic [[deprecated]]
discard_write SIMSYCL_DETAIL_DEPRECATED_IN_SYCL,
discard_read_write SIMSYCL_DETAIL_DEPRECATED_IN_SYCL,
atomic SIMSYCL_DETAIL_DEPRECATED_IN_SYCL
};

enum class aspect {
Expand Down Expand Up @@ -120,25 +122,31 @@ enum class stream_manipulator {
enum class target {
device,
host_task,
constant_buffer [[deprecated]],
local [[deprecated]],
host_buffer [[deprecated]],
global_buffer [[deprecated]] = device,
constant_buffer SIMSYCL_DETAIL_DEPRECATED_IN_SYCL,
local SIMSYCL_DETAIL_DEPRECATED_IN_SYCL,
host_buffer SIMSYCL_DETAIL_DEPRECATED_IN_SYCL,
global_buffer SIMSYCL_DETAIL_DEPRECATED_IN_SYCL = device,
};

} // namespace simsycl::sycl

namespace simsycl::sycl::access {

enum class address_space { global_space, local_space, constant_space [[deprecated]], private_space, generic_space };
enum class address_space {
global_space,
local_space,
constant_space SIMSYCL_DETAIL_DEPRECATED_IN_SYCL,
private_space,
generic_space
};

enum class decorated { no, yes, legacy };

using mode [[deprecated]] = sycl::access_mode;
using mode SIMSYCL_DETAIL_DEPRECATED_IN_SYCL = sycl::access_mode;

using target [[deprecated]] = sycl::target;
using target SIMSYCL_DETAIL_DEPRECATED_IN_SYCL = sycl::target;

enum class [[deprecated]] placeholder { false_t, true_t };
enum class SIMSYCL_DETAIL_DEPRECATED_IN_SYCL placeholder { false_t, true_t };

enum class fence_space { local_space, global_space, global_and_local };

Expand Down
2 changes: 1 addition & 1 deletion include/simsycl/sycl/forward.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class atomic;
template<typename T, int Dimensions = 1, typename AllocatorT = buffer_allocator<std::remove_const_t<T>>>
class buffer;

using byte [[deprecated]] = std::uint8_t;
using byte SIMSYCL_DETAIL_DEPRECATED_IN_SYCL = std::uint8_t;

class context;

Expand Down
16 changes: 8 additions & 8 deletions include/simsycl/sycl/group.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ class group {
group() = delete;

// TODO not in the spec, remove
[[deprecated("use sycl::group::get_group_id")]] id_type get_id() const { return get_group_id(); }
[[deprecated("non-standard, use sycl::group::get_group_id")]] id_type get_id() const { return get_group_id(); }

// TODO not in the spec, remove
[[deprecated("use sycl::group::get_group_id")]] size_t get_id(int dimension) const {
[[deprecated("non-standard, use sycl::group::get_group_id")]] size_t get_id(int dimension) const {
return get_group_id(dimension);
}

id_type get_group_id() const { return m_group_item.get_id(); }

size_t get_group_id(int dimension) const { return m_group_item.get_id()[dimension]; }

[[deprecated("deprecated in SYCL2020")]] range<Dimensions> get_global_range() const {
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL range<Dimensions> get_global_range() const {
SIMSYCL_CHECK(
!m_hierarchical && "get_global_range is not supported for from within a parallel_for_work_item context");
return m_global_item.get_range();
Expand Down Expand Up @@ -137,7 +137,7 @@ class group {

size_t operator[](int dimension) const { return m_group_item.get_id()[dimension]; }

[[deprecated("use sycl::group::get_group_linear_id")]] size_t get_linear_id() const {
[[deprecated("non-standard, use sycl::group::get_group_linear_id")]] size_t get_linear_id() const {
return get_group_linear_id();
}

Expand Down Expand Up @@ -225,25 +225,25 @@ class group {
}

template<typename DataT>
[[deprecated]] device_event async_work_group_copy(
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL device_event async_work_group_copy(
local_ptr<DataT> dest, global_ptr<DataT> src, size_t num_elements) const {
std::copy_n(src.get(), num_elements, dest.get());
}

template<typename DataT>
[[deprecated]] device_event async_work_group_copy(
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL device_event async_work_group_copy(
global_ptr<DataT> dest, local_ptr<DataT> src, size_t num_elements) const {
std::copy_n(src.get(), num_elements, dest.get());
}

template<typename DataT>
[[deprecated]] device_event async_work_group_copy(
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL device_event async_work_group_copy(
local_ptr<DataT> dest, global_ptr<DataT> src, size_t num_elements, size_t src_stride) const {
for(size_t i = 0; i < num_elements; ++i) { dest[i] = src[i * src_stride]; }
}

template<typename DataT>
[[deprecated]] device_event async_work_group_copy(
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL device_event async_work_group_copy(
global_ptr<DataT> dest, local_ptr<DataT> src, size_t num_elements, size_t dest_stride) const {
for(size_t i = 0; i < num_elements; ++i) { dest[i * dest_stride] = src[i]; }
}
Expand Down
2 changes: 1 addition & 1 deletion include/simsycl/sycl/handler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class handler {
}

template<typename KernelName = simsycl::detail::unnamed_kernel, typename KernelType, int Dimensions>
[[deprecated("Deprecated in SYCL 2020")]] void parallel_for(
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL void parallel_for(
range<Dimensions> num_work_items, id<Dimensions> work_item_offset, KernelType &&kernel_func) {
simsycl::detail::parallel_for(num_work_items, work_item_offset, kernel_func);
}
Expand Down
18 changes: 9 additions & 9 deletions include/simsycl/sycl/info.hh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct native_vector_width_half : detail::info_descriptor<uint32_t> {};
struct max_clock_frequency : detail::info_descriptor<uint32_t> {};
struct address_bits : detail::info_descriptor<uint32_t> {};
struct max_mem_alloc_size : detail::info_descriptor<uint64_t> {};
struct [[deprecated]] image_support : detail::info_descriptor<bool> {};
struct SIMSYCL_DETAIL_DEPRECATED_IN_SYCL image_support : detail::info_descriptor<bool> {};
struct max_read_image_args : detail::info_descriptor<uint32_t> {};
struct max_write_image_args : detail::info_descriptor<uint32_t> {};
struct image2d_max_height : detail::info_descriptor<size_t> {};
Expand All @@ -118,8 +118,8 @@ struct global_mem_cache_type : detail::info_descriptor<info::global_mem_cache_ty
struct global_mem_cache_line_size : detail::info_descriptor<uint32_t> {};
struct global_mem_cache_size : detail::info_descriptor<uint64_t> {};
struct global_mem_size : detail::info_descriptor<uint64_t> {};
struct [[deprecated]] max_constant_buffer_size : detail::info_descriptor<uint64_t> {};
struct [[deprecated]] max_constant_args : detail::info_descriptor<uint32_t> {};
struct SIMSYCL_DETAIL_DEPRECATED_IN_SYCL max_constant_buffer_size : detail::info_descriptor<uint64_t> {};
struct SIMSYCL_DETAIL_DEPRECATED_IN_SYCL max_constant_args : detail::info_descriptor<uint32_t> {};
struct local_mem_type : detail::info_descriptor<info::local_mem_type> {};
struct local_mem_size : detail::info_descriptor<uint64_t> {};
struct error_correction_support : detail::info_descriptor<bool> {};
Expand All @@ -131,11 +131,11 @@ struct atomic_fence_scope_capabilities : detail::info_descriptor<std::vector<syc
struct profiling_timer_resolution : detail::info_descriptor<size_t> {};
struct is_endian_little : detail::info_descriptor<bool> {};
struct is_available : detail::info_descriptor<bool> {};
struct [[deprecated]] is_compiler_available : detail::info_descriptor<bool> {};
struct [[deprecated]] is_linker_available : detail::info_descriptor<bool> {};
struct SIMSYCL_DETAIL_DEPRECATED_IN_SYCL is_compiler_available : detail::info_descriptor<bool> {};
struct SIMSYCL_DETAIL_DEPRECATED_IN_SYCL is_linker_available : detail::info_descriptor<bool> {};
struct execution_capabilities : detail::info_descriptor<std::vector<info::execution_capability>> {};
struct [[deprecated]] queue_profiling : detail::info_descriptor<bool> {};
struct [[deprecated]] built_in_kernels : detail::info_descriptor<std::vector<std::string>> {};
struct SIMSYCL_DETAIL_DEPRECATED_IN_SYCL queue_profiling : detail::info_descriptor<bool> {};
struct SIMSYCL_DETAIL_DEPRECATED_IN_SYCL built_in_kernels : detail::info_descriptor<std::vector<std::string>> {};
struct built_in_kernel_ids : detail::info_descriptor<std::vector<sycl::kernel_id>> {};
struct platform : detail::info_descriptor<sycl::platform> {};
struct name : detail::info_descriptor<std::string> {};
Expand All @@ -145,7 +145,7 @@ struct profile : detail::info_descriptor<std::string> {};
struct version : detail::info_descriptor<std::string> {};
struct backend_version : detail::info_descriptor<std::string> {};
struct aspects : detail::info_descriptor<std::vector<sycl::aspect>> {};
struct [[deprecated]] extensions : detail::info_descriptor<std::vector<std::string>> {};
struct SIMSYCL_DETAIL_DEPRECATED_IN_SYCL extensions : detail::info_descriptor<std::vector<std::string>> {};
struct printf_buffer_size : detail::info_descriptor<size_t> {};
struct preferred_interop_user_sync : detail::info_descriptor<bool> {};
struct parent_device : detail::info_descriptor<sycl::device> {};
Expand Down Expand Up @@ -200,7 +200,7 @@ struct profile : detail::info_descriptor<std::string> {};
struct version : detail::info_descriptor<std::string> {};
struct name : detail::info_descriptor<std::string> {};
struct vendor : detail::info_descriptor<std::string> {};
struct [[deprecated]] extensions : detail::info_descriptor<std::vector<std::string>> {};
struct SIMSYCL_DETAIL_DEPRECATED_IN_SYCL extensions : detail::info_descriptor<std::vector<std::string>> {};

} // namespace simsycl::sycl::info::platform

Expand Down
2 changes: 1 addition & 1 deletion include/simsycl/sycl/item.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class item {

size_t get_range(int dimension) const { return m_range[dimension]; }

[[deprecated("Deprecated in SYCL 2020")]] id<Dimensions> get_offset() const
SIMSYCL_DETAIL_DEPRECATED_IN_SYCL id<Dimensions> get_offset() const
requires WithOffset
{
return m_offset;
Expand Down
Loading

0 comments on commit c3e9bbb

Please sign in to comment.