can I accelerate parfor loop running external code?
1 次查看(过去 30 天)
显示 更早的评论
Here is my question:
if I run following code, the toc time is 0.296749.
tic
lambda=1;
for k=1:lambda
filename_nam=sprintf('mf2005 test_%03d.nam',k);
[~,~]=system(filename_nam);
.
.
.
end
toc
Otherwise, if I run following code, the toc time is 12.920165. This result is reasonable because 0.296749 * 43 is approximately 12.9.
tic
lambda=43;
for k=1:lambda
filename_nam=sprintf('mf2005 test_%03d.nam',k);
[~,~]=system(filename_nam);
.
.
.
end
toc
Lastly, if I run following code, the toc time is 3.902111. This is obviously improvement by using parfor but I wonder if there is further way of improving the efficiency. In my parallel pool, I have 36 worker (36 core CPU) and the required memory for the exe code is very small compared to my 64Gb memory. The operating system is Windows 10. What is the limiting condition? code? a specific hardware? or any other?
tic
lambda=43;
parfor k=1:lambda
filename_nam=sprintf('mf2005 test_%03d.nam',k);
[~,~]=system(filename_nam);
.
.
.
end
toc
3 个评论
Walter Roberson
2020-4-2
You can test if a process started with .NET is still going, or you can wait for it (with an optional timeout)
Anyhow, typically the answer to the question of the limiting condition is either communications overhead or use of a limited resource (for example disk I/O bandwidth.)
回答(1 个)
Eungyu Park
2020-4-3
1 个评论
Walter Roberson
2020-4-4
Sometimes when multiple processes use a shared resource but do not each need 100% of the resource, then it can be beneficial to start a limited number of the processes and wait for one to finish before starting the next, so that there might be a small number of processes accessing the resource but not too many. This can reduce contention for the resource. This can be especially important for disc access.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!