Remix.run Logo
bencyoung 13 hours ago

Odd that c# has a better stable SIMD story than Rust! It has both generic vector types across a range of sizes and a good set of intrinsics across most of the common instruction sets

kelnos 13 hours ago | parent | next [-]

Why would that be odd? C# is an older and mature language backed by a corporation, while Rust is younger and has been run by a small group of volunteers for years now.

josefx 5 hours ago | parent | next [-]

> hile Rust is younger and has been run by a small group of volunteers for years now

I thought Rust was getting financial support from Google, Microsoft and Mozilla? Or was the Rust Foundation just a convenient way for Mozilla to fire a large amount of developers and we are actually rapidly approaching the OpenSSL Heartbleed state. Where everyone is happily building on a secure foundation that is maintained by a half dead intern when he isn't busy begging for scraps on the street?

testdelacc1 3 hours ago | parent [-]

Mozilla hasn’t supported development on the Rust project for about 5 years now, since laying off all the developers working on it in August 2020.

Since then several Rust project developers did find full time jobs in companies like Amazon, Meta etc. But corporate interest ebbs and flows. For example Huawei employed a couple of engineers to improve the compiler for several years but they lost interest a couple of months ago.

The Rust Foundation is powered by donations, but a lot of its expenses went on funding infrastructure, security, legal expenses. But this problem of funding the maintainers of the project is on their radar. Yesterday they started an initiative to fund raise for the Maintainers Fund, with the money going straight to maintainers who aren’t being paid by their employer to do it full time. (https://rustfoundation.org/media/announcing-the-rust-foundat...)

booi 12 hours ago | parent | prev [-]

not just any corporation.. the largest software corporation on the planet

Arch-TK 11 hours ago | parent [-]

not just any largest software corporation, one of my two least favourite largest software corporations on the planet.

hu3 9 hours ago | parent [-]

not just any least favourite largest software corporation of yours...

the one that most contributes to open source from the largest corporations. so one of my favourites because of that

they were also one of the first of the large corps to show interest in Rust

fulafel 41 minutes ago | parent | prev | next [-]

How much of this is due to use in games and Mono?

Eg https://tirania.org/blog/archive/2008/Nov-03.html

exyi 13 hours ago | parent | prev | next [-]

C# portable SIMD is very nice indeed, but it's also not usable without unsafety. On the other hand, Rust compiler (LLVM) has a fairly competent autovectorizer, so you may be able to simply write loops the right way instead of the fancy API.

buybackoff 11 hours ago | parent | next [-]

Unsafety means different things. In C#, SIMD is possible via `ref`s, which maintains GC safety (no GC holes), but removes bounds safety (array length check). The API is called appropriately Vector.LoadUnsafe

neonsunset 12 hours ago | parent | prev [-]

You are not "forced" into unsafe APIs with Vector<T>/Vector128/256/512<T>. While it is a nice improvement and helps with achieving completely optimal compiler output, you can use it without unsafe. For example, ZLinq even offers .AsVectorizable LINQ-style API, where you pass lambdas which handle vectors and scalars separately. It the user code cannot go out of bounds and the resulting logic even goes through (inlined later by JIT) delegates, yet still offers a massive speed-up (https://github.com/Cysharp/ZLinq?tab=readme-ov-file#vectoriz...).

Another example, note how these implementations, one in unsafe C# and another in safe F# have almost identical performance: https://benchmarksgame-team.pages.debian.net/benchmarksgame/..., https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

jiehong 13 hours ago | parent | prev [-]

C# is blessed on that front. Java’s SIMD state is still sad, and golang is not as great either.

ashf023 13 hours ago | parent | next [-]

Yeah, golang is a particular nightmare for SIMD. You have to write plan 9 assembly, look up what they renamed every instruction to, and then sometimes find that the compiler doesn't actually support that instruction, even though it's part of an ISA they broadly support. Go assembly functions are also not allowed to use the register-based calling convention, so all arguments are passed on the stack, and the compiler will never inline it. So without compiler support I don't believe there's any way to do something like intrinsics even. Fortunately compiler support for intrinsics seems to be on its way! https://github.com/golang/go/issues/73787

Thaxll 10 hours ago | parent [-]

Go has been using register based calling for a while now?

immibis 9 hours ago | parent [-]

GP comment said it's not used for FFI, not that it's not used.

pjmlp 27 minutes ago | parent | prev | next [-]

While it is blocked on Valhala, it is quite usable, if folks use nightly all the the time with Rust, what is the problem with --preview?

soupy-soup 8 hours ago | parent | prev [-]

To be fair, Java's lack of support seems to have more to do with them needing to fix the whole primitive vs object mess rather than a lack of effort. It sounds like the Vector API will be stabilized shortly after they figure that out, but who knows how long it will take.