Skip to content
Projects

Domain decomposition

The equations of simgeometry.domain_decomposition, declared on the code that implements them and checked by the tests.

calculate_proc_sizes

functionsource

Calculate the optimal number of processes in each dimension based on the

search
Pi=round⁡ ⁣(Srem1/k), lowered until Pi∣Srem;Srem←Srem/Pi,k←k−1P_i = \operatorname{round}\!\big(S_\mathrm{rem}^{1/k}\big), \text{ lowered until } P_i \mid S_\mathrm{rem}; \qquad S_\mathrm{rem} \leftarrow S_\mathrm{rem} / P_i, \quad k \leftarrow k - 1
Assumes
  • SS ranks, kk the number of active (decomposed) axes, taken in order with Srem=SS_\mathrm{rem} = S at the start
  • the last active axis gets SremS_\mathrm{rem}, so ∏Pi=S\prod P_i = S and the search never restarts or fails
  • no axis decomposed: all ranks on the first decomposed axis (all ones when none is)
  • not balanced across axes: 6 ranks in 3D give (2,1,3)(2, 1, 3), 16 give (2,2,4)(2, 2, 4)

DomainDecomposition

classsource

Represent the MPI process grid of a decomposed domain.

rank
rank=∑ici∏j>iPj\text{rank} = \sum_i c_i \prod_{j > i} P_j
neighbours
ci±1, wrapped modulo Pi on a periodic axis, else MPI.PROC_NULLc_i \pm 1, \text{ wrapped modulo } P_i \text{ on a periodic axis, else } \texttt{MPI.PROC\_NULL}
node cuts
cutc=c⌊NiPi⌋+min⁡(c,Ni mod Pi),block c owns nodes [cutc,cutc+1)\mathrm{cut}_c = c \left\lfloor \frac{N_i}{P_i} \right\rfloor + \min(c, N_i \bmod P_i), \qquad \text{block } c \text{ owns nodes } [\mathrm{cut}_c, \mathrm{cut}_{c+1})
edges
ec=l+cutc h,e0=l,ePi=u,block c owns [ec,ec+1)e_c = l + \mathrm{cut}_c\, h, \qquad e_0 = l, \quad e_{P_i} = u, \qquad \text{block } c \text{ owns } [e_c, e_{c+1})
owner
ci(x)=#{k=1,…,Pi−1:ek≤xi}c_i(x) = \#\{k = 1, \dots, P_i - 1 : e_k \le x_i\}
Assumes
  • the process grid PP from calculate_proc_sizes; row-major ranks, as mpiarray places them
  • hh over N−1N - 1 cells on a bounded axis, NN on a periodic one; the first Ni mod PiN_i \bmod P_i blocks are one node longer (mpiarray's chunk_bounds)
  • a position below ll goes to block 0, one at or above eP−1e_{P-1} (also uu and NaN) to the last block
  • replicated (more than one rank, one block): every rank holds everything at process coordinate 0; its neighbours are itself on periodic axes
  • fields (layout) and markers (owner_ranks) share the one split
Built from