BullseyeCoverage Up Contents Search

OpenMP Performance Degradation

Symptoms

Instrumented code that uses OpenMP compiler directives exhibits poor performance. This is despite CPU performance monitoring showing high processor utilization.

Performance may be worse than when the code is compiled with OpenMP disabled.

Cause

The BullseyeCoverage instrumentation writes to memory that is shared among all threads. Accessing the same memory locations from multiple threads causes severe CPU cache performance degradation, due to false sharing.

This effect may be so severe that the overhead of the OpenMP implementation is not offset by parallelizing.

Resolution

Exclude the performance-critical code from instrumentation, as well as any functions called from the performance-critical code.

For example,

#pragma BullseyeCoverage save off
void f(double d) {
	...
}

void g() {
	#pragma omp parallel for
	for (size_t i = 1; i < n; i++) {
		f(a[i]);
	}
}
#pragma BullseyeCoverage restore

Updated: 12 Feb 2026