News for hackers. Stuff that matters.
Re:LFortran Compiles Prima by andsoitis on Sunday March 09, 2025 @05:34AM (#43307617)
LFortran is an alpha-stage modern, interactive LLVM-based Fortran compiler.
Re:LFortran Compiles Prima by froh on Sunday March 09, 2025 @05:12PM (#43313892)
thanks you've saved me looking it up myself
Re:LFortran Compiles Prima by pjmlp on Sunday March 09, 2025 @05:45AM (#43307654)
Nice milestone.

Modern Fortran is no longer the FORTRAN from punch cards, having this compiler push maybe will help folks to write directly blazing performance Fortran code, instead of numerical code in Python.

Re:LFortran Compiles Prima by anta40 on Sunday March 09, 2025 @06:35AM (#43307851)
The lang is still under development, the most current in in Fortran 2023: https://global.oup.com/academic/product/modern-fortran-expla...
Re:LFortran Compiles Prima by pjmlp on Sunday March 09, 2025 @07:41AM (#43308187)
I am fully aware of it, however most recent revisions tend not to be adopted by all compilers, and honestly the large majority only cares about keeping existing code running.

A bit like C23 and C++23 are here, and the large majority is a mix of C89, C99, C++11, and C++17, as what folks in the trenches care about.

Or Java 8 versus Java 24, and so on.

Fortran is in a similar position.

Re:LFortran Compiles Prima by rbanffy on Sunday March 09, 2025 @08:54AM (#43308702)
How many different platforms out there run Fortran code these days? I’m aware of it being very important in scientific computing (and compiling existing code is critical) but I don’t know many other use cases and different platforms requiring different compilers.
Re:LFortran Compiles Prima by pjmlp on Sunday March 09, 2025 @09:05AM (#43308776)
In many HPC cases you are using the platform tools, not gfortran.

Also we have one use case that is responsible for OpenCL losing mindshare for scientific community, running Fortran on GPU.

Thus I bet at least Intel, NVidia, AMD, Cray, IBM, being relevant ones.

Yes, some of them are planning to eventually adopt LFortran to replace their own, like they did with clang, or at least are using LLVM nowadays.

Re:LFortran Compiles Prima by pklausler on Monday March 10, 2025 @11:04AM (#43321453)
I think that you're conflating LFortran with LLVM Flang.
Re:LFortran Compiles Prima by ok123456 on Sunday March 09, 2025 @12:41PM (#43310840)
Everyone using numpy.
Re:LFortran Compiles Prima by rbanffy on Sunday March 09, 2025 @03:23PM (#43312709)
What compilers are used to build it might be relevant.
Re:LFortran Compiles Prima by ok123456 on Sunday March 09, 2025 @03:50PM (#43313014)
Typically gfortran and intel fortran.
Re:LFortran Compiles Prima by ggraphilia on Sunday March 09, 2025 @05:59PM (#43314340)
It may not be that simple on Windows : https://labs.quansight.org/blog/building-scipy-with-flang
Re:LFortran Compiles Prima by jamesfinlayson on Sunday March 09, 2025 @09:00PM (#43315735)
At a previous job there were two fairly old Fortran code bases running on emulated hardware. I think one was using an old proprietary compiler (I want to say from IBM) while the other was almost certainly using some ancient compiler given the emulated hardware that it was running on.
Re:LFortran Compiles Prima by yjftsjthsd-h on Sunday March 09, 2025 @10:20AM (#43309221)
I was given to believe that a lot of numerical code in python is fortran with a little bit of wrapper?
Re:LFortran Compiles Prima by pjmlp on Sunday March 09, 2025 @10:25AM (#43309256)
Depends on the library, it is a mix of C, C++, Fortran, and using Python as JIT DSLs.
Re:LFortran Compiles Prima by actinium226 on Sunday March 09, 2025 @10:29AM (#43309292)
Congrats to Ondřej Čertík and the team working on LFortran, this is a big milestone!
Re:LFortran Compiles Prima by genphy1976 on Sunday March 09, 2025 @12:35PM (#43310762)
For more information about LFortran, see

- Wikipedia: https://en.wikipedia.org/wiki/LFortran

- Homepage: https://lfortran.org

- GitHub: https://github.com/lfortran/lfortran

If you like to play with it, see

- LFortran in web browsers using WebAssembly: https://dev.lfortran.org

- LFortran in Compiler Explorer: https://godbolt.org/z/EfWvsY6Kh

Re:LFortran Compiles Prima by genphy1976 on Sunday March 09, 2025 @12:39PM (#43310824)
In case you appreciate LFortran and would like to sponsor its development, see

- Become a sponsor to LFortran: https://github.com/sponsors/lfortran

- Open Collective: https://opencollective.com/lfortran

- NumFOCUS: https://numfocus.org/donate-to-lfortran

Re:LFortran Compiles Prima by ggraphilia on Sunday March 09, 2025 @01:45PM (#43311639)
Re:LFortran Compiles Prima by pklausler on Monday March 10, 2025 @11:06AM (#43321475)
That's not the same compiler.
Re:LFortran Compiles Prima by ggraphilia on Sunday March 09, 2025 @06:08PM (#43314410)
Re:LFortran Compiles Prima by quanto on Sunday March 09, 2025 @07:03PM (#43314875)
> It utilizes a range of Modern Fortran features, including extensive use of optional variables, function pointer passing, and a randomized test driver, among others. Successfully compiling PRIMA requires a compiler with a robust and mature backend, as well as well-developed intermediate passes and a capable parser.

I am not getting a full picture here. What's challenging about PRIMA code base? Does it use some advanced features that are difficult for a compiler to support? Are the mentioned features in the 2008 standard?

What's actually impressive is that LFortran in alpha stage is only 2x slower than GFortran, which goes back decades.

Re:LFortran Compiles Prima by certik on Monday March 10, 2025 @10:29AM (#43321069)
It was a lot of corner cases that we had to get right, it's the most advanced code that LFortran can compile. I think none of the features individually is difficult to support, but there were a lot of them.
Re:LFortran Compiles Prima by ggraphilia on Sunday March 09, 2025 @07:48PM (#43315168)
Re:LFortran Compiles Prima by genewitch on Monday March 10, 2025 @07:14AM (#43319190)
I'll have to benchmark a library-less Matmul with LFortran, to compare against flang, C, and python versions.

Roughly: 8, 12, 18 units of time, respectively. Python only being twice as slow for the simplest matmul - how much of that is merely the interpreter startup time?