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

Implement reverse-lane ABI for wasm #1114

Closed
wants to merge 2 commits into from

Conversation

SoniEx2
Copy link

@SoniEx2 SoniEx2 commented Dec 6, 2023

This is probably slower than it needs to be, but we tried to keep it clean more than anything.

Reverse-lane ABI is used in wabt, and even in wasmtime sometimes. Not really aware of any other wasm runtimes that support s390x/big-endian platforms...

(This is also probably wrong somehow, what with the whole "new contributor" thing. Suggestions/feedback/guidance would be appreciated.)

Closes #1113

@mr-c
Copy link
Collaborator

mr-c commented Dec 7, 2023

Thank you @SoniEx2 for this; how shall we test this in our CI? Do we have to use WABT, or ..?

@SoniEx2
Copy link
Author

SoniEx2 commented Dec 7, 2023

How is simde testing set up? The intended use-case of this feature is to run unmodified wasm (simd) tests on s390x platform, including (simd) endian tests. Certainly, using wasm2c would work, but may be too heavyweight...? (And arguably the cyclic dependency is less than ideal...)

@mr-c
Copy link
Collaborator

mr-c commented Dec 7, 2023

How is simde testing set up? The intended use-case of this feature is to run unmodified wasm (simd) tests on s390x platform, including (simd) endian tests. Certainly, using wasm2c would work, but may be too heavyweight...? (And arguably the cyclic dependency is less than ideal...)

In 9212c4a I added s390x GCC builds using -DSIMDE_WASM_REVERSE_LANE_ORDER; should that be enough?

@mr-c
Copy link
Collaborator

mr-c commented Dec 7, 2023

@SoniEx2
Copy link
Author

SoniEx2 commented Dec 7, 2023

hmm...

the feature does work in wabt: https://github.com/SoniEx2/wasm2kotlin/actions/runs/7122216960/job/19392874088

however, wabt has code to specifically take advantage of reverse lane order, while the existing simde tests may not...

will look in a bit, currently on phone.

@mr-c
Copy link
Collaborator

mr-c commented Dec 7, 2023

Here is some of the test code:

simde_v128_t a = simde_wasm_v128_load(test_vec[i].a);
uint32_t r = simde_wasm_i8x16_bitmask(a);
simde_assert_equal_u32(r, test_vec[i].r);

@SoniEx2
Copy link
Author

SoniEx2 commented Dec 7, 2023

ah, indeed!

since wabt stores the entire wasm memory in reverse byte order (so wasm byte address 0 is at mem[size-1]), it aligns nicely with reverse lane order. but the simde tests assume direct byte order.

@SoniEx2
Copy link
Author

SoniEx2 commented Feb 2, 2024

the solution we would like to see would be for the tests to use simde_wasm_*_make, but we no longer feel like these changes would be a particularly good fit for simde. we will just do what we need to do in wabt, tho if anyone wants to revisit this whole thing at some point, they are welcome to do so.

thanks anyway.

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.

wasm simd128: "big-endian" ABI support?
2 participants