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
>>>
>>

Reply via email to