Skip to content

Commit

Permalink
buffer::set_final_data accepts weak_ptr<T>, not weak_ptr<T[]> or shar…
Browse files Browse the repository at this point in the history
…ed_ptr<T[]>
  • Loading branch information
fknorr committed Dec 26, 2024
1 parent f1e6fd0 commit b9520a5
Showing 1 changed file with 8 additions and 11 deletions.
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

0 comments on commit b9520a5

Please sign in to comment.