Skip to content

Commit

Permalink
[SYCLomatic] return device_pointer from device_vector::data() (#1861)
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Hoeflinger <[email protected]>
  • Loading branch information
danhoeflinger authored Apr 23, 2024
1 parent d0c9afe commit 7a56e37
Showing 1 changed file with 9 additions and 9 deletions.
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 = device_pointer<const T>;
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 @@ -466,8 +466,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 @@ -626,8 +626,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 = device_pointer<const T>;
using difference_type =
typename std::iterator_traits<iterator>::difference_type;
using size_type = std::size_t;
Expand Down Expand Up @@ -860,9 +860,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<const T *>(_storage));
}
void shrink_to_fit(void) {
if (_size != capacity()) {
Expand Down

0 comments on commit 7a56e37

Please sign in to comment.