Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Send + Sync for CudaStream #254

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/driver/safe/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ pub struct CudaStream {
device: Arc<CudaDevice>,
}

unsafe impl Send for CudaStream {}
unsafe impl Sync for CudaStream {}

impl CudaDevice {
/// Allocates a new stream that can execute kernels concurrently to the default stream.
///
Expand Down Expand Up @@ -906,6 +909,8 @@ impl<R: RangeBounds<usize>> RangeHelper for R {

#[cfg(test)]
mod tests {
use std::thread;

use super::*;

#[test]
Expand All @@ -930,4 +935,17 @@ mod tests {
assert!(unsafe { slice.transmute_mut::<f32>(25) }.is_some());
assert!(unsafe { slice.transmute_mut::<f32>(26) }.is_none());
}

#[test]
fn test_send_dev() {
let dev = CudaDevice::new(0).unwrap();
thread::spawn(|| dev);
}

#[test]
fn test_send_stream() {
let dev = CudaDevice::new(0).unwrap();
let stream = dev.fork_default_stream().unwrap();
thread::spawn(|| stream);
}
}
Loading