Your first run¶
Simulation user
This page runs an example shipped with Onika, shows its operator graph and
changes a parameter from the command line. It uses the counter loop,
the running example of this guide: a loop that prints the time step until it
reaches nsteps.
Run an example¶
Onika installs two launchers in <install-prefix>/bin:
onika-exec: the application itself. Sourcebin/setup-env.shfirst, so that it finds its plugins and configuration files.onikarun: a wrapper script that sourcessetup-env.shand then runsonika-execwith the same arguments.
Onika ships this example as data/exemples/print_loop.msp:
Content of print_loop.msp (you will write it yourself in Your first input file)
print_timestep:
rebind: { value: timestep }
body: [ print_int: { prefix: "Current timestep = ", suffix: "\n" } ]
compute_loop_stop:
rebind:
end_at: nsteps
result: compute_loop_continue
body:
- sim_continue
compute_loop:
loop: true
condition: compute_loop_continue
body: [ print_timestep, next_time_step, compute_loop_stop ]
global:
dt: 1.0
nsteps: 20
timestep: 0
compute_loop_continue: true
simulation:
- global
- mpi_comm_world
- init_cuda
- global
- unit_system:
verbose: true
unit_system: { length: meter , mass: kilogram , time: second , charge: coulomb , temperature: kelvin , amount: mol , luminosity: candela , angle: radian , energy: joule }
- compute_loop
The output ends with:
Look at the graph¶
--debug-graph prints the operator graph that Onika built from the input
file, with the slots of each operator (IN, OUT or IN/OUT):
*SUPPRESS* simulation.global
*SUPPRESS* simulation.mpi_comm_world
*SUPPRESS* simulation.init_cuda
======= simulation graph ========
simulation
global
compute_loop_continue OUT
dt OUT
nsteps OUT
timestep OUT
unit_system
unit_system IN
verbose IN
compute_loop
print_int
prefix IN
suffix IN
timestep IN
next_time_step
dt IN
physical_time IN/OUT
timestep IN/OUT
sim_continue
check_freq IN
compute_loop_continue IN/OUT
nsteps IN
remain IN
signal_handler_priv IN/OUT
stop_file IN
timestep IN
=================================
Three things to notice:
- Slots are connected by name.
next_time_stepreadsdtandtimestep, produced earlier byglobal. No explicit wiring is needed. - Rebinding renames slots.
print_inthas a slotvalue, shown here astimestep, because the input file rebinds it. Same forsim_continue, whoseend_atandresultbecomenstepsandcompute_loop_continue. See Rebinding slots. - Unused operators are removed.
*SUPPRESS*lines list operators whose outputs nobody reads. Hereprint_loop.mspcallsglobaltwice, so the first call is useless. See Unused operators are removed.
flowchart LR
global -- "dt, timestep, nsteps,<br/>compute_loop_continue" --> loop
subgraph loop ["compute_loop (loop while compute_loop_continue)"]
direction LR
p["print_int<br/>value ← timestep"] --> n["next_time_step"] --> s["sim_continue<br/>end_at ← nsteps<br/>result → compute_loop_continue"]
end
Change a value from the command line¶
Every value of the input file can be overridden with --set-<path> <value>,
where <path> is the YAML path with - as separator:
Other options control the run itself (threads, GPU, profiling...), for
example --omp_num_threads 4 or --profiling-summary. See Running a simulation.
Next step: Your first input file, to write this input file yourself.