4 ms·
Julia and Matlab use the same (Fortran-based) linear algebra codes in the background. I think it is great to see that a port of the Fortran code in Julia is ne
by jpfr 10y ago
Julia and Matlab use the same (Fortran-based) linear algebra codes in the background.
I think it is great to see that a port of the Fortran code in Julia is nearly as fast as the Fortran code itself. So you can take Julia and write concise Matlab-style code (vectorized everywhere) or write imperative code (loops everywhere) and be equally fast.
Note that the graphs in the post are biased. The Fortran version uses a different algorithm for the solver.
Edit: The Matlab code is highly obfuscated. That is not good for the sake of comparison.
https://github.com/precisesimulation/julia-matlab-fortran-fem-benchmark/blob/master/src_matlab/fem_poisson.m https://github.com/precisesimulation/julia-matlab-fortran-fe...
- SixSigma 10y agoExcept Julia vectorised is not as fast as Julia looped. so this : for i = 1:size(a)[1] a[i] = 2a[i] + 3b[i] end is faster than a = 2a .+ 3b (although I haven't benchmarked it) Here's someone that did : http://aflyax.github.io/de_vectorization-runtime/ http://aflyax.github.io/de_vectorization-runtime/ but in 0.5 there are speedups, apparently. Here's a stack overflow discussion on it http://stackoverflow.com/questions/27928502/julia-vectorized-vs-devectorized-code http://stackoverflow.com/questions/27928502/julia-vectorized...
- bauta-steen 10y agoVery interesting, just tested on 0.5 and vectorized can still be a magnitude slower. ulia> @time vect(x, y, a, b) 0.000038 seconds (29 allocations: 37.406 KB) 1×2 Array{Float64,2}: julia> @time devect(x, y, a, b) 0.000006 seconds (10 allocations: 512 bytes) 1×2 Array{Float64,2}: julia> @time vect(x, y, a, b) 0.002324 seconds (73 allocations: 3.075 MB) 416×2 Array{Float64,2}: julia> @time devect(x, y, a, b) 0.000206 seconds (18 allocations: 23.359 KB) 416×2 Array{Float64,2}:
- marmaduke 10y agoMatlab uses mkl for linear algebra, not the old school Fortran reference routines.
- jpfr 10y agoOptionally. OpenBLAS and LAPACK are the default. See here: https://github.com/JuliaLang/julia https://github.com/JuliaLang/julia OpenBLAS — fast, open, and maintained basic linear algebra subprograms (BLAS) library, based on Kazushige Goto's famous GotoBLAS. LAPACK (>= 3.5) — library of linear algebra routines for solving systems of simultaneous linear equations, least-squares solutions of linear systems of equations, eigenvalue problems, and singular value problems. MKL (optional) – OpenBLAS and LAPACK may be replaced by Intel's MKL library
- marmaduke 10y agoI have compiled Julia from source several times thx; my point was that MATLAB is not using reference Fortran routines.