[julia-users] Re: eig()/eigfact() performance: Julia vs. MATLAB

2015-08-04 Thread Evgeni Bezus
Thank you all for your replies.

I have tried to run the following modified Julia code at my work PC 
(Windows 7, Core i7-2600 , 16 GB RAM):

function f(M)
  for i = 1:10
F = eigfact(M)
  end
end

blas_set_num_threads(1)
n = 1000
M = rand(n, n)
F = eigfact(M)
@time f(M)

The MATLAB code remained the same:

n = 1000;
M = rand(n, n);
[D, V] = eig(M);
tic;
for i = 1:10
[D, V] = eig(M);
end
toc

It turned out that in this case Julia time (~17 sec.) exceeds the MATLAB 
time (~14.5 sec) by less than 20% which is quite acceptable for me. 
Moreover, the laptop time values are almost the same.



понедельник, 13 июля 2015 г., 4:20:41 UTC+4 пользователь Sheehan Olver 
написал:

 Sorry, forgot the timing with the default number of threads.

 *julia **@time eigfact(M);*

 elapsed time: 2.261110895 seconds (79997048 bytes allocated, 2.05% gc time)

 On Monday, July 13, 2015 at 10:19:33 AM UTC+10, Sheehan Olver wrote:

 I remember seeing this same performance gap before.  I believe the 
 problem is that OpenBLAS doesn't have the correct thread defaults. Here are 
 other timings setting the threads directly:

 *julia **blas_set_num_threads(1)*


 *julia **@time eigfact(M);*

 elapsed time: 1.827510669 seconds (79997048 bytes allocated, 1.88% gc 
 time)


 *julia **blas_set_num_threads(2)*


 *julia **@time eigfact(M);*

 elapsed time: 1.549618631 seconds (79997048 bytes allocated)


 *julia **blas_set_num_threads(3);@time eigfact(M);*

 elapsed time: 1.498852226 seconds (79997048 bytes allocated, 2.63% gc 
 time)


 *julia **blas_set_num_threads(4);@time eigfact(M);*

 elapsed time: 2.062847561 seconds (79997048 bytes allocated)

 On Monday, July 13, 2015 at 4:33:56 AM UTC+10, Evgeni Bezus wrote:

 Hi all,

 I am a Julia novice and I am considering it as a potential alternative 
 to MATLAB.
 My field is computational nanophotonics and the main numerical technique 
 that I use involves multiple solution of the eigenvalue/eigenvector problem 
 for dense matrices with size of about 1000*1000 (more or less).
 I tried to run the following nearly equivalent code in Julia and in 
 MATLAB:

 Julia code:

 n = 1000
 M = rand(n, n)
 F = eigfact(M)
 tic()
 for i = 1:10
 F = eigfact(M)
 end
 toc()


 MATLAB code:

 n = 1000;
 M = rand(n, n);
 [D, V] = eig(M);
 tic;
 for i = 1:10
 [D, V] = eig(M);
 end
 toc

 It turns out that MATLAB's eig() runs nearly 2.3 times faster than eig() 
 or eigfact() in Julia. On the machine available to me right now (relatively 
 old Core i5 laptop) the average time for MATLAB is of about 37 seconds, 
 while the mean Julia time is of about 85 seconds. I use MATLAB R2010b and 
 Julia 0.3.7 (i tried to run the code both in Juno and in a REPL session and 
 obtained nearly identical results).

 Is there anything that I'm doing wrong?

 Best regards,
 Evgeni



Re: [julia-users] Re: eig()/eigfact() performance: Julia vs. MATLAB

2015-07-12 Thread Milan Bouchet-Valat
Le dimanche 12 juillet 2015 à 11:38 -0700, John Myles White a écrit :
 http://julia.readthedocs.org/en/release-0.3/manual/performance-tips/
I don't think running the code in the global scope is the problem here:
most of the computing time is probably in BLAS anyway. I think MATLAB
uses Intel MKL while Julia uses OpenBLAS, and maybe on that particular
problem and with your particular machine the former is significantly
faster.

If you really need this 2.3 factor you could try building Julia with
MKL. See https://github.com/JuliaLang/julia/#intel-compilers-and-math
-kernel-library-mkl


Regards


 On Sunday, July 12, 2015 at 8:33:56 PM UTC+2, Evgeni Bezus wrote:
  Hi all,
  
  I am a Julia novice and I am considering it as a potential 
  alternative to MATLAB.
  My field is computational nanophotonics and the main numerical 
  technique that I use involves multiple solution of the 
  eigenvalue/eigenvector problem for dense matrices with size of 
  about 1000*1000 (more or less).
  I tried to run the following nearly equivalent code in Julia and in 
  MATLAB:
  
  Julia code:
  
  n = 1000
  M = rand(n, n)
  F = eigfact(M)
  tic()
  for i = 1:10
  F = eigfact(M)
  end
  toc()
  
  
  MATLAB code:
  
  n = 1000;
  M = rand(n, n);
  [D, V] = eig(M);
  tic;
  for i = 1:10
  [D, V] = eig(M);
  end
  toc
  
  It turns out that MATLAB's eig() runs nearly 2.3 times faster than 
  eig() or eigfact() in Julia. On the machine available to me right 
  now (relatively old Core i5 laptop) the average time for MATLAB is 
  of about 37 seconds, while the mean Julia time is of about 85 
  seconds. I use MATLAB R2010b and Julia 0.3.7 (i tried to run the 
  code both in Juno and in a REPL session and obtained nearly 
  identical results).
  
  Is there anything that I'm doing wrong?
  
  Best regards,
  Evgeni
  


Re: [julia-users] Re: eig()/eigfact() performance: Julia vs. MATLAB

2015-07-12 Thread Mauricio Esteban Cuak
I tried in in Matlab R2014a and Julia 0.3.10 on an 2.5 GHZ i5 and the 
difference was much smaller:

22 seconds for Julia, 19 for Matlab

Also, I tried it in local and global scope and the difference wasn't more 
than one or two seconds




El domingo, 12 de julio de 2015, 13:57:40 (UTC-5), Milan Bouchet-Valat 
escribió:

 Le dimanche 12 juillet 2015 à 11:38 -0700, John Myles White a écrit : 
  http://julia.readthedocs.org/en/release-0.3/manual/performance-tips/ 
 I don't think running the code in the global scope is the problem here: 
 most of the computing time is probably in BLAS anyway. I think MATLAB 
 uses Intel MKL while Julia uses OpenBLAS, and maybe on that particular 
 problem and with your particular machine the former is significantly 
 faster. 

 If you really need this 2.3 factor you could try building Julia with 
 MKL. See https://github.com/JuliaLang/julia/#intel-compilers-and-math 
 -kernel-library-mkl 
 https://github.com/JuliaLang/julia/#intel-compilers-and-math-kernel-library-mkl
  


 Regards 


  On Sunday, July 12, 2015 at 8:33:56 PM UTC+2, Evgeni Bezus wrote: 
   Hi all, 
   
   I am a Julia novice and I am considering it as a potential 
   alternative to MATLAB. 
   My field is computational nanophotonics and the main numerical 
   technique that I use involves multiple solution of the 
   eigenvalue/eigenvector problem for dense matrices with size of 
   about 1000*1000 (more or less). 
   I tried to run the following nearly equivalent code in Julia and in 
   MATLAB: 
   
   Julia code: 
   
   n = 1000 
   M = rand(n, n) 
   F = eigfact(M) 
   tic() 
   for i = 1:10 
   F = eigfact(M) 
   end 
   toc() 
   
   
   MATLAB code: 
   
   n = 1000; 
   M = rand(n, n); 
   [D, V] = eig(M); 
   tic; 
   for i = 1:10 
   [D, V] = eig(M); 
   end 
   toc 
   
   It turns out that MATLAB's eig() runs nearly 2.3 times faster than 
   eig() or eigfact() in Julia. On the machine available to me right 
   now (relatively old Core i5 laptop) the average time for MATLAB is 
   of about 37 seconds, while the mean Julia time is of about 85 
   seconds. I use MATLAB R2010b and Julia 0.3.7 (i tried to run the 
   code both in Juno and in a REPL session and obtained nearly 
   identical results). 
   
   Is there anything that I'm doing wrong? 
   
   Best regards, 
   Evgeni 
   



[julia-users] Re: eig()/eigfact() performance: Julia vs. MATLAB

2015-07-12 Thread Sheehan Olver
I remember seeing this same performance gap before.  I believe the problem 
is that OpenBLAS doesn't have the correct thread defaults. Here are other 
timings setting the threads directly:

*julia **blas_set_num_threads(1)*


*julia **@time eigfact(M);*

elapsed time: 1.827510669 seconds (79997048 bytes allocated, 1.88% gc time)


*julia **blas_set_num_threads(2)*


*julia **@time eigfact(M);*

elapsed time: 1.549618631 seconds (79997048 bytes allocated)


*julia **blas_set_num_threads(3);@time eigfact(M);*

elapsed time: 1.498852226 seconds (79997048 bytes allocated, 2.63% gc time)


*julia **blas_set_num_threads(4);@time eigfact(M);*

elapsed time: 2.062847561 seconds (79997048 bytes allocated)

On Monday, July 13, 2015 at 4:33:56 AM UTC+10, Evgeni Bezus wrote:

 Hi all,

 I am a Julia novice and I am considering it as a potential alternative to 
 MATLAB.
 My field is computational nanophotonics and the main numerical technique 
 that I use involves multiple solution of the eigenvalue/eigenvector problem 
 for dense matrices with size of about 1000*1000 (more or less).
 I tried to run the following nearly equivalent code in Julia and in MATLAB:

 Julia code:

 n = 1000
 M = rand(n, n)
 F = eigfact(M)
 tic()
 for i = 1:10
 F = eigfact(M)
 end
 toc()


 MATLAB code:

 n = 1000;
 M = rand(n, n);
 [D, V] = eig(M);
 tic;
 for i = 1:10
 [D, V] = eig(M);
 end
 toc

 It turns out that MATLAB's eig() runs nearly 2.3 times faster than eig() 
 or eigfact() in Julia. On the machine available to me right now (relatively 
 old Core i5 laptop) the average time for MATLAB is of about 37 seconds, 
 while the mean Julia time is of about 85 seconds. I use MATLAB R2010b and 
 Julia 0.3.7 (i tried to run the code both in Juno and in a REPL session and 
 obtained nearly identical results).

 Is there anything that I'm doing wrong?

 Best regards,
 Evgeni



[julia-users] Re: eig()/eigfact() performance: Julia vs. MATLAB

2015-07-12 Thread Sheehan Olver
Sorry, forgot the timing with the default number of threads.

*julia **@time eigfact(M);*

elapsed time: 2.261110895 seconds (79997048 bytes allocated, 2.05% gc time)

On Monday, July 13, 2015 at 10:19:33 AM UTC+10, Sheehan Olver wrote:

 I remember seeing this same performance gap before.  I believe the problem 
 is that OpenBLAS doesn't have the correct thread defaults. Here are other 
 timings setting the threads directly:

 *julia **blas_set_num_threads(1)*


 *julia **@time eigfact(M);*

 elapsed time: 1.827510669 seconds (79997048 bytes allocated, 1.88% gc time)


 *julia **blas_set_num_threads(2)*


 *julia **@time eigfact(M);*

 elapsed time: 1.549618631 seconds (79997048 bytes allocated)


 *julia **blas_set_num_threads(3);@time eigfact(M);*

 elapsed time: 1.498852226 seconds (79997048 bytes allocated, 2.63% gc time)


 *julia **blas_set_num_threads(4);@time eigfact(M);*

 elapsed time: 2.062847561 seconds (79997048 bytes allocated)

 On Monday, July 13, 2015 at 4:33:56 AM UTC+10, Evgeni Bezus wrote:

 Hi all,

 I am a Julia novice and I am considering it as a potential alternative to 
 MATLAB.
 My field is computational nanophotonics and the main numerical technique 
 that I use involves multiple solution of the eigenvalue/eigenvector problem 
 for dense matrices with size of about 1000*1000 (more or less).
 I tried to run the following nearly equivalent code in Julia and in 
 MATLAB:

 Julia code:

 n = 1000
 M = rand(n, n)
 F = eigfact(M)
 tic()
 for i = 1:10
 F = eigfact(M)
 end
 toc()


 MATLAB code:

 n = 1000;
 M = rand(n, n);
 [D, V] = eig(M);
 tic;
 for i = 1:10
 [D, V] = eig(M);
 end
 toc

 It turns out that MATLAB's eig() runs nearly 2.3 times faster than eig() 
 or eigfact() in Julia. On the machine available to me right now (relatively 
 old Core i5 laptop) the average time for MATLAB is of about 37 seconds, 
 while the mean Julia time is of about 85 seconds. I use MATLAB R2010b and 
 Julia 0.3.7 (i tried to run the code both in Juno and in a REPL session and 
 obtained nearly identical results).

 Is there anything that I'm doing wrong?

 Best regards,
 Evgeni



[julia-users] Re: eig()/eigfact() performance: Julia vs. MATLAB

2015-07-12 Thread John Myles White
http://julia.readthedocs.org/en/release-0.3/manual/performance-tips/

On Sunday, July 12, 2015 at 8:33:56 PM UTC+2, Evgeni Bezus wrote:

 Hi all,

 I am a Julia novice and I am considering it as a potential alternative to 
 MATLAB.
 My field is computational nanophotonics and the main numerical technique 
 that I use involves multiple solution of the eigenvalue/eigenvector problem 
 for dense matrices with size of about 1000*1000 (more or less).
 I tried to run the following nearly equivalent code in Julia and in MATLAB:

 Julia code:

 n = 1000
 M = rand(n, n)
 F = eigfact(M)
 tic()
 for i = 1:10
 F = eigfact(M)
 end
 toc()


 MATLAB code:

 n = 1000;
 M = rand(n, n);
 [D, V] = eig(M);
 tic;
 for i = 1:10
 [D, V] = eig(M);
 end
 toc

 It turns out that MATLAB's eig() runs nearly 2.3 times faster than eig() 
 or eigfact() in Julia. On the machine available to me right now (relatively 
 old Core i5 laptop) the average time for MATLAB is of about 37 seconds, 
 while the mean Julia time is of about 85 seconds. I use MATLAB R2010b and 
 Julia 0.3.7 (i tried to run the code both in Juno and in a REPL session and 
 obtained nearly identical results).

 Is there anything that I'm doing wrong?

 Best regards,
 Evgeni