Skip to content

Commit 39bd2ec

Browse files
authored
[CUDAX->libcu++] Move device APIs to libcu++ (#5279)
* Move device APIs to libcudacxx * Missing semicolon * Exclude all device APIs for NVRTC
1 parent 75121e7 commit 39bd2ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+424
-431
lines changed

cudax/examples/async_buffer_add.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ struct generator
4848
int main()
4949
{
5050
// A CUDA stream on which to execute the vector addition kernel
51-
cudax::stream stream{cudax::device_ref{0}};
51+
cudax::stream stream{cuda::device_ref{0}};
5252

5353
// The execution policy we want to use to run all work on the same stream
5454
auto policy = thrust::cuda::par_nosync.on(stream.get());
5555

5656
// An environment we use to pass all necessary information to the containers
57-
cudax::env_t<cuda::mr::device_accessible> env{cudax::device_memory_resource{cudax::device_ref{0}}, stream};
57+
cudax::env_t<cuda::mr::device_accessible> env{cudax::device_memory_resource{cuda::device_ref{0}}, stream};
5858

5959
// Allocate the two inputs and output, but do not zero initialize via `cudax::no_init`
6060
cudax::async_device_buffer<float> A{env, numElements, cudax::no_init};

cudax/examples/cub_reduce.cu

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

2727
// A CUDA stream on which to execute the reduction
28-
cudax::stream stream{cudax::devices[0]};
28+
cudax::stream stream{cuda::devices[0]};
2929

3030
// An environment we use to pass all necessary information to the containers
31-
cudax::env_t<cuda::mr::device_accessible> env{cudax::device_memory_resource{cudax::devices[0]}, stream};
31+
cudax::env_t<cuda::mr::device_accessible> env{cudax::device_memory_resource{cuda::devices[0]}, stream};
3232

3333
// Allocate input and output, but do not zero initialize output (`cudax::no_init`)
3434
cudax::async_device_buffer<int> d_in{env, num_items, 1};

cudax/examples/simple_p2p.cu

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
* Unified Virtual Address Space (UVA) features.
3131
*/
3232

33+
#include <cuda/devices>
3334
#include <cuda/memory_resource>
3435

3536
#include <cuda/experimental/algorithm.cuh>
3637
#include <cuda/experimental/container.cuh>
37-
#include <cuda/experimental/device.cuh>
3838
#include <cuda/experimental/launch.cuh>
3939
#include <cuda/experimental/memory_resource.cuh>
4040

@@ -61,9 +61,9 @@ void print_peer_accessibility()
6161
// Check possibility for peer access
6262
printf("\nChecking GPU(s) for support of peer to peer memory access...\n");
6363

64-
for (auto& dev_i : cudax::devices)
64+
for (auto& dev_i : cuda::devices)
6565
{
66-
for (auto& dev_j : cudax::devices)
66+
for (auto& dev_j : cuda::devices)
6767
{
6868
if (dev_i != dev_j)
6969
{
@@ -112,8 +112,8 @@ template <typename BufferType>
112112
void test_cross_device_access_from_kernel(
113113
cudax::stream_ref dev0_stream, cudax::stream_ref dev1_stream, BufferType& dev0_buffer, BufferType& dev1_buffer)
114114
{
115-
cudax::device_ref dev0 = dev0_stream.device();
116-
cudax::device_ref dev1 = dev1_stream.device();
115+
cuda::device_ref dev0 = dev0_stream.device();
116+
cuda::device_ref dev1 = dev1_stream.device();
117117

118118
// Prepare host buffer and copy to GPU 0
119119
printf("Preparing host buffer and copy to GPU%d...\n", dev0.get());
@@ -184,9 +184,9 @@ try
184184

185185
// Number of GPUs
186186
printf("Checking for multiple GPUs...\n");
187-
printf("CUDA-capable device count: %zu\n", cudax::devices.size());
187+
printf("CUDA-capable device count: %zu\n", cuda::devices.size());
188188

189-
if (cudax::devices.size() < 2)
189+
if (cuda::devices.size() < 2)
190190
{
191191
printf("Two or more GPUs with Peer-to-Peer access capability are required for %s.\n", argv[0]);
192192
printf("Waiving test.\n");
@@ -197,8 +197,8 @@ try
197197
print_peer_accessibility();
198198

199199
// But use a shorthand to find all peers of a device
200-
std::vector<cudax::device_ref> peers;
201-
for (auto& dev : cudax::devices)
200+
std::vector<cuda::device_ref> peers;
201+
for (auto& dev : cuda::devices)
202202
{
203203
peers = dev.peer_devices();
204204
if (peers.size() != 0)

cudax/examples/stdexec_stream.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ __host__ void run()
3838
try
3939
{
4040
task::thread_context tctx;
41-
task::stream_context sctx{cuda::experimental::device_ref{0}};
41+
task::stream_context sctx{cuda::device_ref{0}};
4242
auto sch = sctx.get_scheduler();
4343

4444
auto start = //

cudax/examples/vector_add.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int main(void)
7272
try
7373
{
7474
// A CUDA stream on which to execute the vector addition kernel
75-
cudax::stream stream(cudax::devices[0]);
75+
cudax::stream stream(cuda::devices[0]);
7676

7777
// Print the vector length to be used, and compute its size
7878
int numElements = 50000;

cudax/include/cuda/experimental/__device/logical_device.cuh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
# pragma system_header
2222
#endif // no system header
2323

24-
#include <cuda/experimental/__device/all_devices.cuh>
24+
#include <cuda/__device/all_devices.h>
25+
2526
#include <cuda/experimental/__green_context/green_ctx.cuh>
2627

2728
#include <cuda/std/__cccl/prologue.h>
@@ -82,7 +83,7 @@ public:
8283
// More of a micro-optimization, we can also remove this (depending if we keep device_ref)
8384
//!
8485
//! Constructing a logical_device for a given device has a side effect of initializing that device
85-
logical_device(const ::cuda::experimental::physical_device& __dev)
86+
logical_device(const ::cuda::physical_device& __dev)
8687
: __dev_id(__dev.get())
8788
, __kind(kinds::device)
8889
, __ctx(__dev.primary_context())

cudax/include/cuda/experimental/__execution/stream/context.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
# pragma system_header
2222
#endif // no system header
2323

24+
#include <cuda/__device/device_ref.h>
2425
#include <cuda/__stream/get_stream.h>
2526

26-
#include <cuda/experimental/__device/device_ref.cuh>
2727
#include <cuda/experimental/__execution/stream/scheduler.cuh>
2828
#include <cuda/experimental/stream.cuh>
2929

cudax/include/cuda/experimental/__green_context/green_ctx.cuh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,16 @@
2121
# pragma system_header
2222
#endif // no system header
2323

24+
#include <cuda/__device/all_devices.h>
2425
#include <cuda/__driver/driver_api.h>
2526
#include <cuda/std/__cuda/api_wrapper.h>
2627
#include <cuda/std/utility>
2728

28-
#include <cuda/experimental/__device/all_devices.cuh>
29-
3029
#include <cuda/std/__cccl/prologue.h>
3130

3231
#if _CCCL_CTK_AT_LEAST(12, 5)
3332
namespace cuda::experimental
3433
{
35-
struct device_ref;
3634

3735
struct green_context
3836
{

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public:
6262
//! @throws cuda_error if the CUDA version does not support ``cudaMallocAsync``.
6363
//! @param __device_id The device id of the device the stream pool is constructed on.
6464
//! @param __pool_properties Optional, additional properties of the pool to be created.
65-
explicit device_memory_pool(const ::cuda::experimental::device_ref __device_id,
66-
memory_pool_properties __properties = {})
65+
explicit device_memory_pool(const ::cuda::device_ref __device_id, memory_pool_properties __properties = {})
6766
: __memory_pool_base(__memory_location_type::__device, __properties, __device_id.get())
6867
{}
6968

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private:
7777
public:
7878
//! @brief Constructs a device_memory_resource using the default \c cudaMemPool_t of a given device.
7979
//! @throws cuda_error if retrieving the default \c cudaMemPool_t fails.
80-
explicit device_memory_resource(::cuda::experimental::device_ref __device)
80+
explicit device_memory_resource(::cuda::device_ref __device)
8181
: __memory_resource_base(__get_default_device_mem_pool(__device.get()))
8282
{}
8383

0 commit comments

Comments
 (0)