Using parfor to Solve System of Linear Equations

3 次查看(过去 30 天)
I am trying to solve a system of linear equations for N different cases. Let's say N=140. So at each iteration, there is a portion of my code, where I want to do X = A\b;.
However, I am aware to a beginner's level that A\b implements parallelization when the matrices are sufficiently large. Would adding this loop:
parfor i=1:140
... % set A and b and other book-keeping stuff
X = A\b;
end
make things slower? My A matrix is around 500,000 x 7000 and b is 500,000 x 1, so I am pretty sure that A\b already uses parallelization, but I want to see if there is anyway to improve the operating speed of this overall computation.
  1 个评论
Edric Ellis
Edric Ellis 2016-9-23
It is almost certain that using parfor will actually make this slower - assuming you have access only to the 'local' cluster type. That's because as you observe, A\b is already implicitly multithreaded by MATLAB. The workers run in single-computational-thread mode, so even disregarding data transfer overheads, they can't perform faster than the multi-threaded client. The data transfer overheads will simply serve to slow things down. (If you have access to a remote cluster, the situation is different because there you'll have the opportunity to use more computational resources).

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel Computing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by