The HPCANDISC Procedure

Example 51.2 Performing Canonical Discriminant Analysis in Single-Machine and Distributed Modes

(View the complete code for this example.)

PROC HPCANDISC shows its real power when the computation is conducted using multiple threads or in a distributed environment.

This example shows how you can run PROC HPCANDISC in single-machine and distributed modes. For more information about the execution modes of SAS high-performance analytics procedures, see the section Processing Modes in SAS/STAT 14.2 User's Guide: High-Performance Procedures. The focus of this example is to show how you can switch the modes of execution in PROC HPCANDISC. The following DATA step generates the data:

data ex2Data;
   drop i j n n1 n2 n3 n4;

   n  = 5000000;
   n1 = n*0.1;
   n2 = n*0.25;
   n3 = n*0.45;
   n4 = n*0.7;

   array x{100};

   do i=1 to n;
      do j=1 to dim(x);
         x{j} = ranuni(1);
      end;

      if      i <= n1 then z='small';
      else if i <= n2 then z='medium';
      else if i <= n3 then z='big';
      else if i <= n4 then z='verybig';
      else                 z='huge';

      output;
   end;
run;

The following statements use PROC HPCANDISC to perform a canonical discriminant analysis and to output various statistics to the stats data set (OUTSTAT= stats).

proc hpcandisc data=ex2Data outstat=stats;
   var x:;
   class z;
   performance details;
run;

Output 51.2.1 shows the "Performance Information" table. This table shows that the HPCANDISC procedure executes in single-machine mode on four threads, because the client machine has four CPUs. You can force a certain number of threads on any machine to be involved in the computations by specifying the NTHREADS= option in the PERFORMANCE statement.

Output 51.2.1: Performance Information in Single-Machine Mode

The HPCANDISC Procedure

Performance Information
Execution ModeSingle-Machine
Number of Threads4


Output 51.2.2 shows timing information for the PROC HPCANDISC run. This table is produced when you specify the DETAILS option in the PERFORMANCE statement. You can see that, in this case, the majority of time is spent reading, levelizing, and processing the data.

Output 51.2.2: Timing in Single-Machine Mode

Procedure Task Timing
TaskSecondsPercent
Reading, Levelizing, and Processing Data73.1599.26%
Computing SSCP and Covariance Matrices0.000.00%
Performing Canonical Analysis0.480.65%
Producing Output Statistics Data Set0.070.09%


To switch to running PROC HPCANDISC in distributed mode, specify valid values for the NODES=, INSTALL=, and HOST= options in the PERFORMANCE statement. An alternative to specifying the INSTALL= and HOST= options in the PERFORMANCE statement is to use the OPTIONS SET commands to set appropriate values for the GRIDHOST and GRIDINSTALLLOC environment variables. For information about setting these options or environment variables, see the section Processing Modes in SAS/STAT 14.2 User's Guide: High-Performance Procedures.

The following statements provide an example. To run these statements successfully, you need to set the macro variables GRIDHOST and GRIDINSTALLLOC to resolve to appropriate values, or you can replace the references to macro variables with appropriate values.

proc hpcandisc data=ex2Data outstat=stats;
   var x:;
   class z;
   performance details nodes = 4
               host="&GRIDHOST" install="&GRIDINSTALLLOC";
run;

The execution mode in the "Performance Information" table shown in Output 51.2.3 indicates that the calculations were performed in a distributed environment that uses four nodes, each of which uses 32 threads.

Output 51.2.3: Performance Information in Distributed Mode

Performance Information
Host Node<< your grid host >>
Install Location<< your grid install location >>
Execution ModeDistributed
Number of Compute Nodes4
Number of Threads per Node32


Another indication of distributed execution is the following message issued by all high-performance analytics procedures in the SAS log:

NOTE: The HPCANDISC procedure is executing in the distributed
      computing environment with 4 worker nodes.

Output 51.2.4 shows timing information for this distributed run of the HPCANDISC procedure. In contrast to the single-machine mode (where reading, levelizing, and processing the data dominated the time spent), the majority of time in the distributed mode run is spent distributing the data.

Output 51.2.4: Timing in Distributed Mode

Procedure Task Timing
TaskSecondsPercent
Obtaining Settings0.000.00%
Distributing Data61.5394.60%
Reading, Levelizing, and Processing Data3.124.79%
Computing SSCP and Covariance Matrices0.000.00%
Performing Canonical Analysis0.000.01%
Producing Output Statistics Data Set0.150.23%
Waiting on Client0.240.37%