我寫了一個代碼由matlab和我已經使用並行計算工具箱 更多關於我的代碼的描述: 我試圖通過matlab和並行實現並行遺傳算法計算工具箱。由parfor並行代碼比串行版本慢
我已經實現了,但我有一個問題。那是我用parfor編寫的並行代碼比使用for編寫的代碼慢得多。
我的代碼:
tic
for j=1:maxIteration
parfor i=1:numIslands
if migrationInterval
doMigration;
end
doCrossover;
doMutation;
newSpring;
end
end
toc
numIslands
總是少數(5〜12) maxiteration
始終是很大的數字(1500〜5000) 請幫我 謝謝
我的電腦有兩個內核的CPU – monir
當你運行['gcp'](http://www.mathworks.com/help/distcomp/gcp.html)'('nocreate')時你會得到什麼。 NumWorkers'?如果您在循環之前添加['parpool'](http://www.mathworks.com/help/distcomp/parpool.html)'(2);',您的計時結果會發生變化嗎? –
你能否包括你的泳池設置細節?另外什麼是'migrationInterval'?什麼決定它是真是假? – Matt