That would save a few steps (gfortran, dragonegg, llvm-as), so it's definitely worth trying.
But note that technically speaking the current approach also uses the LLVM wasm backend (after doing all the above, it uses the LLVM wasm backend to compile LLVM IR to wasm).
While reading the blog article, I kept wondering what the performance was like compared to bare metal?
I guess the performance hit is similar to the one C and Rust take? In the order of 10x slower IIRC? How does a Fortran-written (better optimized) library compare to a C-written one? Is the WASM overhead enough to nullify the performance difference? Are the original optimizations well translated to WASM?
A lot of fluid dynamics code is in Fortran and has been validated in wind tunnel. Scientists do not care about what language it is in nor they want to port and risk breaking the pre validated code. They want to run the code and be able to provide a citation as the ground for their work. Scientifically they would need to produce academic literature validating the port and only then come back to the matter at hand.
All of the stuff at Ames that ran on the Cray, was written in HPE Fortran, because the compiler has the ability to vectorize it, and yes, a lot of those fluid simulations that are in their final form for airfoil design do get validated in wind tunnels.
I would love to see some fluid dynamic work run in a web browser, but ... You need the WebAssembly to be able to vectorize and optimize it: See Airvisual.com
Fortran doesn't have pointer arithmetic, and pointers that decay like C. The compiler can be much more aggressive about optimization.
Passing around variable length arrays and arrays with a variable number of dimensions is much easier than C. You don't need to worry about making your own interface around blocks of memory or macros to do this sort of routine thing.
Bounds checking is standard in every Fortran compiler.
Fortran does what its name implies: FORMula TRANslation of math code without a lot of noise.
Yes, 50 year old Fortran code can be hard to read. But, there are tools that can statically 'modernize' it if you really need to do maintenance on it.
It's awesome that BLAS for the most part will compile (except for the "Complex and quad-precision numeric support is still unavailable, but the rest works just fine." according to the article)
I'm not sure it can. I've worked with VBA professionally and it always needs to run within an Office application like Access of Excel. A transpiler is probably doable, but I don't think it would be easy or even possible to port things using VBA to webasm.
31 comments
[ 2.9 ms ] story [ 74.2 ms ] threadBut note that technically speaking the current approach also uses the LLVM wasm backend (after doing all the above, it uses the LLVM wasm backend to compile LLVM IR to wasm).
> While you were reading this article, the test scripts have already run. So open up the developer console and check it out!
That was really slick.
Or is this project more of a "I did it because it was there and I can" (which is certainly a good reason as well)
Maybe you have a math library in there worth putting into wasm.
I guess the performance hit is similar to the one C and Rust take? In the order of 10x slower IIRC? How does a Fortran-written (better optimized) library compare to a C-written one? Is the WASM overhead enough to nullify the performance difference? Are the original optimizations well translated to WASM?
Ah, that's right. There's a ton of scientific software in FORTRAN.
I would love to see some fluid dynamic work run in a web browser, but ... You need the WebAssembly to be able to vectorize and optimize it: See Airvisual.com
or
https://paveldogreat.github.io/WebGL-Fluid-Simulation/
Passing around variable length arrays and arrays with a variable number of dimensions is much easier than C. You don't need to worry about making your own interface around blocks of memory or macros to do this sort of routine thing.
Bounds checking is standard in every Fortran compiler.
Fortran does what its name implies: FORMula TRANslation of math code without a lot of noise.
Yes, 50 year old Fortran code can be hard to read. But, there are tools that can statically 'modernize' it if you really need to do maintenance on it.