Table of Contents

Data sharing (1D FDTD)

Data sharing specifies which variables are shared among OpenMP threads and which have a separate instance per thread. FDTD OpenMP makes these choices explicit on its parallel region:

#pragma omp parallel \
    default(none) \
    firstprivate(Hy, Ez, Ch1, Ch2, Ce1, Ce2, width, nsteps) \
    shared(sim)

firstprivate gives each thread initialized copies of the array pointers, grid width, and step count. Copying a pointer copies its address, not the array it points to. All threads therefore still access the same fields and coefficients.

The sim pointer is shared so the source-processing code can access the common simulation object. The time-loop counter declared inside the region is private to each thread, and the work-sharing loop indices are private too.

default(none) requires explicit classification of applicable variables instead of relying on implicit sharing. It helps expose omissions, while correctness still depends on distinct write destinations and the barriers between phases.