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

buffer::set_final_data accepts weak_ptr<T>, not <T[]> #1011

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
19 changes: 8 additions & 11 deletions tests/buffer/buffer_storage_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,19 @@ class buffer_storage_test {

// Case 3 - Weak pointer
std::shared_ptr<T[]> data_shared_ptr(new T[size]);
std::weak_ptr<T[]> data_final3 = data_shared_ptr;
std::shared_ptr<T> data_shared_ptr_alias(data_shared_ptr,
data_shared_ptr.get());
std::weak_ptr<T> data_final3 = data_shared_ptr_alias;

// Case 4 - Shared pointer
std::shared_ptr<T[]> data_final4(new T[size]);

// Case 5 - Vector data
// Case 4 - Vector iterator
std::vector<T> data_vector;
data_vector.resize(size);
auto data_final5 = data_vector.begin();
auto data_final4 = data_vector.begin();

check_write_back(log, r, data_final1.get());
check_write_back(log, r, data_final2, true /*is_nullptr*/);
check_write_back(log, r, data_final3);
check_write_back(log, r, data_final4);
check_write_back(log, r, data_final5);
}

private:
Expand All @@ -99,12 +97,11 @@ class buffer_storage_test {
}
}

template <template <typename T1> class C>
void check_write_back(util::logger &log, sycl::range<dims> r,
C<T[]> final_data) {
void check_write_back(util::logger& log, sycl::range<dims> r,
std::weak_ptr<T> final_data) {
use_buffer(final_data, r);

std::shared_ptr<T[]> ptr_shrd(final_data);
auto ptr_shrd = final_data.lock();
T *ptr = ptr_shrd.get();
for (size_t i = 0; i < size; ++i) {
check_equal_values(ptr[i], (T)0xFF);
Expand Down