What is the difference between atomic and critical in OpenMP?
问题 What is the difference between atomic and critical in OpenMP? I can do this #pragma omp atomic g_qCount++; but isn\'t this same as #pragma omp critical g_qCount++; ? 回答1: The effect on g_qCount is the same, but what's done is different. An OpenMP critical section is completely general - it can surround any arbitrary block of code. You pay for that generality, however, by incurring significant overhead every time a thread enters and exits the critical section (on top of the inherent cost of