This is a port of the NEMOLite2D codebase in Rust, for benchmarking both Rust and WebAssembly for scientific computing.
For more information about NEMOLite2D, see:
- The STFC site for NEMOLite2D
- The NERC site for GOcean, which is part of the same family of projects and benchmarking suites.
The original code can be found at either of the two above web pages, but the GitHub repository for PSyclone benchmarking is the easiest way to quickly get the most up to date version of the original code. Note that this contains multiple versions of multiple projects. The original serial version which was used for this port can be found at PSycloneBench/ocean/nemo/nemolite2d/original/nemolite2d.f90.
To run natively, install rustup
from https://rustup.rs/ if you haven't already and run:
$ cargo run --release
Running with a WASI-compatible runtime means that you can simply build the .wasm
file for the project and run it exactly like the native executable using one of several available Wasm runtimes.
To build the .wasm
output, you first need to install the WASI libraries for Rust:
$ rustup target add wasm32-wasi
$ cargo build --target=wasm32-wasi --release
The major WASI-compatible runtimes are wasmtime and Wasmer. To run with wasmtime:
$ cargo install wasmtime
$ wasmtime target/wasm32-wasi/release/nemolite2d-rs.wasm --dir=.
To run with Wasmer:
$ curl https://get.wasmer.io -sSfL | sh
$ wasmer run target/wasm32-wasi/release/nemolite2d-rs.wasm --dir=.
Wasmer also supports Wasm's SIMD instructions (at the time of writing, only in the LLVM backend), which allow for significant performance improvements:
$ RUSTFLAGS="-C target-feature=+simd128" cargo build --release --target=wasm32-wasi
$ wasmer run target/wasm32-wasi/release/nemolite2d-rs.wasm --dir=. --backend=llvm --enable-simd
TODO: Add necessary wasm-bindgen attributes and create HTML/JS that runs simulation and shows performance report.