OpenMP
**OpenMP SIMD Vectorization** is **compiler-guided generation of SIMD (Single Instruction Multiple Data) code that exploits vector hardware to process multiple data elements per instruction, achieving massive parallelism within single cores** — enabling 2x-8x speedups on data-parallel code. SIMD vectorization complements thread-level parallelism. **SIMD Pragmas and Directives** include #pragma omp simd enabling automatic vectorization of immediately following loops, with compiler choosing vector width (typically 4-8 elements for AVX/AVX2, up to 8-16 for AVX-512). Collapse clause (collapse(N)) vectorizes nested loops, enabling multidimensional vectorization. Schedule modifiers like simdlen specify explicit vector length. Data dependencies must be analyzed—compiler rejects vectorization if true dependencies exist. **Reduction Operations in SIMD Context** use reduction clause (reduction(+:var)) allowing SIMD-friendly accumulation across vector elements, then reducing partial results across loop iterations. Supported operations include arithmetic, logical, and user-defined operators. **Vector Data Types and Operations** with omp declare simd enable manual SIMD function definition, declaring function works correctly on vector data. Compiler generates multiple versions—scalar, 128-bit, 256-bit, 512-bit—caller can select via simd directive or compiler chooses automatically. **Alignment and Memory Access Patterns** optimize cache utilization and SIMD efficiency. Arrays should be aligned (align(64) for AVX-512), and loops should access memory in sequential, non-strided patterns. Aligned_load and aligned_store intrinsics bypass caches when appropriate. **Loop Transformations for Vectorization** include removing conditionals (predicated operations), scalar-to-vector conversions, and loop unrolling. Gather/scatter operations enable non-contiguous access but with significant overhead. **Interactive Vectorization Debugging** with compiler feedback (e.g., -fopt-info-missed in GCC) identifies loops that couldn't vectorize and reasons why. **Combining SIMD with thread parallelism creates heterogeneous parallelism—threads provide coarse-grained parallelism while SIMD provides fine-grained instruction-level parallelism** for maximum performance.