Skip to content

Commit 4d6db76

Browse files
authored
[cudax -> libcu++] Move memory resources to libcu++ (#6384)
* Move memory resources to libcu++ * Add moved headers to the main header * Unused parameter
1 parent 1a25a42 commit 4d6db76

33 files changed

+316
-380
lines changed

cudax/examples/async_buffer_add.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ int main()
5555
// The execution policy we want to use to run all work on the same stream
5656
auto policy = thrust::cuda::par_nosync.on(stream.get());
5757

58-
cudax::device_memory_pool_ref device_resource = cudax::device_default_memory_pool(cuda::device_ref{0});
58+
cuda::device_memory_pool_ref device_resource = cuda::device_default_memory_pool(cuda::device_ref{0});
5959

6060
// Allocate the two inputs and output, but do not zero initialize via `cudax::no_init`
6161
cudax::async_device_buffer<float> A{stream, device_resource, numElements, cudax::no_init};
@@ -69,7 +69,7 @@ int main()
6969
// Add the vectors together
7070
thrust::transform(policy, A.begin(), A.end(), B.begin(), C.begin(), cuda::std::plus<>{});
7171

72-
cudax::pinned_memory_pool_ref pinned_resource = cudax::pinned_default_memory_pool();
72+
cuda::pinned_memory_pool_ref pinned_resource = cuda::pinned_default_memory_pool();
7373

7474
// Verify that the result vector is correct, by copying it to host
7575
cudax::async_host_buffer<float> h_A{stream, pinned_resource, A};

cudax/examples/cub_reduce.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ int main()
2525
constexpr int num_items = 50000;
2626

2727
// A CUDA stream on which to execute the reduction
28-
cudax::stream stream{cuda::devices[0]};
29-
cudax::device_memory_pool_ref mr = cudax::device_default_memory_pool(cuda::devices[0]);
28+
cuda::stream stream{cuda::devices[0]};
29+
cuda::device_memory_pool_ref mr = cuda::device_default_memory_pool(cuda::devices[0]);
3030

3131
// Allocate input and output, but do not zero initialize output (`cudax::no_init`)
3232
auto d_in = cudax::make_async_buffer<int>(stream, mr, num_items, 1);
@@ -41,7 +41,7 @@ int main()
4141
exit(EXIT_FAILURE);
4242
}
4343

44-
auto h_out = cudax::make_async_buffer<float>(stream, cudax::pinned_default_memory_pool(), d_out);
44+
auto h_out = cudax::make_async_buffer<float>(stream, cuda::pinned_default_memory_pool(), d_out);
4545

4646
stream.sync();
4747

cudax/examples/simple_p2p.cu

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void test_cross_device_access_from_kernel(
120120

121121
// This will be a pinned memory vector once available
122122
cudax::uninitialized_buffer<float, cuda::mr::host_accessible> host_buffer(
123-
cudax::legacy_pinned_memory_resource(), dev0_buffer.size());
123+
cuda::legacy_pinned_memory_resource(), dev0_buffer.size());
124124
std::generate(host_buffer.begin(), host_buffer.end(), []() {
125125
static int i = 0;
126126
return static_cast<float>((i++) % 4096);
@@ -215,13 +215,13 @@ try
215215
return 0;
216216
}
217217

218-
cudax::stream dev0_stream(peers[0]);
219-
cudax::stream dev1_stream(peers[1]);
218+
cuda::stream dev0_stream(peers[0]);
219+
cuda::stream dev1_stream(peers[1]);
220220

221221
printf("Enabling peer access between GPU%d and GPU%d...\n", peers[0].get(), peers[1].get());
222-
cudax::device_memory_pool_ref dev0_resource = cudax::device_default_memory_pool(peers[0]);
222+
cuda::device_memory_pool_ref dev0_resource = cuda::device_default_memory_pool(peers[0]);
223223
dev0_resource.enable_access_from(peers[1]);
224-
cudax::device_memory_pool_ref dev1_resource = cudax::device_default_memory_pool(peers[1]);
224+
cuda::device_memory_pool_ref dev1_resource = cuda::device_default_memory_pool(peers[1]);
225225
dev1_resource.enable_access_from(peers[0]);
226226

227227
// Allocate buffers

cudax/include/cuda/experimental/__memory_resource/resource.cuh

Lines changed: 0 additions & 64 deletions
This file was deleted.

cudax/include/cuda/experimental/memory_resource.cuh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
#endif // !LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE
2424

2525
#include <cuda/__memory_resource/any_resource.h>
26+
#include <cuda/__memory_resource/device_memory_pool.h>
27+
#include <cuda/__memory_resource/legacy_managed_memory_resource.h>
28+
#include <cuda/__memory_resource/legacy_pinned_memory_resource.h>
29+
#include <cuda/__memory_resource/managed_memory_pool.h>
30+
#include <cuda/__memory_resource/pinned_memory_pool.h>
2631
#include <cuda/__memory_resource/properties.h>
32+
#include <cuda/__memory_resource/resource.h>
2733

28-
#include <cuda/experimental/__memory_resource/device_memory_pool.cuh>
29-
#include <cuda/experimental/__memory_resource/legacy_managed_memory_resource.cuh>
30-
#include <cuda/experimental/__memory_resource/legacy_pinned_memory_resource.cuh>
31-
#include <cuda/experimental/__memory_resource/managed_memory_pool.cuh>
32-
#include <cuda/experimental/__memory_resource/pinned_memory_pool.cuh>
33-
#include <cuda/experimental/__memory_resource/resource.cuh>
3434
#include <cuda/experimental/__memory_resource/shared_resource.cuh>
3535

3636
#endif // __CUDAX_MEMORY_RESOURCE___

cudax/test/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ foreach(cn_target IN LISTS cudax_TARGETS)
135135
)
136136

137137
cudax_add_catch2_test(test_target memory_resource ${cn_target}
138-
memory_resource/memory_pools.cu
139-
memory_resource/device_memory_resource.cu
140-
memory_resource/managed_memory_resource.cu
141-
memory_resource/pinned_memory_resource.cu
142138
memory_resource/shared_resource.cu
143139
)
144140

cudax/test/algorithm/common.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void check_result_and_erase(cudax::stream_ref stream, Result&& result, uint8_t p
4747
template <typename Layout = cuda::std::layout_right, typename Extents>
4848
auto make_buffer_for_mdspan(Extents extents, char value = 0)
4949
{
50-
cudax::legacy_pinned_memory_resource host_resource;
50+
cuda::legacy_pinned_memory_resource host_resource;
5151
auto mapping = typename Layout::template mapping<decltype(extents)>{extents};
5252

5353
cudax::uninitialized_buffer<int, cuda::mr::host_accessible> buffer(host_resource, mapping.required_span_size());

cudax/test/algorithm/copy.cu

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
C2H_TEST("1d Copy", "[data_manipulation]")
1414
{
15-
cudax::stream _stream{cuda::device_ref{0}};
15+
cuda::stream _stream{cuda::device_ref{0}};
1616

1717
SECTION("Device resource")
1818
{
19-
cudax::device_memory_pool_ref device_resource = cudax::device_default_memory_pool(cuda::device_ref{0});
19+
cuda::device_memory_pool_ref device_resource = cuda::device_default_memory_pool(cuda::device_ref{0});
2020
std::vector<int> host_vector(buffer_size);
2121

2222
{
@@ -46,8 +46,8 @@ C2H_TEST("1d Copy", "[data_manipulation]")
4646

4747
SECTION("Host and managed resource")
4848
{
49-
cudax::legacy_managed_memory_resource managed_resource;
50-
cudax::legacy_pinned_memory_resource host_resource;
49+
cuda::legacy_managed_memory_resource managed_resource;
50+
cuda::legacy_pinned_memory_resource host_resource;
5151

5252
{
5353
cudax::uninitialized_buffer<int, cuda::mr::host_accessible> host_buffer(host_resource, buffer_size);
@@ -78,7 +78,7 @@ C2H_TEST("1d Copy", "[data_manipulation]")
7878
}
7979
SECTION("Launch transform")
8080
{
81-
cudax::legacy_pinned_memory_resource host_resource;
81+
cuda::legacy_pinned_memory_resource host_resource;
8282
cudax::weird_buffer input(host_resource, buffer_size);
8383
cudax::weird_buffer output(host_resource, buffer_size);
8484

@@ -90,7 +90,7 @@ C2H_TEST("1d Copy", "[data_manipulation]")
9090

9191
SECTION("Asymmetric size")
9292
{
93-
cudax::legacy_pinned_memory_resource host_resource;
93+
cuda::legacy_pinned_memory_resource host_resource;
9494
cudax::uninitialized_buffer<int, cuda::mr::host_accessible> host_buffer(host_resource, 1);
9595
cudax::fill_bytes(_stream, host_buffer, fill_byte);
9696

@@ -133,7 +133,7 @@ void test_mdspan_copy_bytes(
133133

134134
C2H_TEST("Mdspan copy", "[data_manipulation]")
135135
{
136-
cudax::stream stream{cuda::device_ref{0}};
136+
cuda::stream stream{cuda::device_ref{0}};
137137

138138
SECTION("Different extents")
139139
{
@@ -154,7 +154,7 @@ C2H_TEST("Mdspan copy", "[data_manipulation]")
154154

155155
SECTION("Launch transform")
156156
{
157-
auto host_resource = cudax::legacy_pinned_memory_resource{};
157+
auto host_resource = cuda::legacy_pinned_memory_resource{};
158158
auto mixed_extents =
159159
cuda::std::extents<size_t, 1024, cuda::std::dynamic_extent, 2, cuda::std::dynamic_extent>(1024, 2);
160160
[[maybe_unused]] auto static_extents = cuda::std::extents<size_t, 1024, 1024, 2, 2>();
@@ -171,7 +171,7 @@ C2H_TEST("Mdspan copy", "[data_manipulation]")
171171

172172
C2H_TEST("Non exhaustive mdspan copy_bytes", "[data_manipulation]")
173173
{
174-
cudax::stream stream{cuda::device_ref{0}};
174+
cuda::stream stream{cuda::device_ref{0}};
175175
{
176176
auto fake_strided_mdspan = create_fake_strided_mdspan();
177177

cudax/test/algorithm/fill.cu

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
C2H_TEST("Fill", "[data_manipulation]")
1414
{
15-
cudax::stream _stream{cuda::device_ref{0}};
15+
cuda::stream _stream{cuda::device_ref{0}};
1616
SECTION("Host resource")
1717
{
18-
cudax::legacy_pinned_memory_resource host_resource;
18+
cuda::legacy_pinned_memory_resource host_resource;
1919
cudax::uninitialized_buffer<int, cuda::mr::device_accessible> buffer(host_resource, buffer_size);
2020

2121
cudax::fill_bytes(_stream, buffer, fill_byte);
@@ -25,7 +25,7 @@ C2H_TEST("Fill", "[data_manipulation]")
2525

2626
SECTION("Device resource")
2727
{
28-
cudax::device_memory_pool_ref device_resource = cudax::device_default_memory_pool(cuda::device_ref{0});
28+
cuda::device_memory_pool_ref device_resource = cuda::device_default_memory_pool(cuda::device_ref{0});
2929
cudax::uninitialized_buffer<int, cuda::mr::device_accessible> buffer(device_resource, buffer_size);
3030
cudax::fill_bytes(_stream, buffer, fill_byte);
3131

@@ -37,7 +37,7 @@ C2H_TEST("Fill", "[data_manipulation]")
3737
}
3838
SECTION("Launch transform")
3939
{
40-
cudax::legacy_pinned_memory_resource host_resource;
40+
cuda::legacy_pinned_memory_resource host_resource;
4141
cudax::weird_buffer buffer(host_resource, buffer_size);
4242

4343
cudax::fill_bytes(_stream, buffer, fill_byte);
@@ -47,7 +47,7 @@ C2H_TEST("Fill", "[data_manipulation]")
4747

4848
C2H_TEST("Mdspan Fill", "[data_manipulation]")
4949
{
50-
cudax::stream stream{cuda::device_ref{0}};
50+
cuda::stream stream{cuda::device_ref{0}};
5151
{
5252
cuda::std::dextents<size_t, 3> dynamic_extents{1, 2, 3};
5353
auto buffer = make_buffer_for_mdspan(dynamic_extents, 0);
@@ -65,7 +65,7 @@ C2H_TEST("Mdspan Fill", "[data_manipulation]")
6565
check_result_and_erase(stream, cuda::std::span(buffer.data(), buffer.size()));
6666
}
6767
{
68-
cudax::legacy_pinned_memory_resource host_resource;
68+
cuda::legacy_pinned_memory_resource host_resource;
6969
using static_extents = cuda::std::extents<size_t, 2, 3, 4>;
7070
auto size = cuda::std::layout_left::mapping<static_extents>().required_span_size();
7171
cudax::weird_buffer<cuda::std::mdspan<int, static_extents>> buffer(host_resource, size);
@@ -77,7 +77,7 @@ C2H_TEST("Mdspan Fill", "[data_manipulation]")
7777

7878
C2H_TEST("Non exhaustive mdspan fill_bytes", "[data_manipulation]")
7979
{
80-
cudax::stream stream{cuda::device_ref{0}};
80+
cuda::stream stream{cuda::device_ref{0}};
8181
{
8282
auto fake_strided_mdspan = create_fake_strided_mdspan();
8383

cudax/test/containers/async_buffer/copy.cu

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,12 @@ C2H_CCCLRT_TEST("make_async_buffer variants", "[container][async_buffer]")
160160
cudax::stream stream{cuda::device_ref{0}};
161161
const cudax::async_buffer<int, cuda::mr::device_accessible, other_property> input{
162162
stream,
163-
cudax::device_default_memory_pool(cuda::device_ref{0}),
163+
cuda::device_default_memory_pool(cuda::device_ref{0}),
164164
{int(1), int(42), int(1337), int(0), int(12), int(-1)}};
165165

166166
// straight from a resource
167-
auto buf = cuda::experimental::make_async_buffer(
168-
input.stream(), cudax::device_default_memory_pool(cuda::device_ref{0}), input);
167+
auto buf =
168+
cuda::experimental::make_async_buffer(input.stream(), cuda::device_default_memory_pool(cuda::device_ref{0}), input);
169169
CUDAX_CHECK(equal_range(buf));
170170
static_assert(
171171
::cuda::mr::synchronous_resource_with<typename decltype(buf)::__resource_t, cuda::mr::device_accessible>);
@@ -174,7 +174,7 @@ C2H_CCCLRT_TEST("make_async_buffer variants", "[container][async_buffer]")
174174
static_assert(!::cuda::mr::synchronous_resource_with<typename decltype(buf)::__resource_t, other_property>);
175175

176176
auto buf2 = cuda::experimental::make_async_buffer<int, cuda::mr::device_accessible>(
177-
input.stream(), {cudax::device_default_memory_pool(cuda::device_ref{0})}, input);
177+
input.stream(), {cuda::device_default_memory_pool(cuda::device_ref{0})}, input);
178178
CUDAX_CHECK(equal_range(buf2));
179179
static_assert(
180180
::cuda::mr::synchronous_resource_with<typename decltype(buf2)::__resource_t, cuda::mr::device_accessible>);
@@ -184,7 +184,7 @@ C2H_CCCLRT_TEST("make_async_buffer variants", "[container][async_buffer]")
184184

185185
// from any resource
186186
auto any_res = cuda::mr::any_resource<cuda::mr::device_accessible, other_property>(
187-
cudax::device_default_memory_pool(cuda::device_ref{0}));
187+
cuda::device_default_memory_pool(cuda::device_ref{0}));
188188
auto buf3 = cudax::make_async_buffer(input.stream(), any_res, input);
189189
CUDAX_CHECK(equal_range(buf3));
190190
static_assert(
@@ -220,7 +220,7 @@ C2H_CCCLRT_TEST("make_async_buffer variants", "[container][async_buffer]")
220220
!::cuda::mr::synchronous_resource_with<typename decltype(buf6)::__resource_t, cuda::mr::host_accessible>);
221221

222222
auto shared_res =
223-
cudax::make_shared_resource<cudax::device_memory_pool_ref>(cudax::device_default_memory_pool(cuda::device_ref{0}));
223+
cudax::make_shared_resource<cuda::device_memory_pool_ref>(cuda::device_default_memory_pool(cuda::device_ref{0}));
224224
auto buf7 = cudax::make_async_buffer(input.stream(), shared_res, input);
225225
CUDAX_CHECK(equal_range(buf7));
226226
static_assert(

0 commit comments

Comments
 (0)