error detects in labs in spmd

3 ビュー (過去 30 日間)
huda nawaf
huda nawaf 2014 年 1 月 24 日
コメント済み: huda nawaf 2014 年 1 月 28 日
hi,
I have problem with this code , I can not know what is the reason.
this error what I got:
Starting matlabpool using the 'local' configuration ... connected to 2 labs. Lab 2:
ans =
0
??? Error using ==> spmd_feval at 8 Error detected on lab(s) 2
Error in ==> test at 7 Nofusers=700;k1=1;
Caused by:
You must call TIC without an output argument before calling TOC
without an input argument.
Error stack:
(No remote error stack)
%%%the code%% clc;clear;close all;
N=2; % Number of your CPU core, in my case, 4
matlabpool(N) % open N multicores for the parallel computation
tic
spmd % similar with for loop
Nofusers=700;k1=1;
f=fopen('d:\matlab\r2011a\bin\data_net.txt');
for i=1:Nofusers
gl=fgetl(f);
celcod{i}=str2num(gl);
end
fclose all
toc
matlabpool close % you must close the multicore calculation statement
end
thanks

回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 1 月 24 日
Your nesting appears to be off. You have the "matlabpool close" and the "toc" before it inside the spmd block.
Each lab is effectively a different MATLAB session. The "tic" before the spmd block is not in the same session as the "toc" inside the spmd block.
  9 件のコメント
Walter Roberson
Walter Roberson 2014 年 1 月 28 日
Depend on the total time (6.215617)
Your semantic error appears to be repaired.
Was your task to observe "the difference in terms of time between code use spmd and other code do not use it" ? If so then you have done that. Or was your task to come up with some code that runs faster using spmd than with serial? Because if your task was to explain the timings then you should be studying the documentation about how spmd works.
huda nawaf
huda nawaf 2014 年 1 月 28 日
In fact, the last example to know which time I have to depend and why serial faster than parallel. But my problem in first code is to know if I used spmd correctly. thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by