SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irmst_node_set_cardinality_byn.sas
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 SAS Institute Inc. Cary, NC, USA
3*/
4
5/** \file
6 \brief Compute cardinality for parallel IRM execution
7
8 \param[in] n_partitions Macro variable (set via the IRM macrovarload facility) specifying the number of requested partitions. Valid options: MAX, AUTO, <N>. See below for details.
9 \param[in] ds_in Input table to be partitioned
10 \param[out] ds_out_cardinality Output IRM cardinality table
11
12
13 \details
14
15 This node sets the number of data partitions for enabling IRM parallel processing:
16 - If <i>N_PARTITIONS = MAX</i>, the cardinality is set to the total number of available CPUs (as returned by &SYSNCPU)
17 - If <i>N_PARTITIONS = AUTO</i>, the cardinality is set to 80% of the total number of available CPUs
18 - If <i>N_PARTITIONS = <value></i>, the cardinality is set to the specified value
19
20
21 In addition the following macro utilities are called:
22
23 | Macro name | Description | Further information |
24 |---------------------------|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------|
25 | irm_session_prepare | Reads RUN_OPTION table and sets logging options | \link irm_session_prepare.sas \endlink |
26 | irm_session_cleanup | Removes all non-IRM WORK datasets/views and deletes all user-created macro variables from workspace session | \link irm_session_cleanup.sas \endlink |
27
28 \ingroup nodes
29 \author SAS Institute Inc.
30 \date 2018
31*/
32
33/* Initialize session */
34%irm_session_prepare();
35
36
37/* ****************************************************************** */
38/* Compute cardinality for parallel execution */
39/* ****************************************************************** */
40
41/* Number of records in the input table */
42%let TotRows = %rsk_attrn(&ds_in., nobs);
43
44/* Determine parallelization level */
45data &ds_out_cardinality.;
46 length
47 PARTITION_CONFIG $20.
48 MAX_RANK_NO 8.
49 ;
50 PARTITION_CONFIG = strip(symget("N_PARTITIONS"));
51 /* Total number of available CPU cores */
52 CPU_CNT = &sysncpu.;
53 /* Total number of records */
54 TOT_ROWS = &TotRows.;
55
56 /* Check if PARTITION_CONFIG is a number */
57 if(prxmatch("/^\d+/i", PARTITION_CONFIG)) then
58 /* Read the number of partition, set the floor to 1 */
59 MAX_RANK_NO = max(1, input(PARTITION_CONFIG, 8.));
60 else if(upcase(PARTITION_CONFIG) in ("ALL", "MAX")) then
61 /* Use all CPU cores */
62 MAX_RANK_NO = CPU_CNT;
63 else do;
64 /* Limit the CPU count to 80% of the available CPU cores */
65 CPU_CNT = round(&sysncpu. * 0.8);
66 /* Number of records for each partition (closest integer) */
67 ROWS_x_PARTITION = round(TOT_ROWS/CPU_CNT);
68 /* Check if we exceed the total number of rows */
69 if(ROWS_x_PARTITION * CPU_CNT > TOT_ROWS) then
70 /* Reduce the number of partitions: the last partition will always have more records to process */
71 MAX_RANK_NO = floor(TOT_ROWS/ROWS_x_PARTITION);
72 else
73 /* Default: use 80% of the available CPU cores */
74 MAX_RANK_NO = CPU_CNT;
75 end;
76
77 /* Make sure the number of partitions does not exceed the number of records to be processed */
78 MAX_RANK_NO = max(min(MAX_RANK_NO, TOT_ROWS), 1);
79run;
80
81
82/* Cleanup session */
83%irm_session_cleanup;