Matrix storage in julia

How is the matrix stored in Julia? Is it row-major storage like in C++ or column-major storage like Fortran? Recently, I converted my Fortran code in Julia. In Fortran, it takes around 1.6 seconds to run the program. In Julia, it took me 12 seconds for the same program. I am using @time to measure the CPU time where the main calculation is done. Is it normal or I can improve the performance of Julia code.
Thank you.

Column-major like Fortran.

This speed difference is certainly not expected. Without seeing the code it’s hard to tell how to improve it though.

Did you look at the Performance tips?

2 Likes

I was not passing variables to the functions. So, I was accessing global variables in the function where the main calculation is done. After passing the variables as an argument to the function, the execution time reduced to 3.13 seconds. I will look more into performance tips to see if the performance can be further improved.
Thank you.

Also have a look at

to automatically check if you are following the performance tips

3 Likes

I have tried using Traceur.jl, to evaluate my code. However, it hangs. (I use Julia 1.1.0, on notebook)

How to use Traceur.jl yo analyze the code? Are there any instruction on how to use the package?
Thank you.

How can I store the CPU time in a variable? @time just prints the execution time by CPU. Thank you.

Use @timed.

Also check out BenchmarkTools.jl for more accurate benchmarking.

1 Like

How can I use profiling or BenchmarkTools to analyze the code?