kicad2ems.mom25d.policy

mom25d.policy - how a frequency is solved, as data: choose() takes the sizes,
the memory, the GPU and what failed before, and returns a SolvePlan; fast.py
carries it out. memory_plan is the same rules for a whole run (the solver, the
precision and the memory the log and the estimates give).

The rungs, each a factorisation behind one interface (fast.py):
  vulkan-c64  complex64 LU on the GPU, its triangular solves there
  cpu-c64     complex64 LU on the host (or the GPU's, downloaded)
  cpu-c128    complex128 LU on the host: no refinement
  blr         the compiled block low-rank factor (no dense Z)
A complex64 LU preconditions GMRES on the double operator: the dense double Z
(dense) or the matrix-free one. Where a rung fails at f, the one below it
solves, and so does every frequency up to RETRY x f.
class kicad2ems.mom25d.policy.SolvePlan(basis: str = 'rwg', rung: str = 'cpu-c128', dense: bool = True, gpu_factor: bool = False, keep: int = 0, loops: bool = False, why: str = '', gpu_dense: bool = False, half: bool = False)[source]
basis: 'rwg' or 'loop/tree'. rung: the factorisation (the module's
docstring). dense: Z in double, its products the refinement's (else Z in
complex64, the refinement matrix-free). gpu_factor: factored on the GPU,
solved on the host (where the GPU's solves failed). keep: LUs kept after
the solve (a matrix-free one keeps its own alone). loops: the sides'
verticals as loops (T^T Z T). why: why not the loop/tree basis.
gpu_dense: the dense Z on the GPU too, the products there. half: the
dense Z by its lower half (half.Half), the factor an LDL^T of it.
property on_gpu[source]
Whether the GPU factors.
kicad2ems.mom25d.policy.anchor_bytes(n, nv)[source]
The host's bytes of the via blocks the sweep keeps to interpolate them
(blocks.Anchors: KEEP anchors, each the via columns' blocks less the
first's, complex64: n x nv of them and two nv x nv), capped as fast.py
caps them: a double Z, or ANCHOR_ROOM where that is more.
kicad2ems.mom25d.policy.choose(f, n, nq=None, nt=0, avail=16000000000.0, gpu=None, precision='mixed', solver='direct', reuse=True, history=None, held=None, kh2=1.0, loop_tree='auto', lt_block='', sides=False, gpu_dense=False, half=True)[source]
The SolvePlan at f. n: unknowns, nq: in the LU (fewer with quads), nt:
triangles. avail: host bytes free. gpu: None, or (free bytes, need:
unknowns -> a factor's bytes, optionally a kept factor's bytes: device()).
precision: the run's ('double', 'mixed').
history: {(basis, rung): the highest f it failed at} (rung 'ldl': the
GPU's LDL^T, fast.py's). held: {basis:
(host, GPU) bytes of the LUs kept, theirs to give back}. kh2: (k h)^2 at
f. loop_tree: 'auto', 'on', 'off'. lt_block: why the loop/tree basis
cannot be used (quads, holes). sides: the sides of thick copper have
verticals. gpu_dense: the GPU can hold the double Z (GPU_DENSE). half:
the half may be taken (False: the operator gave it up, fast.py).
kicad2ems.mom25d.policy.dense_bytes(n, nq)[source]
The hybrid's host bytes: the double Z and its complex64 copy; with quads
(nq < n) Z and the reduced matrix, then the copy.
kicad2ems.mom25d.policy.device(b, ldl=None)[source]
choose's and memory_plan's gpu for backend b (None: None): (free
bytes, a factor's need, a kept factor's bytes), the LDL^T's where it is
taken (LDL, and the backend has it).
kicad2ems.mom25d.policy.gpu_fits(need, free)[source]
Whether an LU of `need` bytes fits a GPU with `free`: at least 0.5 GB
(3 %) to spare: 90 % of the free turned down antenna_cp_patch's 40.8k
unknowns (14.15 GB of 15.7 GB), which factored there in 19 s with 1.95 GB
left, against minutes on the CPU.
kicad2ems.mom25d.policy.memory_plan(n, avail=None, gpu=None, precision='auto', solver='auto', n_lu=None, nv=0, gpu_dense=True, interp=True, pairs=0, sides=False)[source]
How the solver of n unknowns runs and the memory it needs: dict(solver,
precision, path, host, gpu, fits) (bytes). gpu: None or (free bytes, need:
unknowns -> an LU's bytes), the backend's own estimate (device()). path:
'double' (LU on the CPU), 'hybrid' (complex64 LU on the GPU, the double Z
on the host for the refinement), 'gpu-lu' (complex64 Z on the host and the
GPU), 'cpu-mixed' (complex64 LU on the CPU), 'blr' (compressed, no dense
Z). n_lu: the unknowns the LU factors (fewer with quads). 'auto' takes the
block low-rank LU from BLR_MIN_N unknowns where the GPU factors without
the hybrid, from BLR_CPU_MIN_N where the CPU factors, and wherever the
direct solver does not fit. The GPU's bytes include the
double Z where choose puts it there too (gpu_dense: the backend's double
kernels; GPU_DENSE), the host's the via blocks kept for the sweep's
interpolation (nv via unknowns, interp: on; blocks.Anchors: up to a double
Z, or ANCHOR_ROOM) and the near field's (pairs: near triangle pairs;
near_bytes). sides: the sides of thick copper have verticals (their
loops keep Z whole: no half).
kicad2ems.mom25d.policy.near_bytes(pairs, sparse=False)[source]
The near field's host bytes for `pairs` near triangle pairs: those held,
and, for a solver that keeps the correction sparse (sparse: the block
low-rank LU, a matrix-free refinement), its peak while that is built
(fast.FastOperator.NEAR_BYTES: what its piece-at-a-time build keeps, and
one piece's peak, near.near_sparse). A dense Z takes the correction in
place.
kicad2ems.mom25d.policy.via_block_bytes(n, nv)[source]
The block low-rank solve's via and side blocks, filled whole: B ((n -
nv) x nv) and C (nv x nv), complex128.