Changes between Version 4 and Version 5 of WorkGeneration


Ignore:
Timestamp:
Apr 18, 2007, 4:28:56 PM (17 years ago)
Author:
davea
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WorkGeneration

    v4 v5  
    157157);
    158158}}}
    159 create_work() creates a workunit. The arguments are similar to those of the utility program; some of the information is passed in the DB_WORKUNIT structure, namely the following fields:
    160 {{{
    161 name
    162 appid
    163 }}}
    164 The following may be passed either in the DB_WORKUNIT structure or in the workunit template file:
    165 {{{
    166 rsc_fpops_est
    167 rsc_fpops_bound
    168 rsc_memory_bound
    169 rsc_disk_bound
    170 batch
    171 delay_bound
    172 min_quorum
    173 target_nresults
    174 max_error_results
    175 max_total_results
    176 max_success_results
    177 }}}
    178 
    179 == Examples ==
     159create_work() submits a job. The ''name'' and ''appid'' fields of the DB_WORKUNIT structure must always be initialized.
     160Other job parameters may be passed either in the DB_WORKUNIT structure or in the input template file (the latter has priority).
     161
    180162=== Making one workunit ===
    181163
    182 Here's a program that generates one workunit (error-checking is omitted for clarity):
    183 {{{
     164Here's a program that submits one job (error-checking is omitted for clarity):
     165{{{
     166#include "boinc_db.h"
    184167#include "backend_lib.h"
    185168
    186 main() {
     169int main() {
    187170    DB_APP app;
    188171    DB_WORKUNIT wu;
    189     char wu_template[LARGE_BLOB_SIZE];
     172    char* wu_template;
    190173    char* infiles[] = {"infile"};
     174    char path[1024];
    191175
    192176    SCHED_CONFIG config;
    193177    config.parse_file();
    194178
    195     boinc_db.open(config.db_name, config.db_host, config.db_passwd);
     179    boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd);
    196180    app.lookup("where name='myappname'");
    197181
     182    // write input file in the download directory
     183    //
     184    config.download_path("infile", path);
     185    FILE* f = fopen(path, "w");
     186    fwrite(f, "random stuff");
     187    fclose(f);
     188
     189    read_file_malloc("templates/input_template.xml", wu_template);
    198190    wu.clear();     // zeroes all fields
     191    strcpy(wu.name, "test_name");
    199192    wu.appid = app.id;
    200193    wu.min_quorum = 2;
     
    208201    wu.rsc_disk_bound = 1e8;
    209202    wu.delay_bound = 7*86400;
    210     read_filename("templates/wu_template.xml", wu_template, sizeof(wu_template));
    211203    create_work(
    212204        wu,
    213205        wu_template,
    214         "templates/results_template.xml",
    215         "templates/results_template.xml",
     206        "templates/output_template.xml",
     207        "templates/output_template.xml",
    216208        infiles,
    217209        1,
     
    220212}
    221213}}}
    222 This program must be run in the project directory since it expects to find the config.xml file in the current directory.
     214The program must be run in the project directory.
    223215=== Making lots of workunits ===
    224216