Commit 50d7818
authored
Let the GPU surface-distance relaxation run to convergence (#3732)
* Let the GPU surface-distance relaxation run to convergence (#3721)
_surface_distance_cupy capped its parallel relaxation at H + W passes.
One pass moves distance information about one pixel hop, so the number
of passes needed is the hop count of the longest shortest path. Those
two agree on open terrain, but NaN barriers make paths wind, and the
Bellman-Ford bound for a grid graph is the pixel count.
Hitting the cap exited the loop with no warning and no signal in the
output, so pixels the CPU reaches came back NaN, meaning unreachable.
On a 16x16 serpentine corridor the GPU found 37 of 136 reachable pixels;
at 24x24 it found 53 of 300.
The ceiling is now H * W and reaching it warns. The changed-flag check
still exits as soon as the solution settles, so open terrain runs the
same number of passes as before: 256x256 and 512x512 random elevation
both timed within noise of main (0.135 vs 0.136 s, 0.313 vs 0.326 s).
Also covers the bounded dask+cupy path, which runs this function per
chunk against the chunk's own H and W.
* Address review: cover DIRECTION in the long-path test, fix the warning stacklevel (#3721)
_surface_distance_cupy runs the same relaxation loop for all three
modes, and DIRECTION reads srow/scol, which a truncated loop leaves
unset just as it leaves dist at infinity. The long-path test now
parametrizes over surface_direction too.
The convergence warning used stacklevel=2, which lands on _compute.
_surface_distance_dask already uses 4 for the same call depth, so the
warning now points at the caller.1 parent bc4925a commit 50d7818
2 files changed
Lines changed: 61 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
611 | 611 | | |
612 | 612 | | |
613 | 613 | | |
614 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
615 | 623 | | |
616 | 624 | | |
617 | 625 | | |
| |||
621 | 629 | | |
622 | 630 | | |
623 | 631 | | |
| 632 | + | |
624 | 633 | | |
625 | 634 | | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
626 | 645 | | |
627 | 646 | | |
628 | 647 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
748 | 748 | | |
749 | 749 | | |
750 | 750 | | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
751 | 792 | | |
752 | 793 | | |
753 | 794 | | |
| |||
0 commit comments