does mom_model.2 have data races?

Discuss the OpenMP Examples document, updated for OpenMP 5.0

does mom_model.2 have data races?

Postby sfsiegel » Mon May 18, 2020 6:26 pm

Here is the discussion of mem_model.2 in its entirety:
The following example demonstrates why synchronization is difficult to perform correctly through variables. The value of flag is undefined in both prints on thread 1 and the value of data is only well-defined in the second print.

But isn't it true that all accesses to shared variables in this example are involved in data races? I assumed this was the case, because there are no release or acquire flushes (neither explicit nor implicit), and therefore no happens-before ordering between operations from different threads.

My understanding is that if an execution has two threads accessing the same variable, at least one of the accesses is a write, they are not both atomic, and neither operation "happens before" the other, then there is a data race. If that's not right, I'd like to know.
Posts: 12
Joined: Mon Mar 24, 2014 4:47 pm

Return to OpenMP 5.0 Examples Discussion

Who is online

Users browsing this forum: No registered users and 1 guest