WebAssembly / simd

Branch of the spec repo scoped to discussion of SIMD in WebAssembly
Other
527 stars 50 forks source link

Double-precision SIMD conversions #348

Open Maratyszcza opened 3 years ago

Maratyszcza commented 3 years ago

Currently WebAssembly SIMD specification is missing all kinds of double-precision f64x2 conversions. The instruction set needs at least the following conversions to be usable:

tlively commented 3 years ago

Can you clarify what you mean by "to be usable?" Are there real-world applications that would require these conversions for which scalarizing them would be insufficient?

Maratyszcza commented 3 years ago

Without these instructions SIMD specification is functionally incomplete: it doesn't cover many basic C/C++ operations (conversions between double type and other types). Double-precision computations are mostly used in scientific computing, and so are conversions between double and int/float:

ngzhian commented 3 years ago

What have you been doing intrinsics wise in the absence of these instructions? Are you scalarizing them?

I took a quick peek at the suggested conversions, it looks like on x86 they map to pretty straightforward instructions (cvt* family), and also we have the scalar instructions in Wasm already. So symmetry wise and codegen wise they seem pretty okay.

Maratyszcza commented 3 years ago

XNNPACK doesn't use double-precision, so I didn't need to find a work-around. The emmintrin.h header in Emscripten implements these functions through scalarization.

jan-wassenberg commented 3 years ago

+1 for these being useful, the math library being built for Highway requires these.