🌶️ chili
A modular, reusable, general-purpose backend
The chili backend acts in two phases.
In the first phase, source code is being generated by
macros and
generics.
Afterwards, the generated code is compiled and run.
To leverage the strong type-system and compiler optimizations of the Rust compiler rustc,
cellular_raza makes extensive use of these methods.
Code generation
cellular_raza provides generic concepts which need to be numerically
integrated.
The chili backend makes extensive use of macros in order to build a fully working simulation.
Three macros stand out in particular:
build_aux_storage
build_communicator and
run_main.
They can also be used in tandem via the
run_simulation macro.
Aux Storage
To store additional information for cell-agents such as position, velocity increments used by the
solver or information about next update steps of the cycle trait,
we need an additional struct that holds this information.
The chili backend provides the
build_aux_storage macro
which inserts code that defines said struct depending on which
concepts the user chose.
Communicator
The [chili]((/internals/backend/chili) backend uses parallelization across multiple threads.
Since cellular_raza makes use of domain decomposition methods,
we must be able to communicate and synchronize between threads.
The build_communicator
macro inserts code which defines a new struct that fulfills this purpose.
Main function
To numerically solve the specified system, chili provides the
run_main macro.
It decomposes the domain with the cells and distributes the workload across multiple threads.
The main purpose of this macro is to insert only update functions which correspond to the selected
simulation aspects.
It also handles storage of simulation results.