Benefits of Distributed and Multithreaded Computing

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: hsevex06.sas
 Description: Example program from SAS/ETS High Performance
              Procedures User's Guide, The HPSEVERITY Procedure
       Title: Benefits of Distributed and Multithreaded Computing
     Product: SAS High Performance Econometrics Software
        Keys: Severity Distribution Modeling
        PROC: HPSEVERITY
       Notes:

--------------------------------------------------------------*/

/*----- Lognormal Model with left-truncation and censoring -----*/
%let nobs = 10000000;
data largedata(keep=y x1-x3 threshold limit label=
   'Large Lognormal Sample With Censoring, Truncation, and External Effects');
   call streaminit(45678);
   label y='Censored & Truncated Response Affected by Regressors';
   array x{*} x1-x3;
   array b{4} _TEMPORARY_ (1 0.75 -1 0.25);
   Sigma = 0.25;
   do n = 1 to &nobs;
      Mu = b(1); /* log of base value of scale */
      do i = 1 to dim(x);
         x(i) = rand('UNIFORM');
         Mu = Mu + b(i+1) * x(i);
      end;
      y = exp(Mu) * rand('LOGNORMAL')**Sigma;

      /* make about 20% of the observations left-truncated */
      if (rand('UNIFORM') < 0.2) then
         threshold = y * (1 - rand('UNIFORM'));
      else
         threshold = .;

      /* make about 15% of the observations right-censored */
      iscens = (rand('UNIFORM') < 0.15);
      if (iscens) then
         limit = y;
      else
         limit = .;

      output;
   end;
run;

/* Fit all predefined distributions without any multithreading or
   distributed computing */
proc hpseverity data=largedata criterion=aicc initsample(size=20000);
   loss y / lt=threshold rc=limit;
   scalemodel x1-x3;
   dist _predef_;
   performance nthreads=1 bufsize=1000000 details;
run;

/* Specify that all the logical CPU cores on the machine be used */
options cpucount=actual;

/* Fit all predefined distributions with multithreading, but no
   distributed computing */
proc hpseverity data=largedata criterion=aicc initsample(size=20000);
   loss y / lt=threshold rc=limit;
   scalemodel x1-x3;
   dist _predef_;
   performance bufsize=1000000 details;
run;

/* Set the appliance host and installation location that are
   appropriate for your distributed mode setup */
option set=GRIDHOST      ="&GRIDHOST";
option set=GRIDINSTALLLOC="&GRIDINSTALLLOC";

/* Fit all predefined distributions on 1 grid node without
   any multithreading */
proc hpseverity data=largedata criterion=aicc initsample(size=20000);
   loss y / lt=threshold rc=limit;
   scalemodel x1-x3;
   dist _predef_;
   performance nodes=1 nthreads=1 details
      host="&GRIDHOST" install="&GRIDINSTALLLOC";
run;

/* Fit all predefined distributions on 1 grid node with multithreading */
proc hpseverity data=largedata criterion=aicc initsample(size=20000);
   loss y / lt=threshold rc=limit;
   scalemodel x1-x3;
   dist _predef_;
   performance nodes=1 nthreads=16 details
      host="&GRIDHOST" install="&GRIDINSTALLLOC";
run;

/* Fit all predefined distributions with distributed computing and
   multithreading within each node */
proc hpseverity data=largedata criterion=aicc initsample(size=20000);
   loss y / lt=threshold rc=limit;
   scalemodel x1-x3;
   dist _predef_;
   performance nodes=16 nthreads=16 details
      host="&GRIDHOST" install="&GRIDINSTALLLOC";
run;