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

make uninitialized[_async]_buffer's range accessors const-correct #3615

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
everything in its right place
ericniebler committed Jan 30, 2025
commit 56fa95a973036117d42b5ea8cb1915fdb7a06736
18 changes: 6 additions & 12 deletions cudax/test/containers/uninitialized_async_buffer.cu
Original file line number Diff line number Diff line change
@@ -58,18 +58,6 @@ TEMPLATE_TEST_CASE(
cuda::experimental::device_memory_resource resource{};
cuda::experimental::stream stream{};

if (false)
{
uninitialized_async_buffer buf{resource, stream, 42};
uninitialized_async_buffer const& cbuf = buf;
static_assert(cuda::std::is_same<decltype(buf.begin()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(cbuf.begin()), TestType const*>::value, "");
static_assert(cuda::std::is_same<decltype(buf.end()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(cbuf.end()), TestType const*>::value, "");
static_assert(cuda::std::is_same<decltype(buf.data()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(cbuf.data()), TestType const*>::value, "");
}

SECTION("construction")
{
{
@@ -149,6 +137,9 @@ TEMPLATE_TEST_CASE(
SECTION("access")
{
uninitialized_async_buffer buf{resource, stream, 42};
static_assert(cuda::std::is_same<decltype(buf.begin()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(buf.end()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(buf.data()), TestType*>::value, "");
CUDAX_CHECK(buf.data() != nullptr);
CUDAX_CHECK(buf.size() == 42);
CUDAX_CHECK(buf.size_bytes() == 42 * sizeof(TestType));
@@ -157,6 +148,9 @@ TEMPLATE_TEST_CASE(
CUDAX_CHECK(buf.get_stream() == stream);
CUDAX_CHECK(buf.get_memory_resource() == resource);

static_assert(cuda::std::is_same<decltype(cuda::std::as_const(buf).begin()), TestType const*>::value, "");
static_assert(cuda::std::is_same<decltype(cuda::std::as_const(buf).end()), TestType const*>::value, "");
static_assert(cuda::std::is_same<decltype(cuda::std::as_const(buf).data()), TestType const*>::value, "");
CUDAX_CHECK(cuda::std::as_const(buf).data() != nullptr);
CUDAX_CHECK(cuda::std::as_const(buf).size() == 42);
CUDAX_CHECK(cuda::std::as_const(buf).size_bytes() == 42 * sizeof(TestType));
18 changes: 6 additions & 12 deletions cudax/test/containers/uninitialized_buffer.cu
Original file line number Diff line number Diff line change
@@ -83,18 +83,6 @@ TEMPLATE_TEST_CASE(

cudax::device_memory_resource resource{};

if (false)
{
uninitialized_buffer buf{resource, 42};
uninitialized_buffer const& cbuf = buf;
static_assert(cuda::std::is_same<decltype(buf.begin()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(cbuf.begin()), TestType const*>::value, "");
static_assert(cuda::std::is_same<decltype(buf.end()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(cbuf.end()), TestType const*>::value, "");
static_assert(cuda::std::is_same<decltype(buf.data()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(cbuf.data()), TestType const*>::value, "");
}

SECTION("construction")
{
static_assert(!cuda::std::is_copy_constructible<uninitialized_buffer>::value, "");
@@ -167,13 +155,19 @@ TEMPLATE_TEST_CASE(
SECTION("access")
{
uninitialized_buffer buf{resource, 42};
static_assert(cuda::std::is_same<decltype(buf.begin()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(buf.end()), TestType*>::value, "");
static_assert(cuda::std::is_same<decltype(buf.data()), TestType*>::value, "");
CUDAX_CHECK(buf.data() != nullptr);
CUDAX_CHECK(buf.size() == 42);
CUDAX_CHECK(buf.size_bytes() == 42 * sizeof(TestType));
CUDAX_CHECK(buf.begin() == buf.data());
CUDAX_CHECK(buf.end() == buf.begin() + buf.size());
CUDAX_CHECK(buf.get_memory_resource() == resource);

static_assert(cuda::std::is_same<decltype(cuda::std::as_const(buf).begin()), TestType const*>::value, "");
static_assert(cuda::std::is_same<decltype(cuda::std::as_const(buf).end()), TestType const*>::value, "");
static_assert(cuda::std::is_same<decltype(cuda::std::as_const(buf).data()), TestType const*>::value, "");
CUDAX_CHECK(cuda::std::as_const(buf).data() != nullptr);
CUDAX_CHECK(cuda::std::as_const(buf).size() == 42);
CUDAX_CHECK(cuda::std::as_const(buf).begin() == buf.data());