I am a Fortran guy and new to Julia. I am translating my Fortran code to Julia, and to make a direct comparison between the speed of modern Fortran and Julia.
But I want to make the comparison fair. I do not want to compare a fast Fortran code with my baby level Julia code. I wish to write the Julia code as fast as I can. So the Fortran .vs. Julia comparison can be reasonable.
Therefore, I just wonder, could anyone recommend perhaps some public Github or Gitlab repos with high performance Julia code? I feel learning from those code can be helpful. Reading the Julia documents still is a little too abstract for me.
Sorry for the direct ping but I think you need to get the perspective of @lmiq, who is probably the most enthusiastic and succesful Fortran convert I know around here. Actually maybe if you go through some of his past posts you can already find some wisdom with regards to what Fortran programmers need to look out for.
The obvious one is: GitHub - JuliaLang/julia: The Julia Programming Language - Most of Julia’s Base module and standard libraries are written in pure Julia with performance in mind. The code is both readable and well-commented (imo).
Just as a random example, here’s a high-performance implementation of trigonometric functions, that is written entirely in Julia. (Parts are translated from C, apparently.)
At the Julia REPL, you can type things like @edit sin(0.0) in order to see the code for a specific function with a specific type of argument.
My advice would be to choose one specific relatively small and self-contained program or function you have in Fortran and start translating it to Julia. If the performance is not similar to the Fortran code, post it here, ask for advice. As a general rule, you should be able to write code in Julia that is as fast as the Fortran code (and vice-versa).
Julia shines, from the perspective of a Fortran developer, not because of the performance you get from very well written code in both languages. That is the same. Julia will give generic functions, a very nice programming experience (you need to use Revise and use a proper development workflow), and many tools that allow you to improve the algorithms you are developing much easily than you (I, in fact) were able to do in Fortran. Also, the package manager and documentation integration is fantastic for distributing and documenting the code.
This in particular looks at one specific important aspect (mutability vs. immutability of variables) from a what I perceived coming from Fortran: Immutable variables · JuliaNotes.jl
But, I insist, start trying and ask for advice here. People here are really helpful.
You can check Home · LoopVectorization.jl. LoopVectorization is a package that enables very fast for loops. The docs have some examples of how fast it can run and how easy it is to use. LoopVectorization might be a bit cheating since it uses a lot of LLVM intrinsics instead of just julia operations, although it is just julia code so it might be fine.
Thank you.
It is a Monte Carlo (MC) code in expectation maximization (EM) algorithm.
in EM, there are loops(iterations) in order to update the parameters, in each iteration, MC is involved in evaluating the integrals for updating the parameters.
I agree with leandromartinez98 that you should generally not see any or much performance gain by converting your Fortran code to Julia (unless there are significant algorithmic differences, which could go either way). You may also want to get help from the Fortran discourse community or get help from experts on the Intel Fortran forum to improve your existing Fortran codebase.
They’re just microbenchmarks, but here are the Fortran benchmarks used and here is the compilation command.
Microbenchmarks may not necessarily be representative of an application, but RecursiveFactorization.jl is an example of a larger program making good use out of it and beating OpenBLAS in performance.