Skip to content

Implement _mm_getcsr, _mm_setcsr, _mm_sfence #88

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

Merged
merged 5 commits into from
Oct 5, 2017

Conversation

nominolo
Copy link
Contributor

This PR implements the following sse intrinsics:

  • _mm_getcsr
  • _mm_setcsr
  • _MM_GET_EXCEPTION_STATE
  • _MM_SET_EXCEPTION_STATE
  • _MM_GET_EXCEPTION_MASK
  • _MM_SET_EXCEPTION_MASK
  • _MM_GET_ROUNDING_MODE
  • _MM_SET_ROUNDING_MODE
  • _MM_GET_FLUSH_ZERO_MODE
  • _MM_SET_FLUSH_ZERO_MODE
  • _mm_sfence

However, all the _MM_* helpers are macros in C, but functions in Rust, so I turned them into lower-case names. See #84 for the open policy discussion on this.

Testing this turned out to be a bit tricky because almost all of the small unit tests seem to get constant folded (see #86).

The _mm_sfence intrinsic doesn't quite fit in thematically. I can put it into a separate PR if that's preferred.

@nominolo
Copy link
Contributor Author

nominolo commented Sep 30, 2017

Hm, the test failure is likely due to constant folding (https://travis-ci.org/rust-lang-nursery/stdsimd/jobs/281739237). Do Travis CI and appveyor use different LLVM versions? The rustc versions seem to be the same.

@alexcrichton
Copy link
Member

I wonder, if this is setting a CPU register, does it work in multithreaded programs? Will this need to be tested as a separate executable? Other than that using functions for macros seems fine, and maybe test::black_box could be used to inhibit constant folding?

@nominolo
Copy link
Contributor Author

nominolo commented Oct 4, 2017

_mm_setcsr must only affect the current thread (otherwise, that's a CPU or Kernel bug). I wrote tests in such a way that there are no asserts between modifying and restoring the state, so even if multiple tests are run in the same thread, it should be safe. I don't know if Rust uses a new thread per test.

@alexcrichton alexcrichton merged commit 6d2730a into rust-lang:master Oct 5, 2017
@alexcrichton
Copy link
Member

Awesome, thanks @nominolo!

@nominolo nominolo deleted the sse branch October 5, 2017 19:38
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.

2 participants