how can I write a parallel code in Matlab?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
sasa
am 1 Aug. 2014
Beantwortet: Edric Ellis
am 4 Aug. 2014
hi every one, can you help me to write a program with parfor and compare the time consumed in comparing with for? The code is: matlabpool open local 7 tic parfor i = 1:100000 k=i end toc matlabpool close Elapsed time is 1.846197 seconds.
tic,for i = 1:100000 k=i end toc Elapsed time is 0.000640 seconds.
0 Kommentare
Akzeptierte Antwort
Dima Lisin
am 1 Aug. 2014
The reason you are seeing this result is because your loop does not do anything. If you make each iteration of your loop do substantial work, you will see a speedup.
Weitere Antworten (1)
Edric Ellis
am 4 Aug. 2014
Ideally, you should not open and close the pool for timing purposes - it's intended that you keep the pool open.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!