Changes between Version 40 and Version 41 of BasicApi


Ignore:
Timestamp:
Aug 10, 2012, 3:15:35 PM (12 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BasicApi

    v40 v41  
    55Most of the functions have a C interface,
    66so that they can be used from programs written in C and other languages.
    7 Unless otherwise specified, the functions return an integer error code; zero indicates success.
     7Unless otherwise specified, the functions return an integer error code;
     8zero indicates success.
    89To use the API include there header.
    910{{{
     
    9495== Checkpointing == #checkpointing
    9596
    96 Computations that use a significant amount of time per work unit may want to periodically write the current state of the computation to disk. This is known as '''checkpointing'''. The state file must include everything required to start the computation again at the same place it was checkpointed. On startup, the application reads the state file to determine where to begin computation. If the BOINC client quits or exits, the computation can be restarted from the most recent checkpoint.
    97 
    98 Frequency of checkpointing is a user preference (e.g. laptop users might want to checkpoint infrequently). An application must call
     97Long jobs may want to periodically
     98write the current state of the computation to disk.
     99This is known as '''checkpointing'''.
     100The checkpoint file must include everything required to restart the computation
     101at the same point.
     102On startup, the application reads the checkpoint file to determine where to begin computation.
     103If the BOINC client quits or exits,
     104the computation can be restarted from the most recent checkpoint.
     105
     106Most applications are able to checkpoint only at specific points,
     107e.g. at the end the outer loop.
     108Whan the application is at such a point, it must call
    99109
    100110{{{
     
    103113}}}
    104114
    105 whenever it reaches a point where it is able to checkpoint. If this returns nonzero (True) then the application should checkpoint immediately (i.e., write the state file and flush all output files), then call
     115If this returns nonzero (True) then the application should checkpoint immediately
     116(i.e., write the state file and flush all output files), then call
    106117
    107118{{{
     
    110121}}}
    111122
    112 `boinc_time_to_checkpoint()` is fast, so it can be called frequently (hundreds or thousands of times a second).
     123`boinc_time_to_checkpoint()` is fast,
     124so it can be called frequently (hundreds or thousands of times a second).
     125
     126'''boinc_time_to_checkpoint''' returns true only when sufficient time
     127has passed since the last checkpoint.
     128This minimum interval is the maximum of:
     129
     130 * A user preference
     131  (e.g. laptop users might want to checkpoint infrequently).
     132 * An optional application-supplied, specified by calling
     133
     134{{{
     135boinc_set_min_checkpoint_period(int nsecs);
     136}}}
    113137
    114138If you're using replication, make sure your application generates the same results
    115139regardless of where and how often it restarts.
    116140This requires:
    117  * In writing the checkpoint file, use conversion codes that don't lose precision; e.g., use %e for doubles.
    118  * 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:
     141 * In writing the checkpoint file, use conversion codes that don't lose precision;
     142  e.g., use %e for doubles.
     143 * If your app uses random numbers, save and restore the state of the RNG.
     144   If you use rand(), you can do this by surrounding every boinc_time_to_checkpoint()
     145   with the following:
    119146{{{
    120147int x = rand();
     
    135162}}}
    136163
    137 Call these around code segments during which you don't want to be suspended or killed by the core client. Since r14694, critical sections are reentrant. This means that you can begin critical section multiple times, but each {{{begin}}} must have a matching {{{end}}} call.
     164Call these around code segments during which you don't want to be
     165suspended or killed by the core client.
     166Since r14694, critical sections are reentrant.
     167This means that you can begin critical section multiple times,
     168but each {{{begin}}} must have a matching {{{end}}} call.
    138169
    139170'''NOTE:''' This is done automatically while checkpointing.
     
    141172== Atomic file update ==
    142173
    143 To facilitate atomic checkpoint, an application can write to output and state files using the `MFILE` class.
     174To facilitate atomic checkpoint,
     175an application can write to output and state files using the `MFILE` class.
    144176
    145177{{{
     
    157189}}}
    158190
    159 MFILE buffers data in memory and writes to disk only on `flush()` or `close()`. This lets you write output files and state files more or less atomically.
     191MFILE buffers data in memory and writes to disk only on `flush()` or `close()`.
     192This lets you write output files and state files more or less atomically.
    160193
    161194
    162195== Reporting progress == #progress
    163196
    164 The core client GUI displays the percent done of workunits in progress. To keep this display current, an application should periodically call
     197The core client GUI displays the percent done of workunits in progress.
     198To keep this display current, an application should periodically call
    165199
    166200{{{
     
    172206This function is fast and can be called frequently (once per second or more).
    173207The sequence of arguments in successive calls should be non-decreasing.
    174 An application should never 'reset' and start over if an error occurs; it should exit with an error code.
    175 
    176 
     208An application should never 'reset' and start over if an error occurs;
     209it should exit with an error code.
    177210
    178211== Timing information ==
     
    195228== Standalone mode == #standalone
    196229
    197 BOINC applications can be run in "standalone" mode for testing, or under the control of the BOINC client.
     230BOINC applications can be run in "standalone" mode for testing,
     231or under the control of the BOINC client.
    198232You might want your application to behave differently in the two cases.
    199  For example you might want to output debugging information if the application is running standalone.
    200 To determine if the application is running in standalone mode or under the control of the BOINC client, call
     233For example you might want to output debugging information
     234if the application is running standalone.
     235To determine if the application is running in standalone mode or
     236under the control of the BOINC client, call
    201237
    202238{{{
     
    205241}}}
    206242
    207 This returns non-zero (True) if the application is running standalone, and zero (False) if the application is running under the control of the BOINC client.
     243This returns non-zero (True) if the application is running standalone,
     244and zero (False) if the application is running under the control of the BOINC client.
    208245
    209246== Registering a timer handler == #timer