diff --git a/sycl/include/CL/sycl/buffer.hpp b/sycl/include/CL/sycl/buffer.hpp index 7cf5a0e2be62e..240c332c910b4 100755 --- a/sycl/include/CL/sycl/buffer.hpp +++ b/sycl/include/CL/sycl/buffer.hpp @@ -263,7 +263,10 @@ class buffer { size_t get_count() const { return size(); } size_t size() const noexcept { return Range.size(); } - size_t get_size() const { return size() * sizeof(T); } + __SYCL2020_DEPRECATED( + "get_size() is deprecated, please use byte_size() instead") + size_t get_size() const { return byte_size(); } + size_t byte_size() const noexcept { return size() * sizeof(T); } AllocatorT get_allocator() const { return impl->template get_allocator(); @@ -343,7 +346,7 @@ class buffer { template buffer reinterpret(range reinterpretRange) const { - if (sizeof(ReinterpretT) * reinterpretRange.size() != get_size()) + if (sizeof(ReinterpretT) * reinterpretRange.size() != byte_size()) throw cl::sycl::invalid_object_error( "Total size in bytes represented by the type and range of the " "reinterpreted SYCL buffer does not equal the total size in bytes " @@ -369,7 +372,7 @@ class buffer { (sizeof(ReinterpretT) != sizeof(T))), buffer>::type reinterpret() const { - long sz = get_size(); // TODO: switch to byte_size() once implemented + long sz = byte_size(); if (sz % sizeof(ReinterpretT) != 0) throw cl::sycl::invalid_object_error( "Total byte size of buffer is not evenly divisible by the size of " diff --git a/sycl/include/CL/sycl/types.hpp b/sycl/include/CL/sycl/types.hpp index 602b54a1bcca0..3387c3cc0407b 100644 --- a/sycl/include/CL/sycl/types.hpp +++ b/sycl/include/CL/sycl/types.hpp @@ -805,7 +805,10 @@ template class vec { __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") static constexpr size_t get_count() { return size(); } static constexpr size_t size() noexcept { return NumElements; } - static constexpr size_t get_size() { return sizeof(m_Data); } + __SYCL2020_DEPRECATED( + "get_size() is deprecated, please use byte_size() instead") + static constexpr size_t get_size() { return byte_size(); } + static constexpr size_t byte_size() { return sizeof(m_Data); } template @@ -1400,7 +1403,15 @@ class SwizzleOp { __SYCL2020_DEPRECATED("get_count() is deprecated, please use size() instead") size_t get_count() const { return size(); } size_t size() const noexcept { return getNumElements(); } - template size_t get_size() const { + + template + __SYCL2020_DEPRECATED( + "get_size() is deprecated, please use byte_size() instead") + size_t get_size() const { + return byte_size(); + } + + template size_t byte_size() const noexcept { return sizeof(DataT) * (Num == 3 ? 4 : Num); } diff --git a/sycl/test/warnings/sycl_2020_deprecations.cpp b/sycl/test/warnings/sycl_2020_deprecations.cpp index 218f2ac5e0591..d99b34eff1880 100644 --- a/sycl/test/warnings/sycl_2020_deprecations.cpp +++ b/sycl/test/warnings/sycl_2020_deprecations.cpp @@ -69,6 +69,14 @@ int main() { // expected-warning@+1{{'get_count' is deprecated: get_count() is deprecated, please use size() instead}} size_t BufferGetCount = Buffer.get_count(); size_t BufferSize = Buffer.size(); + // expected-warning@+1 {{'get_size' is deprecated: get_size() is deprecated, please use byte_size() instead}} + size_t BufferGetSize = Buffer.get_size(); + + sycl::vec Vec(1, 2); + // expected-warning@+1{{'get_count' is deprecated: get_count() is deprecated, please use size() instead}} + size_t VecGetCount = Vec.get_count(); + // expected-warning@+1 {{'get_size' is deprecated: get_size() is deprecated, please use byte_size() instead}} + size_t VecGetSize = Vec.get_size(); // expected-warning@+1 {{'runtime_error' is deprecated: use sycl::exception with sycl::errc::runtime instead.}} sycl::runtime_error re;