Home Knowledge Base OpenMP (Open Multi-Processing)

OpenMP (Open Multi-Processing) is the directive-based shared-memory parallel programming API that enables incremental parallelization of sequential C/C++/Fortran programs by inserting compiler pragmas — where a single #pragma omp parallel for can parallelize a loop across all available CPU cores with minimal code change, making it the most widely-used approach for shared-memory parallelism in scientific computing, simulation, and performance-critical applications.

Execution Model

OpenMP follows the fork-join model:

Key Directives

// Parallel loop — most common usage
#pragma omp parallel for schedule(dynamic, 64) reduction(+:sum)
for (int i = 0; i < N; i++) {
    sum += compute(data[i]);
}

// Task parallelism — dynamic, irregular workloads
#pragma omp parallel
#pragma omp single
for (node* p = head; p; p = p->next) {
    #pragma omp task firstprivate(p)
    process(p);
}
#pragma omp taskwait

Data Scoping

Scheduling Strategies

ScheduleDistributionBest For
staticFixed chunks (N/P per thread)Uniform work per iteration
dynamicOn-demand chunks from queueVariable work per iteration
guidedDecreasing chunk sizesMixed uniform/variable
autoCompiler/runtime choiceLet implementation decide

Advanced Features (OpenMP 5.0+)

OpenMP is the pragmatic on-ramp to parallel computing — enabling performance-critical loops and algorithms to exploit multicore hardware through incremental, directive-based parallelization that preserves the readability and maintainability of the original sequential code.

openmp programmingpragma omp parallelopenmp shared memoryopenmp directiveloop parallelism openmp

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.