Skip to content

Commit 4d07f0c

Browse files
committed
Run some unit tests on CI.
Most tests are out of reach because they require an NVIDIA GPU, but a few can run. (Ones in `gpu_rand` and `cuda_std` need minor fixes.) Might as well enable them.
1 parent 0e864be commit 4d07f0c

15 files changed

+44
-36
lines changed

.github/workflows/ci_linux.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ jobs:
9292
RUSTFLAGS: -Dwarnings
9393
run: cargo clippy --workspace --exclude "optix*" --exclude "path-tracer" --exclude "denoiser" --exclude "ex0*" --exclude "cudnn*"
9494

95-
# Don't currently test because many tests rely on the system having a CUDA GPU
96-
# - name: Test
97-
# run: cargo test --workspace
95+
# Very limited testing because we can only run tests that don't rely on having a CUDA GPU.
96+
- name: Test
97+
run: cargo test -p cuda_std -p gpu_rand -p nvvm -p rustc_codegen_nvvm
9898

9999
- name: Check documentation
100100
env:

.github/workflows/ci_windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ jobs:
9191
RUSTFLAGS: -Dwarnings
9292
run: cargo clippy --workspace --exclude "optix*" --exclude "path-tracer" --exclude "denoiser" --exclude "vecadd*" --exclude "gemm*" --exclude "ex0*" --exclude "cudnn*" --exclude "sha2*"
9393

94-
# Don't currently test because many tests rely on the system having a CUDA GPU
95-
# - name: Test
96-
# run: cargo test --workspace
94+
# Very limited testing because we can only run tests that don't rely on having a CUDA GPU.
95+
- name: Test
96+
run: cargo test -p cuda_std -p gpu_rand -p nvvm -p rustc_codegen_nvvm
9797

9898
- name: Check documentation
9999
env:

crates/cuda_std/src/thread.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,24 @@
4242
//! ## Computing global indices (examples)
4343
//!
4444
//! 1D global thread index:
45-
//! ```rust
46-
//! use cuda_std::thread;
47-
//! let gx = thread::block_idx_x() * thread::block_dim_x() + thread::thread_idx_x();
45+
//! ```no_run
46+
//! # use cuda_std::kernel;
47+
//! ##[kernel]
48+
//! pub unsafe fn f1d() {
49+
//! use cuda_std::thread;
50+
//! let gx = thread::block_idx_x() * thread::block_dim_x() + thread::thread_idx_x();
51+
//! }
4852
//! ```
4953
//!
5054
//! 2D global coordinates (x, y):
5155
//! ```rust
52-
//! use cuda_std::thread;
53-
//! let x = thread::block_idx_x() * thread::block_dim_x() + thread::thread_idx_x();
54-
//! let y = thread::block_idx_y() * thread::block_dim_y() + thread::thread_idx_y();
56+
//! # use cuda_std::kernel;
57+
//! ##[kernel]
58+
//! pub unsafe fn f2d() {
59+
//! use cuda_std::thread;
60+
//! let x = thread::block_idx_x() * thread::block_dim_x() + thread::thread_idx_x();
61+
//! let y = thread::block_idx_y() * thread::block_dim_y() + thread::thread_idx_y();
62+
//! }
5563
//! ```
5664
//!
5765
//! Note: Hardware limits for block dimensions, grid dimensions, and total threads per block

crates/gpu_rand/src/xoroshiro/xoroshiro128plus.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ impl Xoroshiro128Plus {
2727
/// parallel computations.
2828
///
2929
/// ```
30-
/// use rand_xoshiro::rand_core::SeedableRng;
31-
/// use rand_xoshiro::Xoroshiro128Plus;
30+
/// use gpu_rand::xoroshiro::rand_core::SeedableRng;
31+
/// use gpu_rand::xoroshiro::Xoroshiro128Plus;
3232
///
3333
/// let rng1 = Xoroshiro128Plus::seed_from_u64(0);
3434
/// let mut rng2 = rng1.clone();

crates/gpu_rand/src/xoroshiro/xoroshiro128plusplus.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl Xoroshiro128PlusPlus {
2626
/// parallel computations.
2727
///
2828
/// ```
29-
/// use rand_xoshiro::rand_core::SeedableRng;
30-
/// use rand_xoshiro::Xoroshiro128PlusPlus;
29+
/// use gpu_rand::xoroshiro::rand_core::SeedableRng;
30+
/// use gpu_rand::xoroshiro::Xoroshiro128PlusPlus;
3131
///
3232
/// let rng1 = Xoroshiro128PlusPlus::seed_from_u64(0);
3333
/// let mut rng2 = rng1.clone();

crates/gpu_rand/src/xoroshiro/xoroshiro128starstar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl Xoroshiro128StarStar {
2626
/// parallel computations.
2727
///
2828
/// ```
29-
/// use rand_xoshiro::rand_core::SeedableRng;
30-
/// use rand_xoshiro::Xoroshiro128StarStar;
29+
/// use gpu_rand::xoroshiro::rand_core::SeedableRng;
30+
/// use gpu_rand::xoroshiro::Xoroshiro128StarStar;
3131
///
3232
/// let rng1 = Xoroshiro128StarStar::seed_from_u64(0);
3333
/// let mut rng2 = rng1.clone();

crates/gpu_rand/src/xoroshiro/xoshiro128plus.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ impl Xoshiro128Plus {
2525
/// parallel computations.
2626
///
2727
/// ```
28-
/// use rand_xoshiro::rand_core::SeedableRng;
29-
/// use rand_xoshiro::Xoroshiro128StarStar;
28+
/// use gpu_rand::xoroshiro::rand_core::SeedableRng;
29+
/// use gpu_rand::xoroshiro::Xoroshiro128StarStar;
3030
///
3131
/// let rng1 = Xoroshiro128StarStar::seed_from_u64(0);
3232
/// let mut rng2 = rng1.clone();

crates/gpu_rand/src/xoroshiro/xoshiro128plusplus.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ impl Xoshiro128PlusPlus {
2424
/// parallel computations.
2525
///
2626
/// ```
27-
/// use rand_xoshiro::rand_core::SeedableRng;
28-
/// use rand_xoshiro::Xoroshiro128PlusPlus;
27+
/// use gpu_rand::xoroshiro::rand_core::SeedableRng;
28+
/// use gpu_rand::xoroshiro::Xoroshiro128PlusPlus;
2929
///
3030
/// let rng1 = Xoroshiro128PlusPlus::seed_from_u64(0);
3131
/// let mut rng2 = rng1.clone();

crates/gpu_rand/src/xoroshiro/xoshiro128starstar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ impl Xoshiro128StarStar {
2424
/// parallel computations.
2525
///
2626
/// ```
27-
/// use rand_xoshiro::rand_core::SeedableRng;
28-
/// use rand_xoshiro::Xoroshiro128StarStar;
27+
/// use gpu_rand::xoroshiro::rand_core::SeedableRng;
28+
/// use gpu_rand::xoroshiro::Xoroshiro128StarStar;
2929
///
3030
/// let rng1 = Xoroshiro128StarStar::seed_from_u64(0);
3131
/// let mut rng2 = rng1.clone();

crates/gpu_rand/src/xoroshiro/xoshiro256plus.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ impl Xoshiro256Plus {
2525
/// parallel computations.
2626
///
2727
/// ```
28-
/// use rand_xoshiro::rand_core::SeedableRng;
29-
/// use rand_xoshiro::Xoshiro256Plus;
28+
/// use gpu_rand::xoroshiro::rand_core::SeedableRng;
29+
/// use gpu_rand::xoroshiro::Xoshiro256Plus;
3030
///
3131
/// let rng1 = Xoshiro256Plus::seed_from_u64(0);
3232
/// let mut rng2 = rng1.clone();

0 commit comments

Comments
 (0)