fdtd-openmp-memory-alignment
Table of Contents
Memory alignment (1D FDTD)
Memory alignment places array storage at addresses suitable for regular machine accesses. FDTD OpenMP uses a 64-byte boundary and rounds allocations up before calling aligned_alloc():
size_t bytes = ((count * size + FDTD_ALIGN - 1) / FDTD_ALIGN) * FDTD_ALIGN; void *ptr = aligned_alloc(FDTD_ALIGN, bytes); assert(ptr != NULL); // Initialize to zero memset(ptr, 0, bytes);
FDTD_ALIGN is defined as 64. The rounding satisfies aligned_alloc()'s requirement that the allocation size be a multiple of the alignment. Zeroing initializes the full allocation, including padding.
Padding does not add grid cells: update loops still use the configured width. Alignment can help vectorized access, but shifted stencil reads such as Ez[k + 1] remain offset from the array base. It does not guarantee that the compiler vectorizes every operation.
Source: fdtd_alloc.c.
fdtd-openmp-memory-alignment.md · Last modified: by 127.0.0.1
