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

Fixes universal_vector test failure on CTK 11.1 & gcc-6 #209

Merged
merged 1 commit into from
Jul 12, 2023
Merged
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
40 changes: 27 additions & 13 deletions thrust/testing/cuda/device_side_universal_vector.cu
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
template <class VecT>
__host__ __device__ void universal_vector_access(VecT &in, thrust::universal_vector<bool> &out)
{
const int expected_front = 4;
const int expected_back = 2;
const int expected_front = 4;
const int expected_back = 2;

out[0] = in.size() == 2 && //
in[0] == expected_front && //
Expand Down Expand Up @@ -43,15 +43,23 @@ void test_universal_vector_access(VecT &vec, thrust::universal_vector<bool> &out

void TestUniversalVectorDeviceAccess()
{
thrust::universal_vector<thrust::universal_vector<int>> in_storage(1);
thrust::universal_vector<int> &in = *thrust::raw_pointer_cast(in_storage.data());
using in_vector_t = thrust::universal_vector<int>;
using out_vector_t = thrust::universal_vector<bool>;

in_vector_t *in_ptr{};
cudaMallocManaged(&in_ptr, sizeof(*in_ptr));
new (in_ptr) in_vector_t(1);

auto &in = *in_ptr;
in.resize(2);
in[0] = 4;
in[1] = 2;

thrust::universal_vector<thrust::universal_vector<bool>> out_storage(1);
thrust::universal_vector<bool> &out = *thrust::raw_pointer_cast(out_storage.data());
out_vector_t *out_ptr{};
cudaMallocManaged(&out_ptr, sizeof(*out_ptr));
new (out_ptr) out_vector_t(1);
auto &out = *out_ptr;

out.resize(1);
out[0] = false;

Expand All @@ -61,24 +69,30 @@ DECLARE_UNITTEST(TestUniversalVectorDeviceAccess);

void TestConstUniversalVectorDeviceAccess()
{
thrust::universal_vector<thrust::universal_vector<int>> in_storage(1);
using in_vector_t = thrust::universal_vector<int>;
using out_vector_t = thrust::universal_vector<bool>;

{
thrust::universal_vector<int> &in = *thrust::raw_pointer_cast(in_storage.data());
in_vector_t *in_ptr{};
cudaMallocManaged(&in_ptr, sizeof(*in_ptr));
new (in_ptr) in_vector_t(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just realized there's no corresponding cudaFree.


{
auto &in = *in_ptr;
in.resize(2);
in[0] = 4;
in[1] = 2;
}

const thrust::universal_vector<int> &in = *thrust::raw_pointer_cast(in_storage.data());
const auto &const_in = *in_ptr;

thrust::universal_vector<thrust::universal_vector<bool>> out_storage(1);
thrust::universal_vector<bool> &out = *thrust::raw_pointer_cast(out_storage.data());
out_vector_t *out_ptr{};
cudaMallocManaged(&out_ptr, sizeof(*out_ptr));
new (out_ptr) out_vector_t(1);
auto &out = *out_ptr;

out.resize(1);
out[0] = false;

test_universal_vector_access(in, out);
test_universal_vector_access(const_in, out);
}
DECLARE_UNITTEST(TestConstUniversalVectorDeviceAccess);
Loading