Skip to content

[SYCL] Add a nice error message to sycl::buffer to std::string #4973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from Nov 22, 2021
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
8 changes: 4 additions & 4 deletions sycl/include/CL/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <CL/sycl/exception.hpp>
#include <CL/sycl/property_list.hpp>
#include <CL/sycl/stl.hpp>
#include <CL/sycl/types.hpp>
#include <sycl/ext/oneapi/accessor_property_list.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
Expand Down Expand Up @@ -45,9 +44,10 @@ template <typename T, int dimensions = 1,
typename __Enabled = typename detail::enable_if_t<(dimensions > 0) &&
(dimensions <= 3)>>
class buffer {
static_assert(
is_device_copyable<T>::value,
"The underlying data type of a buffer 'T' must be device copyable");
// TODO check is_device_copyable<T>::value after converting sycl::vec into a
// trivially copyable class.
static_assert(!std::is_same<T, std::string>::value,
"'std::string' is not a device copyable type");

public:
using value_type = T;
Expand Down
7 changes: 0 additions & 7 deletions sycl/include/CL/sycl/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2420,13 +2420,6 @@ struct is_device_copyable<sycl::marray<T, N>,
std::enable_if_t<is_device_copyable<T>::value>>
: std::true_type {};

// vec is device copyable on host, on device vec is trivially copyable
// and therefore is device copyable too.
#ifndef __SYCL_DEVICE_ONLY__
template <typename T, int N>
struct is_device_copyable<sycl::vec<T, N>> : std::true_type {};
#endif

namespace detail {
template <typename T, typename = void>
struct IsDeprecatedDeviceCopyable : std::false_type {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ int main() {
static_assert(!is_device_copyable_v<std::string>);
std::vector<std::string> sv{"hello", "sycl", "world"};
buffer b2(sv.data(), range<1>(3));
//expected-error@CL/sycl/buffer.hpp:* {{"The underlying data type of a buffer 'T' must be device copyable"}}
//expected-error@CL/sycl/buffer.hpp:* {{"'std::string' is not a device copyable type"}}

static_assert(is_device_copyable<sycl::vec<int, 4>>::value);
vec<int, 4> iVec;
buffer b3(&iVec, range<1>(1));
return 0;
}