Matrix storage in julia

#1

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.

0 Likes

#2

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

#3

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.

0 Likes

#4

Also have a look at


to automatically check if you are following the performance tips

3 Likes

#5

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

0 Likes

#6

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

0 Likes

#7

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

0 Likes

#8

Use @timed.

Also check out BenchmarkTools.jl for more accurate benchmarking.

1 Like

#9

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

0 Likes