设置使用的CPU核心数目

  1. myCluster = parcluster('local');
  2. myCluster.NumWorkers = 4; % 'Modified' property now TRUE
  3. saveProfile(myCluster); % 'local' profile now updated,
  4. % 'Modified' property now FALSE
  1. if isempty(gcp)
  2. distcomp.feature('LocalUseMpiexec', false);
  3. c = parcluster;
  4. pool = parpool(c.NumWorkers);
  5. end

设置进程池的数量

  1. CoreNum=6; %设定机器CPU核心数量
  2. if isempty(gcp('nocreate')) %如果并行未开启
  3. parpool(CoreNum);
  4. end