-
Notifications
You must be signed in to change notification settings - Fork 253
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
Fix issues related to MXCSR register #1060
Conversation
Thank you @M-HT ! Can you add some tests to demonstrate the fixes? |
The first two issues are missing definitions so tests don't make sense, because programs using them fail to compile without the fix. |
In the To test the I'm less concerned about the third case. |
I'm not sure what meaningful test can be written which uses _MM_ROUND_MASK / _MM_GET_FLUSH_ZERO_MODE. |
How about this test, is it acceptable ? static int
test_simde_MXCSR (SIMDE_MUNIT_TEST_ARGS) {
uint32_t original_mxcsr = simde_mm_getcsr();
uint32_t masked_mxcsr = original_mxcsr & ~(SIMDE_MM_ROUND_MASK | SIMDE_MM_FLUSH_ZERO_MASK);
simde_mm_setcsr(masked_mxcsr | SIMDE_MM_ROUND_NEAREST | SIMDE_MM_FLUSH_ZERO_OFF);
uint32_t rm_nearest_off = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_ROUNDING_MODE());
uint32_t fzm_nearest_off = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_FLUSH_ZERO_MODE());
simde_mm_setcsr(masked_mxcsr | SIMDE_MM_ROUND_NEAREST | SIMDE_MM_FLUSH_ZERO_ON);
uint32_t rm_nearest_on = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_ROUNDING_MODE());
uint32_t fzm_nearest_on = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_FLUSH_ZERO_MODE());
simde_mm_setcsr(masked_mxcsr | SIMDE_MM_ROUND_DOWN | SIMDE_MM_FLUSH_ZERO_OFF);
uint32_t rm_down_off = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_ROUNDING_MODE());
uint32_t fzm_down_off = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_FLUSH_ZERO_MODE());
simde_mm_setcsr(masked_mxcsr | SIMDE_MM_ROUND_DOWN | SIMDE_MM_FLUSH_ZERO_ON);
uint32_t rm_down_on = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_ROUNDING_MODE());
uint32_t fzm_down_on = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_FLUSH_ZERO_MODE());
simde_mm_setcsr(masked_mxcsr | SIMDE_MM_ROUND_UP | SIMDE_MM_FLUSH_ZERO_OFF);
uint32_t rm_up_off = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_ROUNDING_MODE());
uint32_t fzm_up_off = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_FLUSH_ZERO_MODE());
simde_mm_setcsr(masked_mxcsr | SIMDE_MM_ROUND_UP | SIMDE_MM_FLUSH_ZERO_ON);
uint32_t rm_up_on = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_ROUNDING_MODE());
uint32_t fzm_up_on = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_FLUSH_ZERO_MODE());
simde_mm_setcsr(masked_mxcsr | SIMDE_MM_ROUND_TOWARD_ZERO | SIMDE_MM_FLUSH_ZERO_OFF);
uint32_t rm_zero_off = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_ROUNDING_MODE());
uint32_t fzm_zero_off = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_FLUSH_ZERO_MODE());
simde_mm_setcsr(masked_mxcsr | SIMDE_MM_ROUND_TOWARD_ZERO | SIMDE_MM_FLUSH_ZERO_ON);
uint32_t rm_zero_on = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_ROUNDING_MODE());
uint32_t fzm_zero_on = HEDLEY_STATIC_CAST(uint32_t, SIMDE_MM_GET_FLUSH_ZERO_MODE());
simde_mm_setcsr(original_mxcsr);
simde_assert_equal_u32(rm_nearest_off, rm_nearest_on);
simde_assert_equal_u32(rm_down_off, rm_down_on);
simde_assert_equal_u32(rm_up_off, rm_up_on);
simde_assert_equal_u32(rm_zero_off, rm_zero_on);
simde_assert_equal_u32(fzm_nearest_off, fzm_down_off);
simde_assert_equal_u32(fzm_nearest_off, fzm_up_off);
simde_assert_equal_u32(fzm_nearest_off, fzm_zero_off);
simde_assert_equal_u32(fzm_nearest_on, fzm_down_on);
simde_assert_equal_u32(fzm_nearest_on, fzm_up_on);
simde_assert_equal_u32(fzm_nearest_on, fzm_zero_on);
return 0;
} |
Oh, I didn't see that. It would be good to add those
I like them, thanks! Can you add them to this PR? |
I looked at the how to fix the failing tests and noticed following: In simde, functions I think functions |
Makes sense to me, please implement that; thank you! |
@M-HT Do you have time to file the bug report with emscripten/llvm? The emscripten people are pretty fast at fixing things Directions: https://emscripten.org/docs/getting_started/bug_reports.html Error log: https://github.com/simd-everywhere/simde/actions/runs/6172090486/job/16751643532?pr=1060#step:8:1076 |
I created this issue: emscripten-core/emscripten#20250 |
180bc93
to
60e016c
Compare
These are fixes for issues described in #1059.