amdgcn: Align "omp simd array" variables, and cap vector alignment
Vector alignment for 'omp simd array' variables improved for AMD GCN.
This patch improves performance on AMD GCN targets by over-aligning ‘omp simd array’ variables to 256 bytes, up to a maximum. These variables, often used for SIMD reductions, are accessed as vectors but declared as arrays, leading to suboptimal alignment. Benchmarks show significant speedups in dot product kernels, with double-precision bandwidth increasing from 565 GB/s to 630 GB/s. The patch also caps vector type alignment to 256 bytes, preventing stack space waste from excessive natural alignments.
In Details
For AMD GCN targets, this change enhances LOCAL_DECL_ALIGNMENT for variables used in SIMD reductions (e.g., omp simd array accumulators). These are treated as vectors by the vectorizer but are fundamentally array types. The patch aims to align these arrays to a multiple of their element size, up to 256 bytes, if it provides a benefit over natural alignment (128 bytes for s64, f64; 64 bytes for s32, f32). This is achieved at runtime via GCN_VECTOR_STACK_ALIGNMENT. Additionally, TARGET_VECTOR_ALIGNMENT is capped at 256 bytes to prevent over-alignment of vector types, which can w…
- omp simd array
- In OpenMP, an array variable that is treated as a single unit within a SIMD (Single Instruction, Multiple Data) construct. This allows for vectorized operations on the array elements.
- SIMD reduction
- A parallel programming technique where multiple threads or lanes perform an operation (like addition or multiplication) on a set of data, accumulating a single result. SIMD allows this to happen across multiple data elements simultaneously using specialized processor instructions.
- GCN
- Graphics Core Next, AMD's architecture for their Graphics Processing Units (GPUs).
- LOCAL_DECL_ALIGNMENT
- A GCC target hook that controls the alignment of local variables declared within a function.
- TARGET_VECTOR_ALIGNMENT
- A GCC target hook that specifies the maximum alignment for vector types supported by the target architecture.