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

Scalar + &array and &array + scalar performance improvements #890

Merged
merged 2 commits into from
Jan 10, 2021

Conversation

bluss
Copy link
Member

@bluss bluss commented Jan 10, 2021

This incorporates the benchmark and performance improvements from #782 by @jturner314, without
the applicable types changes (since they run into some rustc bugs at the moment). Jim Turner is
the author of this, I've only edited the commits to the changes we can integrate now.

@jturner314 writes:

  • The new implementation avoids cloning the elements twice, and it
    avoids iterating over the elements twice. (The old implementation
    called .to_owned() followed by the arithmetic operation, while the
    new implementation clones the elements and performs the arithmetic
    operation in the same iteration.)

On my machine, this change improves the performance for both
contiguous and discontiguous arrays. (scalar_add_1/2 go from ~530
ns/iter to ~380 ns/iter, and scalar_add_strided_1/2 go from ~1540
ns/iter to ~1420 ns/iter.)

jturner314 and others added 2 commits December 29, 2020 19:59
* The new implementation avoids cloning the elements twice, and it
  avoids iterating over the elements twice. (The old implementation
  called `.to_owned()` followed by the arithmetic operation, while the
  new implementation clones the elements and performs the arithmetic
  operation in the same iteration.)

On my machine, this change improves the performance for both
contiguous and discontiguous arrays. (`scalar_add_1/2` go from ~530
ns/iter to ~380 ns/iter, and `scalar_add_strided_1/2` go from ~1540
ns/iter to ~1420 ns/iter.)

(Other changes to impl applicability removed from this commit.)

Co-authored-by: bluss <bluss@users.noreply.github.com>
@bluss bluss changed the title Scalar + &Array and &Array + scalar performance improvements Scalar + &array and &array + scalar performance improvements Jan 10, 2021
@bluss bluss merged commit 6483ef5 into master Jan 10, 2021
@bluss bluss deleted the jt-scalar-ops-improvement branch January 10, 2021 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants