Skip to content

Performance

All the times below are wall times of a complete solve() in the automatic mode: validation of the input, ordering of the points, multiscale start, final simplex, and the last pricing pass over all the pairs that certifies the optimum. Every run ended with the status optimal.

  • 1 000 × faster than the original network simplex on 16 threads, at 100 000 points (450 × on one thread)

  • 13 to 31 s a million points against a million in the plane, 8 threads

  • \(n^{1.0}\) to \(n^{1.3}\) growth of the time with the number of points, dimensions 1 to 4

  • linear memory the cost matrix is never stored: 8 TB saved at a million points

Against network_simplex

deblais started from the network simplex of Nicolas Bonneel, network_simplex, the solver behind ot.emd in POT. That solver stores the dense cost matrix, and its search for the entering arc is parallelized with OpenMP. Both were run on the test case of its main.cpp: \(n\) points drawn in \([0, 100]^2\) after srand(0), the same points as sources and targets, random masses. network_simplex is timed on run() only, as in its main.cpp; deblais on the whole solve(). Two AMD EPYC 9655, GCC 14.

Points per cloud network_simplex, 1 thread network_simplex, 16 threads deblais, 1 thread deblais, 16 threads
1 000 0.039 s 0.091 s 0.016 s 0.012 s
10 000 4.4 s 3.4 s 0.21 s 0.092 s
100 000 1 385 s 658 s 3.1 s 0.62 s
1 000 000 48 s 8.5 s
10 000 000 684 s 142 s

On one thread, deblais is 20 times faster at 10 000 points and 450 times faster at 100 000: the original solver grows like \(n^{2.5}\), deblais like \(n^{1.2}\). On 16 threads, deblais is 1 000 times faster at 100 000 points and grows like \(n\). The original solver gains little from the threads, 2 times on 16 threads at 100 000 points, and it is slower on 16 threads than on one below 5 000 points: it opens a parallel region for every block of its pricing, which costs more than the block itself on small problems. The dense cost matrix takes 80 GB at 100 000 points and 8 TB at a million. The costs agree to \(3 \times 10^{-5}\) relative, the cost of network_simplex being the larger one: it accumulates the rounding errors of its real flows.

Time of network_simplex and deblais against the number of points Time of network_simplex and deblais against the number of points

network_simplex against deblais on 1 and 16 threads, on the test case of network_simplex, log-log scale. The dashed lines are the slopes n, n2 and n3; the exponent α of each curve is in the legend.

In short

The time of a solve grows like \(C\, n^\alpha\) with the number \(n\) of points per cloud. Fitted on the medians of the measurements from \(10^5\) points up to the largest size, on 192 threads:

Dimension Masses \(\alpha\) \(C\) (s) Fitted on \(10^5\) \(10^6\) \(10^7\)
1 assignment 1.03 \(1.5 \times 10^{-7}\) \(10^5\) to \(10^8\) 0.03 s 0.19 s 2.5 s
1 random integer 1.08 \(1.4 \times 10^{-7}\) \(10^5\) to \(10^8\) 0.04 s 0.33 s 4.9 s
1 random real 1.08 \(1.4 \times 10^{-7}\) \(10^5\) to \(10^8\) 0.04 s 0.36 s 5.3 s
2 assignment 1.25 \(4.8 \times 10^{-7}\) \(10^5\) to \(10^7\) 0.99 s 13.9 s 294 s
2 random integer 1.23 \(1.1 \times 10^{-6}\) \(10^5\) to \(10^7\) 1.6 s 24.8 s 418 s
2 random real 1.00 \(9.0 \times 10^{-6}\) \(10^5\) to \(3 \times 10^7\) 0.96 s 7.5 s 89 s
3 assignment 1.30 \(2.6 \times 10^{-7}\) \(10^5\) to \(3 \times 10^7\) 1.1 s 10.7 s 329 s
3 random integer 1.25 \(1.3 \times 10^{-6}\) \(10^5\) to \(3 \times 10^7\) 2.5 s 32.9 s 514 s
3 random real 0.95 \(3.5 \times 10^{-5}\) \(10^5\) to \(10^7\) 1.9 s 14.5 s 188 s
4 assignment 1.28 \(6.1 \times 10^{-7}\) \(3 \times 10^4\) to \(3 \times 10^7\) 1.6 s 21.3 s 485 s
4 random integer 1.24 \(4.2 \times 10^{-6}\) \(3 \times 10^4\) to \(10^7\) 6.5 s 92 s 2 928 s
4 random real 1.05 \(3.3 \times 10^{-5}\) \(3 \times 10^4\) to \(10^7\) 5.8 s 49 s 1 197 s

The exponent of a single fit hides a curvature. Measured decade by decade, from \(10^5\) to \(10^6\) points and from \(10^6\) to \(10^7\):

Dimension Masses \(10^5 \to 10^6\) \(10^6 \to 10^7\)
1 assignment 0.83 1.12
1 random integer 0.92 1.17
1 random real 0.93 1.17
2 assignment 1.15 1.33
2 random integer 1.20 1.23
2 random real 0.89 1.08
3 assignment 0.98 1.49
3 random integer 1.11 1.19
3 random real 0.87 1.11
4 assignment 1.11 1.36
4 random integer 1.15 1.50
4 random real 0.93 1.39
  • On the line the closed form is a sort: the time is linear, plus the logarithm of the sort. Below a million points the threads are not all busy, which flattens the first decade.
  • General masses (random real numbers) scale linearly, up to thirty million points in the plane and ten million in space: ten times more points cost ten times more. In dimension 4 the last decade is steeper (see Dimension).
  • Random integer masses are slower and scale like \(n^{1.2}\) in dimensions 2 to 4: their optimal plans are degenerate, which the simplex handles poorly (see Three families of masses).
  • Assignments are the fastest family up to a million points, thanks to the auction, then the steepest: from \(10^6\) to \(10^7\) points their time grows like \(n^{1.3}\) in the plane and in dimension 4, \(n^{1.5}\) in space. The auction on the levels of the multiscale start is the sequential part of the solve, and its share grows with the size.

Time against the number of points, one panel per dimension Time against the number of points, one panel per dimension

Time of a solve against the number of points per cloud, 192 threads, median of the seeds, log-log scale. The dashed lines are the slopes n and n2; the fitted exponent α of each curve, from the table above, is in the corner. Click to enlarge.

Protocol

  • Machines: the curves and the fits ran on nodes with two AMD EPYC 9654 (Zen 4, \(2 \times 96\) cores), the comparison with network_simplex and the thread placement on nodes with two AMD EPYC 9655 (Zen 5, \(2 \times 96\) cores), where the same solves take a quarter to a third less time. 192 threads unless stated otherwise.
  • Build: GCC 14.2, -O3 -march=native -fopenmp, GNU OpenMP runtime.
  • Threads pinned: OMP_PLACES=cores OMP_PROC_BIND=spread (see Thread placement).
  • Data: points drawn uniformly in the unit cube \([0, 1]^d\), \(n\) sources against \(n\) targets.
  • Automatic mode: the only argument is the number of threads.
  • Two to three random instances (seeds) per point, the curves show the median. On a quiet node the times vary by a few percent from one run to the next, and by 10 to 20 % from one instance to the next.

Everything is reproducible with the benchmark built by the examples:

cmake -B build -DDEBLAIS_BUILD_EXAMPLES=ON -DDEBLAIS_NATIVE=ON && cmake --build build
export OMP_PLACES=cores OMP_PROC_BIND=spread
./build/examples/deblais_bench --dim=2 --n=1e6 --masses=random --seed=1

Three families of masses

The masses change the problem more than the size does.

  • Assignment (uniform masses, --masses=uniform): every point carries the same mass, the plan is a permutation. The flows are integers (0 or 1).
  • Random integer masses (--masses=integer): integers drawn uniformly, balanced between the two clouds. The flows are integers.
  • Random real masses (--masses=random): real numbers drawn uniformly in \((0.1, 1.1)\) and normalized. The flows are real numbers.

With integer masses, many pairs tie: the optimal plan is degenerate, and the simplex makes many pivots that move no mass. The automatic mode computes the flows in integer arithmetic, which keeps the plan exact, and solves the levels of the multiscale start of an assignment with an auction (see Concepts). With random real masses no two flows tie, and the same simplex runs three times faster.

Dimension 2, 192 threads, median of the seeds, in seconds:

Points per cloud Assignment Random integer masses Random real masses
10 000 0.14 0.20 0.18
100 000 0.99 1.56 0.96
1 000 000 13.9 24.8 7.5
3 000 000 51 110 26.5
10 000 000 294 418 89
30 000 000 260

Rectangular problems follow the larger side: 100 000 sources against 1 000 000 targets with random masses take 3.7 s.

Dimension

The pricing passes prune the pairs with bounding boxes of points that are consecutive along a Hilbert curve. The pruning weakens as the dimension grows, and the plans of the multiscale start are further from the optimum: deblais is built for dimensions 2 to 4. Beyond, expect the cost to drift towards that of a dense solver.

The same instance generator in every dimension (uniform points in the unit cube), 192 threads:

Masses Points per cloud Dimension 2 Dimension 3 Dimension 4
assignment 10 000 0.14 s 0.14 s 0.17 s
100 000 0.99 s 1.1 s 1.6 s
1 000 000 13.9 s 10.7 s 21.3 s
10 000 000 294 s 329 s 485 s
random integer 10 000 0.20 s 0.26 s 0.40 s
100 000 1.6 s 2.5 s 6.5 s
1 000 000 25 s 33 s 92 s
10 000 000 418 s 514 s 2 928 s
random real 10 000 0.18 s 0.28 s 0.43 s
100 000 0.96 s 1.9 s 5.8 s
1 000 000 7.5 s 14.5 s 49 s
10 000 000 89 s 188 s 1 197 s

Up to a million points the exponent hardly moves with the dimension, the constant does: from the plane to space a solve costs up to twice as much, and dimension 4 costs again two to three times more. Beyond, dimension 4 steepens: from \(10^6\) to \(10^7\) points the time grows like \(n^{1.4}\) to \(n^{1.5}\), and ten million points with random masses take 20 to 50 minutes. Thirty million points in space take 29 minutes for an assignment and 69 minutes with random integer masses; the assignment of thirty million points takes 55 minutes in dimension 4.

The line

In dimension 1 the automatic mode uses the closed form: two sorts and a linear pass. There is no simplex, and the masses only change the linear pass.

Points per cloud Assignment, 192 threads Assignment, 1 thread Random integer masses, 192 threads Random integer masses, 1 thread
1 000 000 0.19 s 0.38 s 0.33 s 0.52 s
10 000 000 2.5 s 4.8 s 4.9 s 7.3 s
100 000 000 32 s 59 s 59 s 88 s

The parallel sort gains a factor of two at most: the line is bound by the memory bandwidth.

Threads

Time against the number of threads, dimension 2 Time against the number of threads, dimension 2

Time against the number of threads, dimension 2, one and ten million points per cloud. The dashed line is the linear speed-up from the first point of the random real masses.

The speed-up is real but far from linear. The sweeps of the domain decomposition and the pricing passes run in parallel; the pivots of the simplex inside a subdomain and the bids of the auction do not, and they set the floor. With random real masses the time keeps going down up to 192 threads; on integer masses, past 32 threads there is little left to gain, and at a million points the assignment is even a little slower on 192 threads than on 32. On 4 threads, a million points with random real masses take 22 s, and ten million 343 s.

Sixteen cores get most of it. At a million points they run 4 to 6 times faster than one thread and save more than 95 % of the time that 192 threads save, for the three families of masses. At ten million points they still save 90 % of it with random real masses.

The assignment is the exception. With uniform masses the solve starts with an auction whose bids run on one thread, so the assignment gains the least from the threads: 4 times faster on 192 threads than on one at a million points, against 8.5 times with random real masses. And at ten million points 16 cores save only 76 % of what 192 save (528 s against 280 s): large assignments are the problems that use a whole node.

Thread placement

Pin the threads. On the machine above, the same solves without pinning (OMP_PROC_BIND=false) are up to twice slower:

Problem (dimension 2, 192 threads) Pinned Not pinned
100 000, uniform masses 0.75 s 1.4 - 1.7 s
1 000 000, random masses 5.7 - 6.2 s 10.2 - 10.7 s
1 000 000, uniform masses 10.4 - 10.9 s 12.4 - 14.0 s
export OMP_PLACES=cores OMP_PROC_BIND=spread

The variables are read when the OpenMP runtime starts: in Python, set them before the first import of deblais or torch.

The domain decomposition opens nested parallel regions, and deblais is tuned for the GNU OpenMP runtime (libgomp). Run on the LLVM runtime (libomp), the solver was measured more than ten times slower at ten million points. The Python package always uses libgomp, the one shipped with PyTorch when PyTorch is installed (see Getting started).

Clustered clouds

All the measurements above draw the points uniformly in a cube. The multiscale start and the domain decomposition work best when the optimal plan moves every point a short distance, which is the case between two samples of the same density. When the two clouds have different shapes, or when the points gather in clusters separated by empty regions, the plan moves mass far away, across many subdomains, and the final simplex has much more work. An example, 4 096 points drawn from a Gaussian against 4 096 points in eight blobs on a circle take 0.54 s on 8 threads, against 0.05 s between two uniform clouds of the same size.

On assignments of clustered clouds the auction can also start a price war: deblais detects it, gives the problem back to the simplex and, after three failures, turns the auction off for the rest of the solve. The subdomains of the decomposition run in parallel, so several of them may fail before the auction is turned off: in the example above, auction=False brings the time down from 0.54 s to 0.25 s. When the same kind of clustered problem is solved many times, in a training loop for instance, measure both.

Memory

The cost matrix is never stored. The memory of a solve is linear in the number of points: the coordinates, a pool of a few arcs per source, the spanning tree of the simplex and the plans of the multiscale levels.