Fix race condition in libgomp's GCN plugin async operations
Ensures correct completion detection for OpenACC async operations on AMD GPUs by holding a lock during placeholder signaling.
A race condition in libgomp’s GCN plugin could lead to incorrect detection of completed OpenACC async operations on AMD GPUs. This occurred when a queue’s drain thread signaled an async placeholder and then dequeued it, allowing a waiting thread to observe the queue as complete prematurely. The fix holds the queue lock during the signaling of the placeholder, making the signal and dequeue operations appear atomic to other threads and resolving intermittent test failures.
In Details
The libgomp GCN plugin's drain thread was susceptible to a race between signaling an async placeholder and dequeuing it. This allowed a consumer thread to see the queue as finished before the placeholder's actual work was complete, leading to spurious acc_async_test failures. By holding the queue lock across the signal and dequeue operations, this commit ensures that the state of the queue is consistent when observed by other threads, fixing a specific test case.