# tree_d_3d.kernels.compile

*module*

Compile tree-d-3d's Pyccel kernel modules once and reuse the builds across processes.

The cache is :class:`cunumpy.kernels.PyccelCache`: a kernel module is built with
``pyccel compile`` on its first use, keyed on its source, the Pyccel and Python
versions and the platform, and stored under ``TREE_D_3D_KERNEL_CACHE`` (default
``~/.cache/tree-d-3d/kernels``, or ``<tmp>/tree-d-3d-kernels`` if that is not writable).
Later processes import the stored extension directly.

Kernels are built with OpenMP, so the loops marked ``#$ omp parallel for`` run on
all cores (limit them with ``OMP_NUM_THREADS``; under MPI set it to the cores per
rank). ``TREE_D_3D_OPENMP=0`` builds them serial, except the kernels that call the OpenMP
runtime; the setting is part of the cache key.

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/kernels/compile.py#L1-L1)

## tree_d_3d.kernels.compile.KERNEL_CACHE

*attribute* · *module attribute*

```python
KERNEL_CACHE = xp.kernels.PyccelCache('tree-d-3d')
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/kernels/compile.py#L20-L20)

## tree_d_3d.kernels.compile.compile_cached

*attribute* · *module attribute*

```python
compile_cached = KERNEL_CACHE.compile
```

[View source](https://github.com/max-models/tree-d-3d/blob/devel/src/tree_d_3d/kernels/compile.py#L24-L24)
