Re: coherence litmus test and data race.
Peter Veentjer via Concurrency-interest <[email protected]> Tue, 13 Jul 2021 17:52:04 +0300
| Newsgroups | gmane.comp.java.jsr.166-concurrency |
|---|---|
| Message-ID | <CAGuAWdDYb78cAMYnSn4r1QLivTmJ87W_RSXOp_B+tf6nkzxLpA@mail.gmail.com> |
Hi Alex, Thanks for your response. I know cache-coherence doesn't come into play since caches on modern CPUs are always coherent. But this test is called the coherence litmus test and checks if it is allowed that loads to the same address get reordered independent of the level this happens. On Tue, Jul 13, 2021 at 5:08 PM Alex Otenko <[email protected]> wrote: > I think the only requirement for plain loads in a concurrent setting is > that there are no out-of-thin-air values. > > That is, you can read only values that some thread stores. > > The coherence does not come into picture, because there is a compiler > (which is allowed to produce code that violates any assumptions you want to > make about hardware) > > Alex > > On Tue, 13 Jul 2021, 08:18 Peter Veentjer via Concurrency-interest, < > [email protected]> wrote: > >> Hi, >> >> Imagine the following program: >> >> int a,b=0 >> >> thread1: >> a=1 >> [storestore] >> a=2 >> >> thread2: >> r1=a >> r2=a >> >> It is obvious that there is a data race since the loads/stores are plain >> loads and stores. My question is about the allowed behaviors in this >> particular case. Do the 2 plain loads to the same address need to be >> executed in order, or will any order be fine? >> >> In terms of litmus tests: is it allowed that code with a data race can >> violate the coherence litmus test. >> >> int a,b=0 >> >> thread1: >> a=1 >> >> thread2: >> a=2 >> >> thread3: >> r1=a >> r2=a >> >> thread4: >> r3=a >> r4=a >> >> So could it be that we end up with r1=1, r2=2, r3=2 and r4=1. >> >> >> https://repository.upenn.edu/cgi/viewcontent.cgi?article=1980&context=cis_reports >> >> My guess at this is allowed behavior because it doesn't change the >> 'within thread as if serial semantics'. >> >> Regards, >> >> Peter. >> >> >> _______________________________________________ >> Concurrency-interest mailing list >> [email protected] >> http://cs.oswego.edu/mailman/listinfo/concurrency-interest >> > _______________________________________________ Concurrency-interest mailing list [email protected] http://cs.oswego.edu/mailman/listinfo/concurrency-interest