8.5.3. Runtime Thread Control - 8.5.3. Runtime Thread Control - 5.3 English - 57404

AOCL User Guide (57404)

Document ID
57404
Release Date
2026-05-13
Version
5.3 English

AOCL-DLP provides comprehensive runtime control over threading behavior through environment variables and API calls.

AOCL-DLP Threading Variables:

Variable

Type

Description

Example Values

DLP_NUM_THREADS

Integer

Sets total number of threads for GEMM operations

1, 4, 8, 16

DLP_IC_NT

Integer

Number of threads for inner loop parallelization (IC dimension)

1, 2, 4

DLP_JC_NT

Integer

Number of threads for outer loop parallelization (JC dimension)

1, 2, 4

Note: When both DLP_IC_NT and DLP_JC_NT are set, DLP_NUM_THREADS is ignored.

OpenMP Environment Variables:

When using OpenMP threading model, these variables affect performance:

Variable

Type

Description

Example Values

OMP_NUM_THREADS

Integer

Number of OpenMP threads

1, 4, 8, 16

OMP_PROC_BIND

String

Thread affinity policy

close, spread, true

OMP_PLACES

String

Thread placement specification

cores, sockets, threads

OMP_WAIT_POLICY

String

Thread wait policy for better performance

active, passive

Additional Environment Variables:

Variable

Description

Example

AOCL_ENABLE_INSTRUCTIONS

Force specific instruction set, overriding auto-detection. See Dynamic Dispatch for the full list of supported values.

avx512, zen4

AOCL_ENABLE_LPGEMM_LOGGER

Enable detailed logging for low-precision GEMM operations. This variable only takes effect if the library is built with DLP_ENABLE_LOGGING=ON. Logs are written to files with pattern aocl_lpgemm_P<pid>_T<tid>.log.

1, true, yes

Usage Examples:

Basic Threading Configuration:

# Set 8 threads for all GEMM operations
export DLP_NUM_THREADS=8
./your_application

# Use 2x4 thread decomposition (2 for JC, 4 for IC)
export DLP_JC_NT=2
export DLP_IC_NT=4
./your_application

OpenMP Optimization for NUMA Systems:

# Multi-socket systems - bind to specific NUMA node with interleaved memory
# Example: 128 cores total, using second socket (cores 64-127, NUMA node 1)
export OMP_WAIT_POLICY=active
export OMP_NUM_THREADS=128
export OMP_PLACES=cores
export OMP_PROC_BIND=close
numactl --cpunodebind=1 --interleave=1 ./your_application

# Alternative: Bind to specific core range
export OMP_WAIT_POLICY=active
export OMP_NUM_THREADS=64
export OMP_PLACES=cores
export OMP_PROC_BIND=close
numactl -C 64-127 --interleave=1 ./your_application

# Single-socket systems - keep threads and memory local
export OMP_WAIT_POLICY=active
export OMP_PROC_BIND=close
export OMP_PLACES=cores
export OMP_NUM_THREADS=16
numactl --cpunodebind=0 --membind=0 ./your_application

Recommended Production Command:

For optimal AOCL-DLP performance on multi-socket systems, use the following comprehensive command template:

# Optimal configuration for second socket with 128 cores
# Adjust OMP_NUM_THREADS based on your system's core count per socket
OMP_WAIT_POLICY=active \
OMP_NUM_THREADS=128 \
OMP_PLACES=cores \
OMP_PROC_BIND=close \
numactl --cpunodebind=1 --interleave=1 \
./your_application

API-Based Thread Control:

AOCL-DLP provides runtime APIs for thread control at two levels:

Thread-local APIs (affect only the calling thread – highest precedence):

#include "aocl_dlp.h"

// Set total number of threads (thread-local)
dlp_thread_set_num_threads(8);

// Set 2D thread decomposition: JC=2, IC=4 (thread-local)
dlp_thread_set_ways(2, 4);

Library-global APIs (affect all threads in the process):

// Set total number of threads (process-wide)
dlp_thread_set_num_threads_library(8);

// Set 2D decomposition (process-wide)
dlp_thread_set_ways_library(2, 4);

Query APIs (get active configuration):

// Get active thread count
md_t active_threads = dlp_thread_get_num_threads_active();

// Get active JC and IC ways
md_t jc = dlp_thread_get_jc_ways_active();
md_t ic = dlp_thread_get_ic_ways_active();

For comprehensive performance optimization strategies and detailed tuning information, refer to the Performance Guide Wiki and the Environment Variables Wiki.