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

Consider unrolling take_even_odd to remove the if statement #261

Closed
kevaundray opened this issue Sep 5, 2024 · 2 comments
Closed

Consider unrolling take_even_odd to remove the if statement #261

kevaundray opened this issue Sep 5, 2024 · 2 comments

Comments

@kevaundray
Copy link
Contributor

This has been taken from Benedikt Wagner's document.

Link:

for (index, value) in list.iter().enumerate() {

It may improve performance, if a single loop iteration takes two indices.

Some rough pseudocode for this could be:

fn take_even_odd<T: Clone>(list: &[T]) -> (Vec<T>, Vec<T>) {
    assert!(list.len() % 2 == 0, "List length must be even");

    let mut even = Vec::with_capacity(list.len() / 2);
    let mut odd = Vec::with_capacity(list.len() / 2);
    
    for chunk in list.chunks_exact(2) {
        even.push(chunk[0].clone());
        odd.push(chunk[1].clone());
    }
    
    (even, odd)
}

Related to #246

@b-wagn
Copy link

b-wagn commented Sep 6, 2024

This may be worth a try. Not sure if it really improves performance :)

@kevaundray
Copy link
Contributor Author

We now use the iterative version of FFT which does not require take_even_odd! This was added in #274

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

2 participants