前几天研究了MATLAB的代码优化,今天来研究一下MATLAB的并行编程(Parallel Programming)。
概念:client & workers
Start up MATLAB in the regular way. This copy of MATLAB that you start with is called the “client” copy; the copies of MATLAB that will be created to assist in the computation are known as “workers”.一些函数:
- matlabpool
>>matlabpool open local 4 >>your_code.m >>matlabpool close
上面的4表示机器的核数,而不是线程数;这里的数字可以<=Num(内核)
- pctRunOnAll
%Clear all loaded functions on all labs >> pctRunOnAll clear functions %