[Chapel Merge] Address non-determinism due to map iteration

Branch: refs/heads/master
Revision: 5019625
Author: mppf
Log Message:

Merge pull request #17412 from mppf/non-deterministic-task-bundles

Address non-determinism due to map iteration

Follow-up to #6876

For https://github.com/Cray/chapel-private/issues/1788

I noticed several places in the compiler where a loop iterating over a
map with form_Map is adding AST nodes. This results in nondeterminism
because the map iteration order is not deterministic.

To address it, this PR adds a new function, sortedSymbolMapElts, which
returns a vector of key-value pairs for a SymbolMap. This vector is
sorted by AST id of the keys before it is returned. Then, I looked at
all of the calls to form_Map. Some of them do not do anything that
depends on the order, but others appeared to potentially depend on the
order. For calls that could depend on the order, I updated them to call
sortedSymbolMapElts, to use C++ range iteration, and to create key
and value variables for the iteration.

The changes to compiler/resolution/interfaceResolution.cpp were causing
test failures somehow. I will leave it to @vasslitvinov to update the
form_Map calls in that file as needed.

  • [x] full local testing
  • [x] full gasnet testing

Reviewed by @vasslitvinov - thanks!

Modified Files:
M compiler/AST/symbol.cpp

M compiler/include/symbol.h
M compiler/passes/createTaskFunctions.cpp
M compiler/passes/flattenFunctions.cpp
M compiler/resolution/cleanups.cpp
M compiler/resolution/functionResolution.cpp
M compiler/resolution/generics.cpp

Compare: https://github.com/chapel-lang/chapel/compare/51a10b44bf0d...5019625867ae