Live data from Hacker News

Fortran on WebAssembly

gws.phd

21–30 of 64 posts

Re: Fortran on WebAssembly

#21

I am pretty ignorant of Web Assembly development. Does Web Assembly have anything to offer me today as a consumer? Or is all of this still setting the groundwork for a future where programs are truly portable? I have heard some rumblings that the WA machinery makes it easier to restrict access (network, files) but I do not know if those are theoretical or implemented today.

Basically Wasm is a virtual machine, is is very similar to JVM that is portable, but the key difference is that Wasm does not have any std nor expose any IO function, so you can build your own host (the VM) that expose functions that can be imported from the Wasm binary, that means that the Wasm binary can have access to the external world only through these functions.

Also I would say an advantage is that the binary format is not proprietary and there's a spec, so anyone could implement their own Wasm VM.

But right now is not in a good place yet, is too early and there are a lot of new functionality that is being standardized by a group (similar to W3C) and the process is very slow.

Re: Fortran on WebAssembly

#22
Is there a somewhat "production"-ready ecosystem for linear algebra in javascript?

Upon googling I often find some ~decade old port of one of the old familiars to javascript (e.g. via emscripten), wondering if I'm missing something.

Re: Fortran on WebAssembly

#23
post #22

Is there a somewhat "production"-ready ecosystem for linear algebra in javascript? Upon googling I often find some ~decade old port of one of the old familiars to javascript (e.g. via emscripten), wondering if I'm missing something.

Do we have a BLAS equivalent on WebGPU or WebNN?

Re: Fortran on WebAssembly

#24
I’ve been reading these articles for years, but I’ve yet to experience any practical use of webassembly outside of contrived demos. Where do people use all this stuff? Does anyone use it?

Re: Fortran on WebAssembly

#25
post #7

Earlier quoted context omitted.

The author of LFortran here. The demo at https://dev.lfortran.org uses our direct WASM backend that does not use LLVM. It is currently more limited, and indeed, we currently do not support the cubic power x**3 there, only square power x**2. Our most advanced backend is LLVM, and that of course supports x**3 and a very wide subset of Fortran (such as 60% of all SciPy packages fully compile and all SciPy tests pass). H…

Just curious but what is keeping you from compiling x*3?

Nothing, we can compile x*3. We can't compile x**3, because we do not have a runtime library setup for WASM yet (Flang above had the same issue) and WASM can do x**2, but arbitrary power, such as x**3, requires a runtime power function that we haven't implemented yet. If you want to help, you can fix it probably quite easily right here: https://github.com/lfortran/lfortran/blob/69d488b1d1fd26b163....

Re: Fortran on WebAssembly

#26
post #7

Earlier quoted context omitted.

The author of LFortran here. The demo at https://dev.lfortran.org uses our direct WASM backend that does not use LLVM. It is currently more limited, and indeed, we currently do not support the cubic power x**3 there, only square power x**2. Our most advanced backend is LLVM, and that of course supports x**3 and a very wide subset of Fortran (such as 60% of all SciPy packages fully compile and all SciPy tests pass). H…

I’ll definitely be trying out more of LFortran in the future. For this post I really wanted to go deeper into the approach we’ve taken with flang, but I can see that LFortran is also a very strong choice here for running Fortran on Wasm.

Thanks. Please report all bugs that you find. I talked to my collaborators, we'll try to get some simple demo of Fortran->LLVM->WASM working soon, we need to figure out the runtime library issue (like you did), hook it into the driver, etc. I was in fact thinking about exactly this just last week, to easily distribute my simple computational codes online via static pages.

I think exactly the approach that you took with Flang should work with LFortran also.

Re: Fortran on WebAssembly

#27
post #7

Earlier quoted context omitted.

The author of LFortran here. The demo at https://dev.lfortran.org uses our direct WASM backend that does not use LLVM. It is currently more limited, and indeed, we currently do not support the cubic power x**3 there, only square power x**2. Our most advanced backend is LLVM, and that of course supports x**3 and a very wide subset of Fortran (such as 60% of all SciPy packages fully compile and all SciPy tests pass). H…

Grats for the amazing work! LFortran is very cool project.

Thank you!

Re: Fortran on WebAssembly

#28

I don't know whether to be impressed or horrified. Maybe both. I would recommend using top-of-tree llvm-project/main sources for building f18; we are a fast-moving project and it would be a waste of time for anybody to debug a problem that has already been fixed, or miss a feature that has already been implemented.

I was unable to understand the llvm source well enough to understand your point. Are they working on a WebAssembly port that will get their intermediate code to a point where Fortran works?

Re: Fortran on WebAssembly

#29

I wish I had kept my Fortran 78 code from 1981/82 to see if I could get it to run on this. It was a Jovial programming language source code formatter. Not exactly what you should use Fortran for, but that's the only choice I had.

Did you work at Hughes in Orange County?

Re: Fortran on WebAssembly

#30

I love the "simplest nontrivial example" approach to exposition. I think I learned a lot from the article because it was grounded in the concrete problem "call a BLAS function from Javascript". Great post!

Thanks! There’s a series of books I really like, The Theoretical Minimum[1], that also takes that kind of approach but for teaching physics. [1] https://en.m.wikipedia.org/wiki/The_Theoretical_Minimum

Yes, I also like The Theoretical Minimum. Ha, I didn't realize there is more than one book! I think I only have the classical mechanics book. Need to buy the other ones.

I tried to organize many physics subjects in a similar manner, with many worked out examples (minimal, but non-trivial/complete):

https://www.theoretical-physics.com/dev/index.html

Post reply on HN