| 96 | |
| 97 | If you're using replication, make sure your application generates the same results |
| 98 | regardless of where and how often it restarts. |
| 99 | This requires: |
| 100 | * In writing the checkpoint file, use conversion codes that don't lose precision; e.g., use %e for doubles. |
| 101 | * If your app uses random numbers, save and restore the state of the RNG. You can do this by surrounding every boinc_time_to_checkpoint() with the following: |
| 102 | {{{ |
| 103 | int x = rand(); |
| 104 | if (boinc_time_to_checkpoint()) { |
| 105 | ... |
| 106 | } |
| 107 | srand(x); |
| 108 | }}} |
| 109 | Write x to the checkpoint file, |
| 110 | and do a srand(x) when restarting from a checkpoint. |