Trick Job | Description |
---|
monte_master_init
| Runs once in the master before any slaves are spawned. |
monte_slave_init
|
Runs once in each slave upon spawning. |
monte_master_pre
|
Runs in the master before each run is dispatched. This is where you could modify inputs before they are sent to a slave. |
monte_slave_pre
|
Runs in the slave before each dispatch received from the master is executed. Inputs are processed before this job. |
monte_slave_post
|
Runs in the slave each time this slave completes a run. This is where you could send custom results back to the master. |
monte_master_post
|
Runs in the master each time a slave completes a run. This is where you could receive custom results from a slave. |
monte_slave_shutdown
|
Runs once in the slave before termination. |
monte_master_shutdown
|
Runs once in the master after all runs have completed. |
#### The Post-Run Connection
Post-run communication can be done via the Trick comm package in the post-run jobs. The underlying sockets are already connected at the time the post-run jobs are executed, so the user can simply use the C wrapper functions `::mc_read` and `::mc_write` to pass additional data between the master and slave.
#### Where To Put Optimization Code
Since the master is in charge of dispatching, the optimization code will reside in the master. It is debatable whether to put the actual decision making in the `monte_master_pre` or `monte_master_post` jobs. The tutorial uses `monte_master_pre`, which may seem less intuitive, since the `monte_master_post` is the one receiving the results. It turned out that the decision making for that particular algorithm was easier before the run rather than after. This is not a hard and fast rule. Wherever it makes sense for the problem at hand is where the decision making should go.
### Job Order
This is the order in which jobs are executed in a MonteCarlo sim:
- Program starts
- Master runs constructors
- Master runs default data jobs
- Master processes input file
- Master runs monte_master_init jobs
- For each slave
- Master spawns slave
- Slave runs constructors
- Slave runs default_data jobs
- Slave processes input file (the same one that the master is using)
- Slave runs monte_slave_init jobs
- For each run sent to a slave by the master
- Master runs monte_master_pre jobs
- Slave parses input from master (this is where the variables being swept are set)
- Slave runs monte_slave_pre jobs
- Slave runs initialization jobs
- Slave runs the simulation
- Slave runs shutdown jobs
- Slave runs monte_slave_post jobs
- Master runs monte_master_post jobs
- When all runs have completed
- Each slave runs monte_slave_shutdown jobs
- Master runs monte_master_shutdown jobs
### User Accessible Routines
- ::mc_set_enabled
- ::mc_get_enabled
- ::mc_set_dry_run
- ::mc_get_dry_run
- ::mc_set_localhost_as_remote
- ::mc_get_localhost_as_remote
- ::mc_set_custom_slave_dispatch
- ::mc_get_custom_slave_dispatch
- ::mc_set_timeout
- ::mc_get_timeout
- ::mc_set_max_tries
- ::mc_get_max_tries
- ::mc_set_user_cmd_string
- ::mc_get_user_cmd_string
- ::mc_set_custom_pre_text
- ::mc_get_custom_pre_text
- ::mc_set_custom_post_text
- ::mc_get_custom_post_text
- ::mc_set_verbosity
- ::mc_get_verbosity
- ::mc_set_num_runs
- ::mc_get_num_runs
- ::mc_set_run_directory
- ::mc_get_run_directory
- ::mc_get_slave_id
- ::mc_add_range
- ::mc_add_slave
- ::mc_start_slave
- ::mc_stop_slave
- ::mc_set_output_directory
- ::mc_disable_slave_GUIs
- ::mc_write
- ::mc_read
- ::mc_get_connection_device
- ::mc_set_current_run
- ::mc_get_current_run