Table of Contents

Loop parallelization (2D FDTD)

Loop parallelization assigns different rows of a field update to different CPU threads. In FDTD CUDA's OpenMP v1 implementation, the magnetic and electric phases each use a static work-sharing loop:

#pragma omp for schedule(static)
for (std::size_t j = 0; j < rows; ++j) {
    stepper.h_phase(j, n);
}

One parallel region surrounds the time-stepping loop, so a new thread team is not created for every phase. Static scheduling assigns chunks of rows predictably, which suits the regular work of the grid.

The implicit barrier at the end of the magnetic loop ensures that all magnetic updates finish before the electric loop starts. The electric loop's barrier then completes the step before the next magnetic phase. Removing either barrier would allow threads to read values from the wrong time step.

This distributes rows across cores. SIMD separately handles multiple columns within each thread.