Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Make memory_resource and stream_ref experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Feb 15, 2023
1 parent b809e67 commit d0a55c5
Show file tree
Hide file tree
Showing 30 changed files with 121 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
// UNSUPPORTED: c++03, c++11

// cuda::forward_property

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/std/cassert>
#include <cuda/memory_resource>

namespace has_upstream_resource {
namespace has_upstream_resource {
struct Upstream{};

__device__ Upstream upstream{};
Expand Down Expand Up @@ -53,7 +56,7 @@ namespace forward_property {
struct prop {};

template<class Upstream>
struct derived_plain : public cuda::forward_property<derived_plain<Upstream>, Upstream>
struct derived_plain : public cuda::forward_property<derived_plain<Upstream>, Upstream>
{
constexpr Upstream upstream_resource() const noexcept { return Upstream{}; }
};
Expand Down Expand Up @@ -81,10 +84,10 @@ namespace forward_property {
static_assert( cuda::has_property<derived_plain<upstream_with_both_properties>, prop>, "");
static_assert( cuda::has_property<derived_plain<upstream_with_both_properties>, prop_with_value>, "");

struct derived_override : public cuda::forward_property<derived_override, upstream_with_both_properties>
struct derived_override : public cuda::forward_property<derived_override, upstream_with_both_properties>
{
constexpr upstream_with_both_properties upstream_resource() const noexcept {
return upstream_with_both_properties{};
constexpr upstream_with_both_properties upstream_resource() const noexcept {
return upstream_with_both_properties{};
}
// Get called directly so needs to be annotated
__host__ __device__ friend constexpr int get_property(const derived_override&, prop_with_value) {
Expand All @@ -98,10 +101,10 @@ namespace forward_property {
}
};

struct derived_with_converstin_upstream_resource : public cuda::forward_property<derived_with_converstin_upstream_resource, upstream_with_both_properties>
struct derived_with_converstin_upstream_resource : public cuda::forward_property<derived_with_converstin_upstream_resource, upstream_with_both_properties>
{
constexpr convertible_to_upstream upstream_resource() const noexcept {
return convertible_to_upstream{};
constexpr convertible_to_upstream upstream_resource() const noexcept {
return convertible_to_upstream{};
}
};
static_assert(!cuda::has_property<derived_with_converstin_upstream_resource, prop_with_value>);
Expand All @@ -110,7 +113,7 @@ namespace forward_property {
using derived_no_override = derived_plain<upstream_with_stateful_property>;
const derived_no_override without_override{};
assert(get_property(without_override, prop_with_value{}) == 42);

const derived_override with_override{};
assert(get_property(with_override, prop_with_value{}) == 1337);

Expand All @@ -122,5 +125,5 @@ namespace forward_property {
int main(int, char**) {
forward_property::test_stateful();
static_assert(forward_property::test_stateful(), "");
return 0;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::get_property

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/std/cassert>
#include <cuda/memory_resource>

Expand Down Expand Up @@ -44,10 +47,10 @@ static_assert( cuda::std::invocable<decltype(cuda::get_property), upstream_with_
__host__ __device__ constexpr bool test() {
upstream_with_valueless_property with_valueless{};
cuda::get_property(with_valueless, prop{});

upstream_with_stateful_property with_value{};
assert(cuda::get_property(with_value, prop_with_value{}) == 42);

upstream_with_both_properties with_both{};
cuda::get_property(with_both, prop{});
assert(cuda::get_property(with_both, prop_with_value{}) == 42);
Expand All @@ -57,5 +60,5 @@ __host__ __device__ constexpr bool test() {
int main(int, char**) {
test();
static_assert(test(), "");
return 0;
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::has_property, cuda::has_property_with

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

struct prop_with_value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::async_resource_ref properties

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::async_resource_ref construction

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_ref properties

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::async_resource_ref equality

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>
#include <cuda/stream_ref>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::async_resource_ref equality

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>
#include <cuda/stream_ref>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_ref properties

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::async_resource_ref properties

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>
#include <cuda/stream_ref>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::async_resource

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::async_resource_with

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_with

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_ref properties

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_ref construction

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cstdint>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_ref properties

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_ref equality

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_ref equality

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_ref properties

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
// UNSUPPORTED: c++03, c++11

// cuda::mr::resource_ref properties

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/memory_resource>

#include <cuda/std/cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/stream_ref>
#include <cuda/std/cassert>
#include <cuda/std/type_traits>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//
//===----------------------------------------------------------------------===//

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/stream_ref>
#include <cuda/std/cassert>

Expand Down
2 changes: 2 additions & 0 deletions .upstream-tests/test/cuda/stream_ref/stream_ref.get.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//
//===----------------------------------------------------------------------===//

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/stream_ref>
#include <cuda/std/cassert>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: nvrtc

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/stream_ref>
#include <cuda/std/cassert>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//
//===----------------------------------------------------------------------===//

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/stream_ref>
#include <cuda/std/cassert>

Expand Down
4 changes: 4 additions & 0 deletions .upstream-tests/test/cuda/stream_ref/stream_ref.wait.fail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: nvrtc

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/stream_ref>
#include <cuda/std/cassert>

Expand Down
2 changes: 2 additions & 0 deletions .upstream-tests/test/cuda/stream_ref/stream_ref.wait.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//
//===----------------------------------------------------------------------===//

#define LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE

#include <cuda/stream_ref>
#include <cuda/std/cassert>

Expand Down
Loading

0 comments on commit d0a55c5

Please sign in to comment.