由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Computation版 - MATLAB 并行计算问题
相关主题
Matlab problemNewton's method最后收敛速度很慢,求解释
fortran 基本命令求助,急Parallel computing in Matlab
发现一个有趣的事情,关于fortran IMSL library并行的算法
matlab parallel 编程Re: 急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
在matlab中如果快速地求矩阵的逆我也及问一个问题
optimization using matlab function fminconmy experience,Re: 我也及问一个问题
请教如何根据矩阵元素值找到矩阵的行号?3D FEM code
怎么拟合这样的曲线请教关于matlab benchmark
相关话题的讨论汇总
话题: dummy1话题: dummy2话题: runtimes话题: matlab话题: parfor
进入Computation版参与讨论
1 (共1页)
v****k
发帖数: 229
1
兄弟有几个 matlab 并行计算方面的问题,用他们提供的工具箱:
I just found a simple example online, see:
Without parallel computing:
runtimes = 1e9;
dummy1 = 0;
dummy2 = 0;
tic
for x= 1:runtimes;
dummy1 = dummy1 + x;
dummy2 = 2 * x + 1;
end
toc
with 2012b, it took about 4.8 seconds; but with matlab 2007b, it takes much
longer, about 20 minutes. why 2012 so much faster than 2007?
Next, with parallel computing, the code is like following, it takes 50
seconds. 为什么用并行计算反而慢这么多?
runtimes = 1e9;
dummy1 = 0;
dummy2 = 0;
matlabpool local 2
tic
parfor x= 1:runtimes;
dummy1 = dummy1 + x;
dummy2 = 2 * x + 1;
end
toc
matlabpool close
更奇怪的是,这段程序结束之后,发现 dummy2 还是0,就是说它没有更新!而且系统
不认识这个循环变量 x !!
这段程序是根据这个帖子改写的:http://blog.sciencenet.cn/blog-419879-444784.html
请指点迷津!谢了
k**********g
发帖数: 989
2
http://blogs.mathworks.com/loren/2009/10/02/using-parfor-loops-
"The parfor-loop is designed for task-parallel types of problems where each
iteration of the loop is independent of each other iteration. This is a
critical requirement for using a parfor-loop."
"Checking the above code using M-Lint (MATLAB's static code analyzer) gives
a warning message that these iterations are dependent and will not work with
the parfor construct. "
v****k
发帖数: 229
3
very useful information, will try it. thanks!

each
gives
with

【在 k**********g 的大作中提到】
: http://blogs.mathworks.com/loren/2009/10/02/using-parfor-loops-
: "The parfor-loop is designed for task-parallel types of problems where each
: iteration of the loop is independent of each other iteration. This is a
: critical requirement for using a parfor-loop."
: "Checking the above code using M-Lint (MATLAB's static code analyzer) gives
: a warning message that these iterations are dependent and will not work with
: the parfor construct. "

1 (共1页)
进入Computation版参与讨论
相关主题
请教关于matlab benchmark在matlab中如果快速地求矩阵的逆
请教Stabilized inverse diffusion equationoptimization using matlab function fmincon
请教1万个变量的线性方程组怎么解啊?请教如何根据矩阵元素值找到矩阵的行号?
[合集] ill conditioning怎么拟合这样的曲线
Matlab problemNewton's method最后收敛速度很慢,求解释
fortran 基本命令求助,急Parallel computing in Matlab
发现一个有趣的事情,关于fortran IMSL library并行的算法
matlab parallel 编程Re: 急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
相关话题的讨论汇总
话题: dummy1话题: dummy2话题: runtimes话题: matlab话题: parfor