This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Fix non-determinism in A57 FP Load Balancing
Needs RevisionPublic

Authored by ssijaric on Jan 28 2015, 10:41 AM.

Details

Summary

Change the type of AllChains from std::set<unique_ptr<Chain>> to std::vector<unique_ptr<Chain>>, as traversing pointers contained in std::set doesn't guarantee a well-defined order. We have observed differences in register assignment in .s files produced with the exact same build. I don't see that duplicate entries can be added to AllChains, so it should be safe to replace std::set with std::vector. This way, traversal of AllChains will be well defined.

Example debug output with -debug-only=aarch64-a57-fp-load-balancing resulting in different traversal:

Compile #1:

 colorChainSet(): #sets=4
- Parity=2, Color=Odd
- colorChain({%S19<def> = FMULSrr -> %S19<def> = FMULSrr}, Odd)
- Scavenged register: S3
- Destination register not changed.
- Parity=1, Color=Odd
- {%S18<def> = FMULSrr -> %S18<def> = FMULSrr} - not worthwhile changing; color remains Even
- colorChain({%S18<def> = FMULSrr -> %S18<def> = FMULSrr}, Even)
- Scavenged register: S2
- Destination register not changed.
- Parity=2, Color=Odd
- colorChain({%S6<def> = FMULSrr -> %S6<def> = FMULSrr (kill @ %S18<def> = FMULSrr)}, Odd)
- Scavenged register: S3
- Kill instruction seen.
- Parity=1, Color=Odd
- colorChain({%S16<def> = FMULSrr -> %S16<def> = FMULSrr (kill @ %S19<def> = FMULSrr)}, Odd)
- Scavenged register: S5
- Kill instruction seen.

Compile #2:

colorChainSet(): #sets=4
  • Parity=2, Color=Odd
  • colorChain({%S19<def> = FMULSrr -> %S19<def> = FMULSrr}, Odd)
  • Scavenged register: S3
  • Destination register not changed.
  • Parity=1, Color=Odd
  • {%S18<def> = FMULSrr -> %S18<def> = FMULSrr} - not worthwhile changing; color remains Even
  • colorChain({%S18<def> = FMULSrr -> %S18<def> = FMULSrr}, Even)
  • Scavenged register: S2
  • Destination register not changed.
  • Parity=2, Color=Odd
  • colorChain({%S16<def> = FMULSrr -> %S16<def> = FMULSrr (kill @ %S19<def> = FMULSrr)}, Odd)
  • Scavenged register: S3
  • Kill instruction seen.
  • Parity=1, Color=Odd
  • colorChain({%S6<def> = FMULSrr -> %S6<def> = FMULSrr (kill @ %S18<def> = FMULSrr)}, Odd)
  • Scavenged register: S5
  • Kill instruction seen.

Cannot have a reproducible test case for this.

Diff Detail

Event Timeline

ssijaric updated this revision to Diff 18903.Jan 28 2015, 10:41 AM
ssijaric retitled this revision from to [AArch64] Fix non-determinism in A57 FP Load Balancing.
ssijaric updated this object.
ssijaric edited the test plan for this revision. (Show Details)
ssijaric added a subscriber: Unknown Object (MLST).

Hi James,

Separately, Geoff ran into the same problem. He found that the problem occurs during sorting in AArch64A57FPLoadBalancing::colorChainSet(…). He will upload his patch for review.

I didn’t see the need for the uniqueness property of the set for AllChains, but changing from std::set to std::vector (or SetVector) may be just hiding the problem. Geoff’s patch should address this.

Thanks,

Sanjin

From: James Molloy [mailto:james@jamesmolloy.co.uk]
Sent: Wednesday, January 28, 2015 12:01 PM
To: reviews+D7231+public+a4fec8073b04be0b@reviews.llvm.org; ssijaric@codeaurora.org; james.molloy@arm.com; liujiangning1@gmail.com; t.p.northover@gmail.com
Cc: llvm-commits@cs.uiuc.edu; kanheim@a-bix.com
Subject: Re: [PATCH] [AArch64] Fix non-determinism in A57 FP Load Balancing

Hi Sanjin,

Are you sure we don't need the uniqueness property of a set any more?

If not, SetVector seems like the right solution.

James

jmolloy requested changes to this revision.Feb 5 2015, 7:09 AM
jmolloy edited edge metadata.

Rejecting this, because Geoff fixed this in a different revision.

This revision now requires changes to proceed.Feb 5 2015, 7:09 AM