Live data from Hacker News

LFortran: Modern interactive LLVM-based Fortran compiler

lfortran.org

21–30 of 73 posts

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#21
post #14

Wish lisp have these like jupyter integration. And my first computer lecture many decades ago is really about how he hated fortran and why FORTRAN is still not dead (Mainly negative view due to haveGOTO that time). And it is still not dead.

There’s this:

https://github.com/yitzchak/common-lisp-jupyter

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#22
post #13

Earlier quoted context omitted.

I think Eigen's template strategy is probably hard to beat from the perspective of combining operations. How well Fortran does is probably mostly up to the compiler implementation. In some of my benchmarks, gfortran sometimes seems to fuse the operations and end up much slower than if it has performed them separately in succession, but I wouldn't be surprised if compiling with `-fexternal-blas` (and linking MKL) woul…

These benchmarks are very interesting! From my experience gfortran’s MATMUL is very good for small matrices, but OpenBLAS gets better from ~10x10 elements. Not quite sure that’s the same as your benchmark; its colour code is a bit confusing. Would you mind making the data available? Certainly, gfortran’s default implementation works well as a quick and easy solution for small vectors and matrices outside of hot paths…

My color coding is bad (and there's an open issue about it), but I haven't come up with a great solution. One idea I should add was to make everything relative to LoopVectorization, but that wouldn't help for those interested in other comparisons like Eigen vs gfortran.

I'm on gfortran 10.1.1, so I'd only be missing out on very recent improvements (i.e., to trunk).

Note that these benchmarks were dynamically sized. If you write a fortran program like

  real(kind=8), dimension(10,10) :: A, B, C
  ! fill A and B somehow
  C = matmul(A, B)
the compiler will take advantage of the known dimensions and inline the call, making it much faster.

> I would love an option to align arrays in gfortran. It’s very important to take advantage of automatic vectorisation but I haven’t found a reliable way to do it.

I wish more compilers could also use masks to vectorize without padding. If multiplying 7x7 matrices with AVX512, the obvious solution is to just mask the loads/stores of columns, without the need for padding. Of course, padding would also ensure all your loads/stores are aligned, which can be nice.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#23

I use C++ Eigen extensively. I wonder if it feasible to write a C++ programs that hands off blocks of linear algebra code to Fortran subroutines. Eigen does a wonderful job of late binding and lazy evaluation so that something like the following is fairly efficient: (L.transpose() * P).diagonal().array().square().mean(); which computes the squared average of column by column dot products between matrices L and P. I a…

I've never used Eigen, could you explain specifically what lazy evaluation implies for this expression? Is it to do with the diagonal() call constraining the amount of work to be done?

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#24
post #22

Earlier quoted context omitted.

These benchmarks are very interesting! From my experience gfortran’s MATMUL is very good for small matrices, but OpenBLAS gets better from ~10x10 elements. Not quite sure that’s the same as your benchmark; its colour code is a bit confusing. Would you mind making the data available? Certainly, gfortran’s default implementation works well as a quick and easy solution for small vectors and matrices outside of hot paths…

My color coding is bad (and there's an open issue about it), but I haven't come up with a great solution. One idea I should add was to make everything relative to LoopVectorization, but that wouldn't help for those interested in other comparisons like Eigen vs gfortran. I'm on gfortran 10.1.1, so I'd only be missing out on very recent improvements (i.e., to trunk). Note that these benchmarks were dynamically sized. I…

I think what the plots need is an option to show or hide each curve. It’s a rather large increase in complexity compared to just generating images, though.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#25

Looking forward to differentiable programming in Fortran.

I believe that's called "Julia".

There's a library for Julia coming out soon that can differentiate Fortran code. So, while tongue and cheek, it's not that far off!

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#27
post #26

Not much of a Fortran yet without arrays, complex numbers, or strings.

fortran - one of only a handful of languages that natively supports multidimensional arrays, maybe the only low level one?

C kind of does, right? A multidimensional array in C isn't just an array of pointers.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#28

Is this related to flang? https://github.com/llvm/llvm-project/tree/master/flang/

LFortran author here. As kergonath said below, both "new" Flang that you linked above, and LFortran started at about the same time. I know the Flang developers well and I am hoping we'll be able to collaborate in the future more. It looks like MLIR would be one option: they are going to use it for Flang and LFortran can have a backend that could also use it.

LFortran's main advantage is that it is interactive, so the parser and semantics has to be a little different. And also we designed it so that it will be quite approachable for people to write tools on top.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#29

Nice, I want to play with this, but I see on the Development page there is no/limited support for arrays?

LFortran author here. There is a Python prototype version that you can see in the notebook and it has very limited support for arrays. I stopped spending more time on it once I got further enough to validate that the idea works. And I am now spending all my time on the production LFortran implementation in C++. I am very close to make it usable for some very simple things, and then we'll go from there.
Post reply on HN