Stream: general

Topic: wasm_memory_t block allocation


view this post on Zulip Steve Williams (May 09 2020 at 15:07):

I'd like all wasm_memory_t allocations to be 16 byte aligned so SIMD operation thingies can work as they would in straight native code.

Therefore please perform allocations using :

auto my_aligned_buffer = _aligned_malloc(num_bytes, 16);

.. or provide a mechansism so I can request this if you don't want all buffers allocating like this for some reason.

If that's already in, great :)

view this post on Zulip Steve Williams (May 10 2020 at 08:15):

Don't suppose anyone has any insight into how easy or otherwise it'll be to modify the wasm_memory_t allocations from whatever you're currently doing to aligned_alloc. I don't know much rust. Looked up memory allocation & there's no aligned equivalent as far as I could see. So it'd have to be a C unsafe block ? This is required for performance as otherwise, every operation, you have to copy from where a vector or matrix is into a known aligned block.

view this post on Zulip Steve Williams (May 10 2020 at 08:19):

As a follow on, it'd be nice to be able to perform simd math ops trusted side to keep frequency of interop to the minimum. Have no idea if wasm machine has simd vector/matrix math op concepts at this point. This would mean adding vector2,3,4 and matrix23, matrix34 and matrix44 basic types (scalars being floats for our requirements).

view this post on Zulip Steve Williams (May 10 2020 at 08:21):

then built in basic vector & matrix ops so we can cranelift simd instructions in where the hardware supports it.

view this post on Zulip Steve Williams (May 10 2020 at 08:27):

view this post on Zulip Steve Williams (May 10 2020 at 08:28):

ahhh :)

https://v8.dev/features/simd

view this post on Zulip Steve Williams (May 11 2020 at 07:13):

going beyond that, its conceptually safe to perform more complex parallel ops from untrusted side on the gpu. I don't currently have a requirement for that but its good to think ahead. there's a hit every time you upload to the gpu then download the result, so its not always performant, but it does have its uses. for the time being it'd be good to get simd parity with v8.


Last updated: Nov 22 2024 at 16:03 UTC