Skip to content

Conversation

miili
Copy link

@miili miili commented Oct 24, 2021

The plan is not modified by ..._execute_dft and alike (see https://www.fftw.org/fftw3_doc/Thread-safety.html)
Thus we can pass the plan &self by constant reference.

This enables multiple threaded ffts from the same plan.

    let mut fft2_r2c = R2CPlan32::aligned(&[window_size, window_size], Flag::ESTIMATE).unwrap();
    let mut fft2_c2r = C2RPlan32::aligned(&[window_size, window_size], Flag::ESTIMATE).unwrap();
    frames
        .par_iter_mut()
        .for_each(|(_frame, window_data)| unsafe {
            let frame_shape = [window_data.shape()[0], window_data.shape()[1]];
            let mut window_data_fft = AlignedVec::new((window_size / 2 + 1) * window_size);
            let mut window_data_slice = window_data.as_slice_mut().unwrap();
            fft2_r2c
                .r2c(&mut window_data_slice, &mut window_data_fft)
                .unwrap();
    });

@miili miili changed the title Planer: non-mutable reference to plan Planer: non-mutable reference enables threading Oct 24, 2021
ThomasHabets added a commit to ThomasHabets/fftw that referenced this pull request Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant