From 7f3a5a2b7097848643623f19a59ceb7899114988 Mon Sep 17 00:00:00 2001 From: Bernhard Schuster Date: Sat, 28 Mar 2020 14:31:13 +0100 Subject: [PATCH] fix/test/serial: more #[serial_test::serial] tags --- Cargo.lock | 2 ++ coaster-nn/src/tests/mod.rs | 6 +++--- coaster/Cargo.toml | 1 + coaster/tests/backend_specs.rs | 2 +- coaster/tests/framework_cuda_specs.rs | 12 ++++++------ coaster/tests/shared_memory_specs.rs | 4 ++-- juice/Cargo.toml | 1 + juice/src/layers/common/convolution.rs | 2 +- juice/src/layers/common/rnn.rs | 4 ++-- rcublas/cublas/src/api/context.rs | 6 +++--- rcublas/cublas/src/api/level1.rs | 14 +++++++------- rcublas/cublas/src/api/level3.rs | 2 +- rcublas/cublas/src/api/util.rs | 6 +++--- rcudnn/cudnn/benches/cudnn_overhead.rs | 4 ++-- rcudnn/cudnn/tests/cudnn_specs.rs | 14 +++++++------- rcudnn/cudnn/tests/tensor_descriptor_specs.rs | 2 +- 16 files changed, 43 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d27328f22..01852ff81 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -268,6 +268,7 @@ dependencies = [ "num 0.2.1", "rand 0.7.3", "regex", + "serial_test", ] [[package]] @@ -947,6 +948,7 @@ dependencies = [ "log", "num 0.2.1", "rand 0.7.3", + "serial_test", "timeit", ] diff --git a/coaster-nn/src/tests/mod.rs b/coaster-nn/src/tests/mod.rs index b9158c04c..2f671bb65 100644 --- a/coaster-nn/src/tests/mod.rs +++ b/coaster-nn/src/tests/mod.rs @@ -199,14 +199,14 @@ macro_rules! test_cuda { #[cfg(feature = "cuda")] #[test] - #[serial] + #[serial_test::serial] fn $f32_name() { $test_name::(crate::tests::get_cuda_backend()) } #[cfg(feature = "cuda")] #[test] - #[serial] + #[serial_test::serial] fn $f64_name() { $test_name::(crate::tests::get_cuda_backend()) } @@ -234,7 +234,7 @@ macro_rules! test_cross { ($test_name:ident, $f32_name:ident) => { #[cfg(all(feature = "native",feature = "cuda"))] #[test] - #[serial] + #[serial_test::serial] fn $f32_name() { $test_name::<_, _>(crate::tests::get_native_backend(), crate::tests::get_cuda_backend()) } diff --git a/coaster/Cargo.toml b/coaster/Cargo.toml index 80ca0c4cd..12394d35b 100644 --- a/coaster/Cargo.toml +++ b/coaster/Cargo.toml @@ -29,6 +29,7 @@ compiletest_rs = { version = "0.4", optional = true } [dev-dependencies] rand = "0.7" coaster-nn = { version = "0.4" } +serial_test = "0.4" [features] default = ["native", "cuda"] diff --git a/coaster/tests/backend_specs.rs b/coaster/tests/backend_specs.rs index 9a201bb82..deccc5f0c 100644 --- a/coaster/tests/backend_specs.rs +++ b/coaster/tests/backend_specs.rs @@ -33,7 +33,7 @@ mod backend_spec { use crate::co::*; #[test] - #[serial] + #[serial_test::serial] fn it_can_create_default_backend() { assert!(Backend::::default().is_ok()); } diff --git a/coaster/tests/framework_cuda_specs.rs b/coaster/tests/framework_cuda_specs.rs index c1afdcf6c..11f2a4fa5 100644 --- a/coaster/tests/framework_cuda_specs.rs +++ b/coaster/tests/framework_cuda_specs.rs @@ -8,14 +8,14 @@ mod framework_cuda_spec { use crate::co::frameworks::cuda::memory::*; #[test] - #[serial] + #[serial_test::serial] fn it_works() { let frm = Cuda::new(); println!("{:?}", frm.hardwares()); } #[test] - #[serial] + #[serial_test::serial] fn it_creates_context() { let frm = Cuda::new(); let hardwares = &frm.hardwares()[0..1]; @@ -23,7 +23,7 @@ mod framework_cuda_spec { } #[test] - #[serial] + #[serial_test::serial] #[allow(unused_must_use)] fn it_allocates_memory() { let vec_a = vec![0isize, 1, 2, -3, 4, 5, 6, 7]; @@ -34,7 +34,7 @@ mod framework_cuda_spec { } #[test] - #[serial] + #[serial_test::serial] #[allow(unused_must_use)] // Create a lot of new CUDA devices, tests for correct dropping of device fn it_creates_a_lot_of_devices() { @@ -45,7 +45,7 @@ mod framework_cuda_spec { } #[test] - #[serial] + #[serial_test::serial] #[allow(unused_must_use)] // Allocate 128mb blocks with dropping them in between, tests for correct freeing of memory fn it_allocates_4gb_memory_same_device() { @@ -58,7 +58,7 @@ mod framework_cuda_spec { } #[test] - #[serial] + #[serial_test::serial] fn it_can_synchronize_context() { let backend = Backend::::default().unwrap(); backend.synchronize().unwrap(); diff --git a/coaster/tests/shared_memory_specs.rs b/coaster/tests/shared_memory_specs.rs index a2c65b2a7..9bc0fe8c6 100644 --- a/coaster/tests/shared_memory_specs.rs +++ b/coaster/tests/shared_memory_specs.rs @@ -25,7 +25,7 @@ mod shared_memory_spec { } #[test] - #[serial] + #[serial_test::serial] #[cfg(feature = "cuda")] fn it_creates_new_shared_memory_for_cuda() { let ntv = Cuda::new(); @@ -62,7 +62,7 @@ mod shared_memory_spec { } #[test] - #[serial] + #[serial_test::serial] #[cfg(feature = "cuda")] fn it_syncs_from_native_to_cuda_and_back() { let cu = Cuda::new(); diff --git a/juice/Cargo.toml b/juice/Cargo.toml index 0a1653b3a..ef2ec4b28 100644 --- a/juice/Cargo.toml +++ b/juice/Cargo.toml @@ -35,6 +35,7 @@ capnpc = "0.12" [dev-dependencies] env_logger = "0.6" +serial_test = "0.4" [features] default = ["native", "cuda"] diff --git a/juice/src/layers/common/convolution.rs b/juice/src/layers/common/convolution.rs index 50de2558d..e5646b42a 100644 --- a/juice/src/layers/common/convolution.rs +++ b/juice/src/layers/common/convolution.rs @@ -328,7 +328,7 @@ mod tests { use crate::co::*; #[test] - #[serial] + #[serial_test::serial] #[cfg(feature="cuda")] fn correct_shapes() { let cfg = ConvolutionConfig { diff --git a/juice/src/layers/common/rnn.rs b/juice/src/layers/common/rnn.rs index d88afad5e..43851ee3d 100644 --- a/juice/src/layers/common/rnn.rs +++ b/juice/src/layers/common/rnn.rs @@ -345,7 +345,7 @@ mod tests { } #[test] - #[serial] + #[serial_test::serial] #[cfg(feature = "cuda")] fn rnn_create_layer() { let cfg = RnnConfig { @@ -397,7 +397,7 @@ mod tests { } #[test] - #[serial] + #[serial_test::serial] #[cfg(feature = "cuda")] fn rnn_forward_pass() { let backend: Backend = cuda_backend(); diff --git a/rcublas/cublas/src/api/context.rs b/rcublas/cublas/src/api/context.rs index 10602386f..e42b4f12a 100644 --- a/rcublas/cublas/src/api/context.rs +++ b/rcublas/cublas/src/api/context.rs @@ -166,13 +166,13 @@ mod test { use super::super::PointerMode; #[test] - #[serial] + #[serial_test::serial] fn create_context() { Context::new().unwrap(); } #[test] - #[serial] + #[serial_test::serial] fn default_pointer_mode_is_host() { let ctx = Context::new().unwrap(); let mode = ctx.pointer_mode().unwrap(); @@ -180,7 +180,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn can_set_pointer_mode() { let mut context = Context::new().unwrap(); // set to Device diff --git a/rcublas/cublas/src/api/level1.rs b/rcublas/cublas/src/api/level1.rs index aeb56bea4..db50057dc 100644 --- a/rcublas/cublas/src/api/level1.rs +++ b/rcublas/cublas/src/api/level1.rs @@ -296,7 +296,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn use_cuda_memory_for_asum() { let native = get_native_backend(); let cuda = get_cuda_backend(); @@ -330,7 +330,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn use_cuda_memory_for_axpy() { let native = get_native_backend(); let cuda = get_cuda_backend(); @@ -367,7 +367,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn use_cuda_memory_for_copy() { let native = get_native_backend(); let cuda = get_cuda_backend(); @@ -399,7 +399,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn use_cuda_memory_for_dot() { let native = get_native_backend(); let cuda = get_cuda_backend(); @@ -436,7 +436,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn use_cuda_memory_for_nrm2() { let native = get_native_backend(); let cuda = get_cuda_backend(); @@ -468,7 +468,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn use_cuda_memory_for_scal() { let native = get_native_backend(); let cuda = get_cuda_backend(); @@ -499,7 +499,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn use_cuda_memory_for_swap() { let native = get_native_backend(); let cuda = get_cuda_backend(); diff --git a/rcublas/cublas/src/api/level3.rs b/rcublas/cublas/src/api/level3.rs index 3716d05d4..90fcf0cde 100644 --- a/rcublas/cublas/src/api/level3.rs +++ b/rcublas/cublas/src/api/level3.rs @@ -128,7 +128,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn use_cuda_memory_for_gemm() { let native = get_native_backend(); let cuda = get_cuda_backend(); diff --git a/rcublas/cublas/src/api/util.rs b/rcublas/cublas/src/api/util.rs index b5cdc757f..412b514aa 100644 --- a/rcublas/cublas/src/api/util.rs +++ b/rcublas/cublas/src/api/util.rs @@ -106,7 +106,7 @@ mod test { use super::super::Context; #[test] - #[serial] + #[serial_test::serial] fn manual_context_creation() { unsafe { let handle = API::ffi_create().unwrap(); @@ -115,7 +115,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn default_pointer_mode_is_host() { unsafe { let context = Context::new().unwrap(); @@ -125,7 +125,7 @@ mod test { } #[test] - #[serial] + #[serial_test::serial] fn can_set_pointer_mode() { unsafe { let context = Context::new().unwrap(); diff --git a/rcudnn/cudnn/benches/cudnn_overhead.rs b/rcudnn/cudnn/benches/cudnn_overhead.rs index 2296a1994..4e2e58992 100644 --- a/rcudnn/cudnn/benches/cudnn_overhead.rs +++ b/rcudnn/cudnn/benches/cudnn_overhead.rs @@ -15,7 +15,7 @@ mod cudnn_spec { use rcudnn::Cudnn; #[test] - #[serial] + #[serial_test::serial] fn it_initializes_correctly() { /* match Cudnn::new() { @@ -29,7 +29,7 @@ mod cudnn_spec { } #[test] - #[serial] + #[serial_test::serial] fn it_returns_version() { println!("cuDNN Version: {:?}", Cudnn::version()); } diff --git a/rcudnn/cudnn/tests/cudnn_specs.rs b/rcudnn/cudnn/tests/cudnn_specs.rs index e4ce818eb..fe77143b2 100644 --- a/rcudnn/cudnn/tests/cudnn_specs.rs +++ b/rcudnn/cudnn/tests/cudnn_specs.rs @@ -22,7 +22,7 @@ mod cudnn_spec { }; #[test] - #[serial] + #[serial_test::serial] fn it_initializes_correctly() { let cuda = Cuda::new(); println!("{:?}", cuda.hardwares()); @@ -36,7 +36,7 @@ mod cudnn_spec { } #[test] - #[serial] + #[serial_test::serial] fn it_returns_version() { println!("cuDNN Version: {:?}", Cudnn::version()); } @@ -49,7 +49,7 @@ mod cudnn_spec { * Since then this has been rewritten to not use transmute but a sequence of unsafe optimizations. */ #[test] - #[serial] + #[serial_test::serial] fn it_computes_sigmoid() { let cudnn = Cudnn::new().unwrap(); let desc = TensorDescriptor::new(&[2, 2, 2], &[4, 2, 1], DataType::Float).unwrap(); @@ -84,7 +84,7 @@ mod cudnn_spec { } #[test] - #[serial] + #[serial_test::serial] fn it_finds_correct_convolution_algorithm_forward() { let cudnn = Cudnn::new().unwrap(); let src = TensorDescriptor::new(&[2, 2, 2], &[4, 2, 1], DataType::Float).unwrap(); @@ -107,7 +107,7 @@ mod cudnn_spec { } #[test] - #[serial] + #[serial_test::serial] fn it_finds_correct_convolution_algorithm_backward() { let cudnn = Cudnn::new().unwrap(); let src = TensorDescriptor::new(&[2, 2, 2], &[4, 2, 1], DataType::Float).unwrap(); @@ -130,14 +130,14 @@ mod cudnn_spec { } #[test] - #[serial] + #[serial_test::serial] fn it_allocates_cuda_device_memory() { let _ = Cudnn::new().unwrap(); let _ = CudaDeviceMemory::new(1024).unwrap(); } #[test] - #[serial] + #[serial_test::serial] fn it_computes_dropout_forward() { let cudnn = Cudnn::new().unwrap(); let src = TensorDescriptor::new(&[2, 2, 2], &[4, 2, 1], DataType::Float).unwrap(); diff --git a/rcudnn/cudnn/tests/tensor_descriptor_specs.rs b/rcudnn/cudnn/tests/tensor_descriptor_specs.rs index 6bece925f..448414b1b 100644 --- a/rcudnn/cudnn/tests/tensor_descriptor_specs.rs +++ b/rcudnn/cudnn/tests/tensor_descriptor_specs.rs @@ -7,7 +7,7 @@ mod tensor_descriptor_spec { use crate::cudnn::TensorDescriptor; #[test] - #[serial] + #[serial_test::serial] fn it_initializes_a_tensor_descriptor() { match TensorDescriptor::new(&[2, 2, 2], &[4, 2, 1], DataType::Float) { Ok(_) => assert!(true),