C/C++ now is supported widely in parallel computing, such as CUDA, AMP, ACC, OpenCL, OpenMP, MPI and so on. The for-loop computing in C/C++ is pretty easy to unroll and optimize by compiler. So is Rust is suitable for this ? Is any benchmark for Rust to test performance in parallel computing area?
I think there are two questions here: 1) Is Rust the language suitable for parallel computing? 2) Is Rust the ecosystem suitable for parallel computing?
I think the answer to 1 is almost unreservedly yes - Rust code optimizes just as well as C++ (though you should still benchmark your specific problem!). Of course, you’re at the mercy of the Rust compiler and LLVM. You don’t have the diversity of compilers, for better or worse, that are available for C++.
The answer to 2 is more murky. CPU shared-memory parallelism is available in the highly popular rayon crate. MPI is available to a large degree via the rsmpi crate, which I contribute to. GPGPU offload is currently not too great, though, but people are currently investigating improving the situation (see: Rustacuda).
Today, you’re almost certainly better off writing C++ in HPC, but the situation is slowly improving in the Rust ecosystem!
To add to @AndrewGaspar nice explanations, as of Rust 1.27, SIMD has landed in core::arch and available through
#![feature(stdsimd)]. For ergonomic API, packed_simd is aiming to provide much better and less verbose solution which will hopefully be stabilized in
Also forgot to mention ndarray-parallel which uses rayon under the hood.
Good to see Rust is maturing in this department. I’m also wondering if there exists an example of image processing libs/apps in Rust making use of the SIMD instruction sets? Something similar to Simd.