Table of Contents
Restricted pointers (1D FDTD)
Restricted pointers tell a C compiler how memory is accessed through a pointer during its scope. FDTD OpenMP declares local pointers to its field and coefficient arrays with restrict in both simulation kernels:
Fdtd_FloatType * restrict Hy = sim->fsim_fields->ff_hy; Fdtd_FloatType * restrict Ez = sim->fsim_fields->ff_ez;
When an object is modified through a restricted pointer, accesses to that object must follow the corresponding restriction. The independently allocated field arrays satisfy the intended separation: updating Hy[k] does not also change an overlapping Ez element.
This information lets the compiler reason about dependencies without conservatively assuming that the field pointers overlap. It can help with instruction scheduling and automatic vectorization of the spatial loops. The kernels do not contain an explicit omp simd directive.
restrict does not allocate memory or perform a runtime overlap check. It is a promise that the implementation must honor, separate from the OpenMP rules for data sharing and synchronization between threads.
