Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plain old multiplication much slower than Matlab 2013a #14576

Closed
bdqp opened this issue Jan 6, 2016 · 4 comments
Closed

Plain old multiplication much slower than Matlab 2013a #14576

bdqp opened this issue Jan 6, 2016 · 4 comments
Labels
performance Must go faster

Comments

@bdqp
Copy link

bdqp commented Jan 6, 2016

Julia 0.4:
julia> A=rand(3000,3000);B=rand(3000,3000);
julia> tic();for k=1:50;C=A.*B;end;toc()
elapsed time: 2.386786733 seconds
2.386786733

Matlab 2013a:

A=rand(3000);B=rand(3000);
tic;for k=1:50;C=A.*B;end;toc
Elapsed time is 1.501691 seconds.

This is on a 2 core machine. I also ran it on another computer with 6 cores and the difference is greater (about 4x). So it seems Matlab is using parallelism for .* while Julia isn't. A little experimentation in Matlab shows that it drops to 1 core when the matrix size is 191x191 or smaller.

@KristofferC
Copy link
Member

What is the issue here? Julia does not run multithreaded code yet so naturally it will be slower. Your best bet right now is the ParallelAccelerator.jl package.

@JeffBezanson
Copy link
Member

Duplicate of #1802

@iamed2
Copy link
Contributor

iamed2 commented Jan 7, 2016

in Julia 0.5 (it's roughly the same as 0.4):

julia> A=rand(3000,3000);B=rand(3000,3000);

julia> tic();for k=1:50;C=A.*B;end;toc()
elapsed time: 2.408215731 seconds
2.408215731

julia> tic();for k=1:50;C=A.*B;end;toc()
elapsed time: 1.662830871 seconds
1.662830871

MATLAB 2012b:

>> A=rand(3000);B=rand(3000);
tic;for k=1:50;C=A.*B;end;toc
Elapsed time is 1.429565 seconds.
>> tic;for k=1:50;C=A.*B;end;toc
Elapsed time is 1.455223 seconds.

Also on a 2 core machine. Seems like there is an initial compilation pass involved that is skewing the difference?

@kshyatt kshyatt added the performance Must go faster label Jan 7, 2016
@KristofferC
Copy link
Member

Closing as dup of #1802.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

No branches or pull requests

5 participants