【发布时间】:2017-03-13 04:13:40
【问题描述】:
可能有一个简单的解决方案,但目前我无法理解它。也许有人可以帮助我。
所以我有以下问题:
我总共有N SAS 工作要完成。由于我机器上的资源太有限,无法同时启动所有N 作业,我只想同时开始说k = 5。每次完成一项工作,我都想开始下一项工作。作业完成的顺序并不重要。
目前,我让所有 k=5 工作在我开始下一个 5 之前完成。
所以这是我目前正在做的伪代码:
/*The following macro starts k threads*/
%macro parallel_processing(k);
options fullstimer autosignon=yes sascmd="sas -nonews -threads";
%global thread jj idlist;
/*These are the N ID numbers for the jobs*/
%let idlist = 1 2 3 4 5 ... N;
%let jj = 0;
%do %until(&jj.=N);
%do thread = 1 %to &k.;
%let jj = %eval(&thread.+&jj.);
%syslput thread = &thread;
%syslput jj = &jj.;
%syslput idlist = &idlist.;
rsubmit process=task&thread. wait=no sysrputsync=yes;
%let id =%scan(%trim(&idlist.),&jj.);
/*Do the job*/
%job(id);
endrsubmit;
%end;
/* HERE IS MY PROBLEM:
I want to wait for each job separately, and start a new one
with an increased id. So that constantly k threads are busy.
*/
/* Wait for all threads to finish */
waitfor _all_ %do thread = 1 %to &k.;
task&thread
%end;
/* GET RESULTS FROM THREADS */
%do thread = 1 %to (&k.);
rget task&thread;
%end;
/* SIGNOFF THREADS*/
%do thread = 1 %to (&k.);
signoff task&thread;
%end;
%end;
%mend parallel_processing;
%parallel_processing(k);
也许有人有个好主意,我将不胜感激!提前谢谢你。
【问题讨论】: