[chapel-lang/chapel] This changes the `<=>` operator to swap the pointe

Branch: refs/heads/master
Revision: 1c3b5d1
Author: mcdobe100
Log Message:

Merge pull request #16209 from mcdobe100/array-swap

This changes the <=> operator to swap the pointer for Block and Default Rectangular arrays, for some cases where it was currently doing a deep copy. In order to use this optimization, the arrays to be swapped must:

  • not be an array view
  • have the same domain
  • be of the same type
  • implement the doiSwap() method

If any of these conditions are not met, swaps will still use the old implementation.

Performance comparison for swap on two Block Dist arrays:

Number of Elems before changes (s) after changes (s)
100,000,000 0.032 0.0027
1,000,000,000 0.31 0.0034
10,000,000,000 5.1 0.0032

(It is now constant time for both block and default rectangular, table not totally necessary)

  • paratest gasnet

[ reviewed by @e-kayrakli ] - thanks Engin

Modified Files:
A test/optimizations/arraySwap/blockSwap.chpl
A test/optimizations/arraySwap/blockSwap.good
A test/optimizations/arraySwap/twoDimensionalStridedSwap.chpl
A test/optimizations/arraySwap/twoDimensionalStridedSwap.good
A test/optimizations/arraySwap/twoDimensionalSwap.chpl
A test/optimizations/arraySwap/twoDimensionalSwap.good
M modules/dists/BlockDist.chpl
M modules/internal/ChapelArray.chpl
M modules/internal/DefaultRectangular.chpl

Compare: Comparing 21e8b99cfff4...1c3b5d1ce427 · chapel-lang/chapel · GitHub