HPSEVERITY Procedure

Example 21.6 Benefits of Multithreaded Computing

(View the complete code for this example.)

One of the key features of the HPSEVERITY procedure is that it takes advantage of the multithreaded computing machinery in order to solve a given problem faster. This example illustrates the benefits of using multithreaded computing.

The example uses a simulated data set Work.Largedata, which contains 10,000,000 observations, some of which are right-censored or left-truncated. The losses are affected by three external effects. The DATA step program that generates this data set is available in the accompanying sample program hsevex06.sas.

The following PROC HPSEVERITY step fits all the predefined distributions to the data in the Work.Largedata data set on the client machine with just one thread of computation:

/* Fit all predefined distributions without any multithreading 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;

The NTHREADS=1 option in the PERFORMANCE statement specifies that just one thread of computation be used. The BUFSIZE= option in the PERFORMANCE statement specifies the number of observations to read at one time. Specifying a larger value tends to decrease the time it takes to load the data. The DETAILS option in the performance statement enables reporting of the timing information. The INITSAMPLE option in the PROC HPSEVERITY statement specifies that a uniform random sample of maximum 20,000 observations be used for parameter initialization.

The "Performance Information" and "Procedure Task Timing" tables that PROC HPSEVERITY creates are shown in Output 21.6.1. The "Performance Information" table contains the information about the execution environment. The "Procedure Task Timing" table indicates the total time and relative time taken by each of the four main steps of PROC HPSEVERITY. As that table shows, it takes around 26.3 minutes for the task of estimating parameters, which is usually the most time-consuming of all the tasks.

Output 21.6.1: Performance with No Multithreading

Performance Information
Execution ModeSingle-Machine
Number of Threads1

Procedure Task Timing
TaskSecondsPercent
Load and Prepare Models4.570.29%
Load and Prepare Data10.360.65%
Initialize Parameters0.810.05%
Estimate Parameters1576.5198.93%
Compute Fit Statistics1.320.08%


If the grid appliance is not available, you can improve the performance by using multiple threads of computation; this is in fact the default. The following PROC HPSEVERITY step fits all the predefined distributions by using all the logical CPU cores of the machine:

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

/* Fit all predefined distributions with multithreading*/
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;

When you do not specify the NTHREADS= option in the PERFORMANCE statement, the HPSEVERITY procedure uses the value of the CPUCOUNT= system option to decide the number of threads to use. Setting the CPUCOUNT= option to ACTUAL before the PROC HPSEVERITY step enables the procedure to use all the logical cores of the machine. The machine that is used to obtain these results (and the earlier results in Output 21.6.1) has four physical CPU cores, each with a clock speed of 3.4 GHz. Hyperthreading is enabled on the CPUs to yield eight logical CPU cores; this number is confirmed by the "Performance Information" table in Output 21.6.2. The results in the "Procedure Task Timing" table in Output 21.6.2 indicate that the use of multithreading has improved the performance by reducing the time to estimate parameters to around 5.5 minutes.

Output 21.6.2: Performance with Eight Threads

Performance Information
Execution ModeSingle-Machine
Number of Threads8

Procedure Task Timing
TaskSecondsPercent
Load and Prepare Models0.750.22%
Load and Prepare Data1.060.31%
Initialize Parameters0.670.20%
Estimate Parameters332.0597.44%
Compute Fit Statistics6.251.83%


The computations and time taken to fit each model are shown in the "Estimation Details" table of Output 21.6.3, which is generated whenever you specify the DETAILS option in the PERFORMANCE statement. This table can be useful for comparing the relative effort required to fit each model and drawing some broader conclusions.

Output 21.6.3: Estimation Details

Estimation Details
DistributionConvergedIterationsFunction
Calls
Gradient
Updates
Hessian
Updates
Time
(Seconds)
BurrYes11281049040.91
ExpYes41227208.74
GammaYes515352799.51
IgaussYes412272024.99
LognYes412272017.67
ParetoMaybe5013714301377106.47
GpdYes617443517.82
WeibullYes412272015.95


Last updated: June 19, 2025