content_image/970669.jpg
<img src='content_image/970669.jpg'>

## Specifying the number of OpenMP threads 

OpenMP applications are often written so that they can create an arbitrary number of threads. In this case, the user sets the OMP_NUM_THREADS environment variable to specify the number of threads to create. For example, to run the application with 20 threads, use this command: 

export OMP_NUM_THREADS=20 

Again, the application can control the scheduling policy from the source code, as shown in the following example: 

#pragma omp parallel ... num_threads(4) 

## Showing OpenMP data 

The OpenMP 4.5 standard introduced the OMP_DISPLAY_ENV  environment variable to display the OpenMP version and list the internal control variables (ICVs). The OpenMP run time prints data to the stderr  output stream. If the user sets the value to TRUE , the OpenMP version number and initial values of ICVs are printed. 

The VERBOSE  value instructs the OpenMP run time to augment the output with the values of vendor-specific variables. If the value of this environment variable is set to FALSE  or undefined, no information is printed. This variable is useful when you must be certain that the runtime environment is configured as expected at the moment that the program loads. 

## Placement of OpenMP threads 

The POWER9 processor can handle multiple hardware threads simultaneously. With the increasing number of logical processors, the operating system (OS) kernel scheduler has more possibilities for automatic load balancing. For technical computing workloads, the fixed position of threads within the server is typically preferred. 

The IDs of the logical processors are zero-based. Each logical processor has the same index, regardless of the simultaneous multithreading (SMT) mode. Logical processors are counted starting from the first core of the first socket. The first logical processor of the second core features the index 4. Number the logical processors of the second socket only after you finish the numbering of the logical processors of the first socket. 

