八度并行代码示例

时间:2013-07-03 03:59:17

标签: parallel-processing cluster-computing octave

假设在群集中安装了八度音程的并行包,那么任何人都可以提供一个示例八度代码来提交到群集吗?我在说什么,我只是在Matlab并行计算工具箱中使用parfor,还是使用类似下面代码的东西?

n = 100000000;
s = 0;
% Initialize MPI
MPI_Init;
% Create MPI communicator
comm= MPI_COMM_WORLD;
% Get size and rank
size = MPI_Comm_size(comm);
rank= MPI_Comm_rank(comm);
master = 0;
% Split the for loop into size partitions
m = n / size;
r = mod(n, m);
if ( rank == size-1 )
    se = (rank + 1)*m + r;
else
  se = (rank + 1)*m;
end
% Each process works on a partition of the loop independently
s1 = s;
for i=(rank * m)+1:se
    s1 = s1 + i;
end
% print the partial summation on each process
disp(['Partial summation: ', num2str(s1), ' on process ', num2str(rank)]);

此代码来自链接中的教程
http://faculty.cs.tamu.edu/wuxf/talks/IAMCS-ParallelProgramming-2013-3.pdf

用于matlab和mpi。

非常感谢!

0 个答案:

没有答案