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

Replace custom SIMD abstractions with a crates.io crate #38

Open
liebharc opened this issue Oct 3, 2018 · 2 comments
Open

Replace custom SIMD abstractions with a crates.io crate #38

liebharc opened this issue Oct 3, 2018 · 2 comments

Comments

@liebharc
Copy link
Owner

liebharc commented Oct 3, 2018

Right now basic_dsp uses its own SIMD abstractions which are built on simd. The only reason for that is that at the time that code was written nothing else was available. But that seems to change. There are two libraries which should be a good fit to replace the custom code:

  • packed_simd: The abstractions in this crate seem to be able to replace the basic_dsp code. Since it's in the rust-lang-nursery it might become a standard.
  • simdeez: Also offers good abstractions and runs on Rust stable.

For now it seems to be best to wait what happens with packed_simd and then decide which one to pick.

faster and simd_aligned would also be an option. But since the basic_dsp abstractions also will use multiple CPU cores it might be hard to switch to the higher level abstractions of e.g. faster.

@liebharc
Copy link
Owner Author

liebharc commented Jan 5, 2021

The macro approach of simdeez prevents us from combining it with templates. So the macro fails to compile this:

simd_runtime_generate!(
        fn simd_complex_operation<A, F, G>(
            &mut self,
            simd_op: F,
            scalar_op: G,
            argument: A,
            complexity: Complexity,
        ) where
            A: Sync + Copy + Send,
            F: Fn(Reg, A) -> Reg + 'static + Sync,
            G: Fn(Complex<T>, A) -> Complex<T> + 'static + Sync,
        {
            {
                let data_length = self.valid_len;
                let array = self.data.to_slice_mut();
                let partition = Reg::calc_data_alignment_reqs(&array[0..data_length]);
                Chunk::execute_partial(
                    complexity,
                    &self.multicore_settings,
                    partition.center_mut(array),
                    Reg::LEN,
                    argument,
                    move |array, argument| {
                        let array = Reg::array_to_regs_mut(array);
                        for reg in array {
                            *reg = simd_op(*reg, argument);
                        }
                    },
                );
    
                for num in partition.cedge_iter_mut(array_to_complex_mut(&mut array[0..data_length])) {
                    *num = scalar_op(*num, argument);
                }
            }
        }
    );

Of course there would be other changes we would need to the code IF the macro would get past the generic definitions.

@liebharc
Copy link
Owner Author

liebharc commented Jan 5, 2021

Work on https://github.com/rust-lang/stdsimd seems to be continuing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant