matlab 的并行运算

主要是想在server上实现 matlab 的 并行运算,问了一些人,大概有两个思路。(p.s. server上是 linux 系统)

“有两种方式,一种是bash parallel processing,需要提前计算好程序的动态CPU和内存使用率在分配核心,否则会出现进程假死。另一种是MATLAB的并行,用spmd或parfor,根据具体代码修改。"

最首先是关于 matlab parallel processing 的定义,一些关于 parfor loop 的使用说明,以及 已有的 toolbox,还有一些exercise

http://people.sc.fsu.edu/~jburkardt/m_src/matlab_parallel/matlab_parallel.html

也有matlab自身 的电子书

https://www.mathworks.com/help/pdf_doc/distcomp/distcomp.pdf

下面是一篇blog写的,其中提到用 bash 计算,以及用  parfor loop 的方式进行编程

http://blog.csdn.net/jiandanjinxin/article/details/50697508

下面是一个 关于 使用 parfor loop或者 matlabpool的 cmd 的guide

http://blog.csdn.net/ylf13/article/details/17608399


an example on Youtube

1 type cmd 'matlabpool open num'

 the number means how many cores to open

use the  cmd matlabpool close to end it

2 parfor loop

use this loop to cover the  for loop

the cmd are as below

clear all
close all
clc
 
% matlabpool open 4
 
a= rand (1e6,1);
b= rand (1e6,1);
c=zeros(size(a));
 
 
tic
tstart=tic;
for i=1:length(a)
     c(i)=a(i)+b(i);
end
t_normal_for=toc(tstart)
 
tstart=tic;
parfor i=1:length(a)
     c(i)=a(i)+b(i);
end
t_parfor=toc(tstart)
 
% matlabpool close


3 download the  parallel computing toolbox

GPU running


4 can use the batch in matlab


5 use the spmd (single program multiple data)

when use spmd, preferred to use the switch case  or if else

for each case, specified as each worker


6 use the gpu code

2 functions: arrayfun pagefun

esp. for single cmd line

gpuArray: to transfer the cpu data to the gpu data

after calculation, should transfer the gpu data to the cpu data






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值