Site Tools


fdtd-openmp-single-thread-execution

Single-thread execution (1D FDTD)

Single-thread execution handles work that must happen once per time step inside the parallel kernel. FDTD OpenMP uses omp single after the electric-field update:

#pragma omp single
{
    Fdtd_EzSourcesApply(sim->fsim_sources, sim);
    Fdtd_EzStateNextStep(sim->fsim_state);
}

One thread executes this block. OpenMP does not require it to be the initial thread or the same thread on every step. The other threads skip the block and wait at its implicit closing barrier.

Source application invokes the registered callbacks in order. Executing them once prevents each thread from adding the same source contribution again. Advancing the shared time counter once likewise keeps the simulation clock consistent.

The barrier after the electric loop ensures that field updates finish before this block runs. The barrier after single ensures that the next step sees the completed source contributions and updated clock. This serial work contributes to the scaling limit described by Amdahl's law.

fdtd-openmp-single-thread-execution.md · Last modified: by 127.0.0.1