Why didn't Rust initially implement the default SIMD architecture like Mojo?

Hi, rustaceans. Why didn't Rust initially implement the default simd architecture as a mojo? Is this due to low-level constraints?

On the other hand, there is std::simd aimed at correcting this situation) Thanks

Can you elaborate on what Mojo does that Rust doesn't with respect to SIMD? I've never used Mojo.

Generally, SIMD objects are initialized as SIMD[datatype, size](values) , so to create a SIMD object consisting of four 8-bit unsigned integers we would do:

simd_4x_uint8 = SIMD[DType.uint8, 4](1, 2, 4, 8)
print(simd_4x_uint8)

[1, 2, 4, 8]
And actually, SIMD is so central to Mojo that the builtin Float32 type is actually just an alias for SIMD[DType.float32, 1]:

let x: Float32 = 10.
print(x.type)

let y = SIMD[DType.float32, 1](10.)
print(y.type)
float32
float32

The only difference is probably that in mojo it already works under the hood, and in Rust you need to use the std::simd for this

I wonder what that DType.float32 is though.

std::simd is not a crate.

Sorry, you're right. But you get the idea

How would you like it to work in architectures without SIMD instructions?

1 Like

I found the answer. I think it will be fair for Rust too

https://www.reddit.com/r/C_Programming/comments/113fbbr/why_would_a_language_not_natively_support_simd/

std::simd falls back to scalar math if simd isn't supported, it provides types like f32x1, f64x1 which represent Simd<f32, 1> etc. and can already be used with the nightly toolchain.

3 Likes