# Parallel computing & HPC

Parts I–III taught you to *run* qc-rs. This part teaches you to run it **fast and big** — using more than one
CPU core, more than one machine, or a GPU. It is written **from zero**: you do not need any high-performance
computing (HPC) background. We start with what parallelism even *is*, then work up through the three levels
qc-rs exposes.

:::{note} You do not need this to get started
Everything so far ran fine on a single core. Reach for this part when a calculation is **too slow** or **too
big** for one core — a larger molecule, a bigger basis, a geometry optimization with many steps. If your work
fits comfortably on a laptop, you can skip Part IV until you need it.
:::

## The three levels of parallelism

qc-rs can use more hardware in three complementary ways, from easiest to most involved:

| level | hardware | qc-rs knob | chapter |
|---|---|---|---|
| **Threads** | multiple cores of **one** machine (shared memory) | `run(nthread=N)` | [Threads & BLAS](threads-and-blas.md) |
| **MPI** | multiple **machines** (a cluster) | `run(nmpi=N, hosts=...)` or `comm=` | [MPI & interconnects](mpi-and-interconnects.md) |
| **GPU** | an NVIDIA graphics card | `eri="4c-cuda"` (a `cuda` build) | [GPU / CUDA](gpu-cuda.md) |

They compose: a big cluster run uses **MPI across nodes** and **threads within each node**, and optionally a
**GPU per node**. The [primer](parallel-computing-primer.md) explains the underlying ideas (processes vs
threads, shared vs distributed memory, Amdahl's law) before any qc-rs specifics; the later chapters are the
practical how-to.

## One idea to carry through: more hardware changes the *speed*, not the *answer*

Just as the [initial guess](../20-guide/initial-guess.md) and the [convergence algorithm](../20-guide/scf.md)
only changed the *path*, adding cores, ranks, or a GPU only changes **how fast** you get the result — the
converged energy is the same (to the floating-point reduction order). You will see this verified throughout:
`run(nthread=1)` and `run(nthread=4)` give bit-identical water energies.

## A separate axis: the integral strategy (`eri=`)

Performance in quantum chemistry is dominated by the two-electron integrals, and qc-rs lets you choose **how**
they are handled — in memory, recomputed, out-of-core, density-fitted, on the GPU — through a single
`ints(eri=...)` keyword. That choice interacts with all three parallelism levels, so it gets its own chapter:
[ERI / J-K strategies](eri-jk-strategies.md).

Ready? Start with the [parallel-computing primer](parallel-computing-primer.md), which assumes nothing.
