Live data from Hacker News

LFortran: Modern interactive LLVM-based Fortran compiler

lfortran.org

31–40 of 73 posts

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#32

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

LFortran author here. We will get there. I spent a lot of time in the last year bootstrapping our efforts around https://fortran-lang.org/, which was very successful. I have shifted my focus on LFortran again now.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#33
post #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?

Yeah, you got it. The diagonal() matrix is not actually created since you really don't need all the elements in the final computation.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#34
post #13

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 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…

Thanks for the benchmarks. Do you see some intrinsic reason why a Fortran compiler couldn't do these optimizations? I would think it would know all the information so it would be the ideal place to optimize it.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#35

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…

You can do this with Julia. Julia has an insanely good interop with essentially any language you can name, including cpp and Fortran. You will go through julia but hey, for linear algebra it's the shit.

It would be interesting to compare using Eigen's BCDSVD solv er vs handing it off to julia's library to compute the SVD and handing it back.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#36
post #34
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…

Thanks for the benchmarks. Do you see some intrinsic reason why a Fortran compiler couldn't do these optimizations? I would think it would know all the information so it would be the ideal place to optimize it.

There is no reason it could not. Those optimizations just have to be implemented. Flang (the one merged into LLVM) is using MLIR, which has all the required code-gen abilities. That just leaves the cost modeling / deciding which optimizations/transformations to apply.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#37
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?

That's ridiculous, you can make a C++ class and overload operator() like Eigen to easily make a multi-dimensional array.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#38
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?

Julia, R, and MATLAB. But yeah, it's not common. I end up reinventing this wheel about once a year.

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#39
post #26

Earlier quoted context omitted.

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

That's ridiculous, you can make a C++ class and overload operator() like Eigen to easily make a multi-dimensional array.

"natively"

Re: LFortran: Modern interactive LLVM-based Fortran compiler

#40

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 have been using armadillo now vs Eigen for a couple of years, which can be compiled against OpenBLAS and LAPACK, where matrix ops are handled by fortran routines.

http://arma.sourceforge.net/download.html

Post reply on HN