RWalib C Array Library User Guide > Performance Utilities > alibinit
  

alibinit
Initializes performance parameters. For some background, see RWalib Introduction. This must be the first call to RWalib.
Prototype
void alibinit( wvlong *np, wvlong *tc, SYS_OMP *oe, SYS_CACHE *ce )
Parameters
*np — (Output) If not NULL on input, np points to the number of threads available on the host. Without hyper-threading (HT) or with HT disabled, this is the number of physical cores on the host, but with HT enabled it is twice the number of physical cores on the host.
*tc — (Output) If not NULL on input, tc points to a flag which if nonzero indicates that ATC is enabled. This flag is always returned as zero and is used only by PV-WAVE. ATC can be enabled with alibset().
*oe — (Output) If not NULL on input, oe points to a structure with wvlong fields named nthreads, threshold, and dynamic which correspond to the maximum number of threads for parallel operations, the minimum number of loop iterations for parallel operations, and a flag which if nonzero indicates that OpenMP dynamic threading is enabled. nthreads defaults to *np or OMP_NUM_THREADS if this environment variable is set, threshold defaults to 1000, and dynamic defaults to 0 or OMP_DYNAMIC if this environment variable is set. Each of these parameters can be adjusted at runtime with alibset().
*ce — (Output) If not NULL on input, ce points to a structure with wvlong fields named line, l1, l2, l3, and l4 which correspond to the number of bytes in a data-cache line and in the L1, L2, L3, and L4 data-caches, but the l4 field can be ignored if there is no L4 cache on the host. These values default to 64, 32768, 262144, 8388608, and 67108864 but can be changed with alibset().
Example
Here we call alibinit() on a 12-core hyper-threaded host and print the initial values for the parameters described above.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
    wvlong np;
    SYS_OMP oe;
    SYS_CACHE ce;
    alibinit( &np, NULL, &oe, &ce );
    printf( "%d\n", np );
    printf( "%d\n", oe.nthreads );
    printf( "%d\n", oe.threshold );
    printf( "%d\n", oe.dynamic );
    printf( "%d\n", ce.line );
    printf( "%d\n", ce.l1 );
    printf( "%d\n", ce.l2 );
    printf( "%d\n", ce.l3 );
    printf( "%d\n", ce.l4 );
}
 
Output:
 
24
24
1000
0
64
32768
262144
8388608
67108864

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.