Can't get speed up !
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I've just learned about Matlab Parallel Computing Toolbox. I'm studying about it. In the beginning and for taking motivation i tried some simple codes to get speed up. But all of my parallel results were worse than serial ones. I know about overhead of data communication between cores. So i wrote a code that have least data communication but likewise before the parallel execution time was longer than serial. I execute parallel code on two workers. My CPU is Intel Core 2 Duo 2.26 Ghz. CPU usage is 100% while running parallel code and 50% while running serial code.
I also tried a code that i found in net. The writer had claimed speed of for the code is 1.92 using 2 workers. But i got 0.96 !
I'm so disturbed!
2 个评论
回答(2 个)
john
2012-12-2
2 个评论
Walter Roberson
2012-12-2
Try reversing the order of the subscripts, producing a 4 million by 2 output, so that there would not be any cache-line contention. Also, try vectorizing, e.g.,
A(j, :) = sin(j + (1:4000000));
with no "for k" loop.
john
2012-12-2
编辑:john
2012-12-2
6 个评论
Walter Roberson
2012-12-29
Those machines haven't been sold for a number of years. And MATLAB has not been supported on them for a fair number of releases.
Bradley Stiritz
2013-1-22
Regarding Walter's 12/2/2012 comment, I requested documentation reference from Mathworks support & received this reply:
------------------------------------------------
"While working with MATLAB in general and also with PCT, row-wise access in same column will be faster than column-wise access in same row. This is because, in MATLAB, matrix elements belonging to the same column are located in consecutive locations of memory, while elements belonging to the same row of the matrix are located in non-consecutive locations of memory.
The following link from the Mathworks website highlights the above mentioned fact and also provides additional information on "Speeding up MATLAB Applications"
Also, please see the following MATLAB Documentation link for additional details on profiling and improving parallel code:
Unfortunately, we cannot recommend any books. However, it would be highly recommended to go through the webinars mentioned in the link below:
------------------------------------------------
Hope this helps..
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!