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

Planer: non-mutable reference enables threading #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 10 additions & 8 deletions fftw/src/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pub struct Plan<A, B, Plan: PlanSpec> {
phantom: PhantomData<(A, B)>,
}

unsafe impl<A: Sync, B: Sync> Sync for Plan<A, B, Plan32> {}
unsafe impl<A: Sync, B: Sync> Sync for Plan<A, B, Plan64> {}
unsafe impl<A: Send, B: Send> Send for Plan<A, B, Plan32> {}
unsafe impl<A: Send, B: Send> Send for Plan<A, B, Plan64> {}

Expand Down Expand Up @@ -97,7 +99,7 @@ pub trait C2CPlan: Sized {
) -> Result<Self>;

/// Execute complex-to-complex transform
fn c2c(&mut self, in_: &mut [Self::Complex], out: &mut [Self::Complex]) -> Result<()>;
fn c2c(&self, in_: &mut [Self::Complex], out: &mut [Self::Complex]) -> Result<()>;
}

/// Trait for the plan of Real-to-Complex transformation
Expand All @@ -124,7 +126,7 @@ pub trait R2CPlan: Sized {
) -> Result<Self>;

/// Execute real-to-complex transform
fn r2c(&mut self, in_: &mut [Self::Real], out: &mut [Self::Complex]) -> Result<()>;
fn r2c(&self, in_: &mut [Self::Real], out: &mut [Self::Complex]) -> Result<()>;
}

/// Trait for the plan of Complex-to-Real transformation
Expand All @@ -151,7 +153,7 @@ pub trait C2RPlan: Sized {
) -> Result<Self>;

/// Execute complex-to-real transform
fn c2r(&mut self, in_: &mut [Self::Complex], out: &mut [Self::Real]) -> Result<()>;
fn c2r(&self, in_: &mut [Self::Complex], out: &mut [Self::Real]) -> Result<()>;
}

pub trait R2RPlan: Sized {
Expand All @@ -175,7 +177,7 @@ pub trait R2RPlan: Sized {
) -> Result<Self>;

/// Execute complex-to-complex transform
fn r2r(&mut self, in_: &mut [Self::Real], out: &mut [Self::Real]) -> Result<()>;
fn r2r(&self, in_: &mut [Self::Real], out: &mut [Self::Real]) -> Result<()>;
}

macro_rules! impl_c2c {
Expand Down Expand Up @@ -204,7 +206,7 @@ macro_rules! impl_c2c {
phantom: PhantomData,
})
}
fn c2c(&mut self, in_: &mut [Self::Complex], out: &mut [Self::Complex]) -> Result<()> {
fn c2c(&self, in_: &mut [Self::Complex], out: &mut [Self::Complex]) -> Result<()> {
self.check(in_, out)?;
unsafe { $exec(self.plan, in_.as_mut_ptr(), out.as_mut_ptr()) };
Ok(())
Expand Down Expand Up @@ -242,7 +244,7 @@ macro_rules! impl_r2c {
phantom: PhantomData,
})
}
fn r2c(&mut self, in_: &mut [Self::Real], out: &mut [Self::Complex]) -> Result<()> {
fn r2c(&self, in_: &mut [Self::Real], out: &mut [Self::Complex]) -> Result<()> {
self.check(in_, out)?;
unsafe { $exec(self.plan, in_.as_mut_ptr(), out.as_mut_ptr()) };
Ok(())
Expand Down Expand Up @@ -280,7 +282,7 @@ macro_rules! impl_c2r {
phantom: PhantomData,
})
}
fn c2r(&mut self, in_: &mut [Self::Complex], out: &mut [Self::Real]) -> Result<()> {
fn c2r(&self, in_: &mut [Self::Complex], out: &mut [Self::Real]) -> Result<()> {
self.check(in_, out)?;
unsafe { $exec(self.plan, in_.as_mut_ptr(), out.as_mut_ptr()) };
Ok(())
Expand Down Expand Up @@ -318,7 +320,7 @@ macro_rules! impl_r2r {
phantom: PhantomData,
})
}
fn r2r(&mut self, in_: &mut [Self::Real], out: &mut [Self::Real]) -> Result<()> {
fn r2r(&self, in_: &mut [Self::Real], out: &mut [Self::Real]) -> Result<()> {
self.check(in_, out)?;
unsafe { $exec(self.plan, in_.as_mut_ptr(), out.as_mut_ptr()) };
Ok(())
Expand Down