Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork12k
ENH: Add SIMD sin/cos implementation with numpy-simd-routines#29699
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes from1 commit
919d0b8c5fc842e16efa52f99039File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Extend the C++ doc scope to better explain precision control, which is chosen based on the data type.- Add test cases for sine/cosine facts—for example, `cos(0) == 1`.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -76,17 +76,25 @@ namespace sr = npsr::HWY_NAMESPACE; | ||
| /// Default precision configrations for NumPy SIMD Routines | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Might be good here to tell what low and high imply (or at least where to look it up) | ||
| // TODO: Allow user to configure the default precision at build time. | ||
| namespace detail { | ||
| // `npsr::Precise` is a meta-RAII class responsible for managing the floating-point environment at runtime | ||
| // and holding compile-time configurations for intrinsic floating-point behavior. | ||
| // Default configurations are set to the highest IEEE compliance intent. | ||
| // For more information, see: | ||
| // https://github.com/numpy/numpy-simd-routines/blob/1acd14571b9f58072d1f7f17886945000d78b56a/npsr/precise.h#L93 | ||
| // However, when float64 SIMD is not available or disabled, we define a dummy type to avoid | ||
| // clearing floating-point exceptions within its destructor. | ||
| struct PresiceDummy {}; | ||
| template <typename T> | ||
| struct PreciseByType {}; | ||
| template <> | ||
| struct PreciseByType<float> { | ||
| using Type = decltype(npsr::Precise{npsr::kLowAccuracy}); | ||
| }; | ||
| template <> | ||
| struct PreciseByType<double> { | ||
| #if NPY_HWY_F64 | ||
| using Type =decltype(npsr::Precise{}); | ||
| #else | ||
| // If float64 SIMD isn’t available, use a dummy type. | ||
| // The scalar path will run, but `Type` must still be defined. | ||
| @@ -96,9 +104,12 @@ struct PreciseByType<double> { | ||
| #endif | ||
| }; | ||
| } // namespace detail | ||
| /// `npsr::Precise<...>` for the given type `T`. | ||
| /// If `T` is `float`, it uses the low-accuracy configuration by default. | ||
| /// If `T` is `double`, it uses the high-accuracy configuration by default(if float64 SIMD is available). | ||
| template <typename T> | ||
| using Precise = typename detail::PreciseByType<T>::Type; | ||
| #endif | ||
| #include "simd.inc.hpp" | ||
| } // namespace simd | ||
Uh oh!
There was an error while loading.Please reload this page.