Skip to content
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

[SYCLomatic] return device_pointer from data() #1861

Merged
Changes from 4 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
18 changes: 9 additions & 9 deletions clang/runtime/dpct-rt/include/dpct/dpl_extras/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ class device_vector {
using reference = device_reference<T>;
using const_reference = const reference;
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using pointer = device_pointer<T>;
using const_pointer = const device_pointer<T>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should const_pointer be defined as device_pointer<const T>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Fixed, thanks!

using difference_type =
typename ::std::iterator_traits<iterator>::difference_type;
using size_type = ::std::size_t;
Expand All @@ -171,7 +171,7 @@ class device_vector {
Allocator _alloc;
size_type _size;
size_type _capacity;
pointer _storage;
T *_storage;

size_type _min_capacity() const { return size_type(1); }

Expand Down Expand Up @@ -462,8 +462,8 @@ class device_vector {
reference front() { return *begin(); }
const_reference back(void) const { return *(end() - 1); }
reference back(void) { return *(end() - 1); }
pointer data(void) { return _storage; }
const_pointer data(void) const { return _storage; }
pointer data(void) { return pointer(_storage); }
const_pointer data(void) const { return const_pointer(_storage); }
void shrink_to_fit(void) {
if (_size != capacity() && capacity() > _min_capacity()) {
size_type tmp_capacity = ::std::max(_size, _min_capacity());
Expand Down Expand Up @@ -622,8 +622,8 @@ class device_vector {
using reference = device_reference<T>;
using const_reference = const reference;
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using pointer = device_pointer<T>;
using const_pointer = const device_pointer<T>;
using difference_type =
typename std::iterator_traits<iterator>::difference_type;
using size_type = std::size_t;
Expand Down Expand Up @@ -850,9 +850,9 @@ class device_vector {
reference front() { return *begin(); }
const_reference back(void) const { return *(end() - 1); }
reference back(void) { return *(end() - 1); }
pointer data(void) { return reinterpret_cast<pointer>(_storage); }
pointer data(void) { return pointer(reinterpret_cast<T *>(_storage)); }
const_pointer data(void) const {
return reinterpret_cast<const_pointer>(_storage);
return const_pointer(reinterpret_cast<T *>(_storage));
}
void shrink_to_fit(void) {
if (_size != capacity()) {
Expand Down
Loading