2004-06-09 19:09:16 +00:00
|
|
|
<?php
|
2003-08-19 06:44:58 +00:00
|
|
|
require_once("docutil.php");
|
|
|
|
page_head("Generating work");
|
|
|
|
echo "
|
2005-01-02 07:44:40 +00:00
|
|
|
|
|
|
|
As described earlier, a <a href=work.php>workunit</a>
|
|
|
|
represents the inputs to a computation.
|
|
|
|
The steps in creating a workunit are:
|
|
|
|
<ul>
|
|
|
|
|
|
|
|
<li> Write XML 'template files' that describe the workunit
|
|
|
|
and its corresponding results.
|
|
|
|
Generally the same templates will be used for
|
|
|
|
a large number work of workunits.
|
|
|
|
|
|
|
|
<li> Create the workunit's input file(s)
|
|
|
|
and place them in the download directory.
|
|
|
|
|
|
|
|
<li> Call a BOINC function that creates a
|
|
|
|
database record for the workunit.
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
Once this is done, BOINC takes over:
|
|
|
|
it creates one or more results for the workunit,
|
|
|
|
distributes them to client hosts,
|
|
|
|
collects the output files,
|
|
|
|
finds a canonical result,
|
|
|
|
assimilates the canonical result,
|
|
|
|
and deletes files.
|
|
|
|
|
2002-05-24 04:29:10 +00:00
|
|
|
<p>
|
2005-01-02 07:44:40 +00:00
|
|
|
During the testing phase of a project,
|
2005-01-10 20:46:33 +00:00
|
|
|
you can use the <a href=busy_work.php>make_work</a> daemon
|
2005-01-02 07:44:40 +00:00
|
|
|
to replicate a given workunit as needed to maintain
|
|
|
|
a constant supply of work.
|
|
|
|
This is useful while testing and debugging the application.
|
|
|
|
|
2004-02-15 19:22:01 +00:00
|
|
|
|
2005-01-02 07:44:40 +00:00
|
|
|
<h2>Workunit and result template files</h2>
|
2002-05-24 04:29:10 +00:00
|
|
|
<p>
|
2005-01-02 07:44:40 +00:00
|
|
|
A workunit template file has the form
|
2004-02-09 05:11:05 +00:00
|
|
|
<pre>",htmlspecialchars("
|
2004-02-15 19:22:01 +00:00
|
|
|
<file_info>
|
|
|
|
<number>0</number>
|
2004-04-13 23:55:05 +00:00
|
|
|
[ <sticky/>, other attributes]
|
2004-02-15 19:22:01 +00:00
|
|
|
</file_info>
|
2003-08-15 22:19:25 +00:00
|
|
|
[ ... ]
|
2004-02-09 05:11:05 +00:00
|
|
|
<workunit>
|
2004-02-15 19:22:01 +00:00
|
|
|
<file_ref>
|
2004-04-13 23:55:05 +00:00
|
|
|
<file_number>0</file_number>
|
2004-02-15 19:22:01 +00:00
|
|
|
<open_name>NAME</open_name>
|
|
|
|
</file_ref>
|
|
|
|
[ ... ]
|
2004-02-09 05:11:05 +00:00
|
|
|
[ <command_line>-flags xyz</command_line> ]
|
2004-04-13 23:55:05 +00:00
|
|
|
[ <rsc_fpops_est>x</rsc_fpops_est> ]
|
|
|
|
[ <rsc_fpops_bound>x</rsc_fpops_bound> ]
|
|
|
|
[ <rsc_memory_bound>x</rsc_memory_bounds> ]
|
|
|
|
[ <rsc_disk_bound>x</rsc_disk_bounds> ]
|
|
|
|
[ <delay_bound>x</delay_bound> ]
|
|
|
|
[ <min_quorum>x</min_quorum> ]
|
|
|
|
[ <target_nresults>x</target_nresults> ]
|
|
|
|
[ <max_error_results>x</max_error_results> ]
|
|
|
|
[ <max_total_results>x</max_total_results> ]
|
2004-11-22 19:17:13 +00:00
|
|
|
[ <max_success_results>x</max_success_results> ]
|
2004-02-09 05:11:05 +00:00
|
|
|
</workunit>
|
|
|
|
"), "
|
2003-08-15 22:19:25 +00:00
|
|
|
</pre>
|
|
|
|
The components are:
|
2004-02-09 05:11:05 +00:00
|
|
|
";
|
|
|
|
list_start();
|
2004-02-15 19:22:01 +00:00
|
|
|
list_item(htmlspecialchars("<file_info>, <file_ref>"),
|
2004-04-13 23:55:05 +00:00
|
|
|
"Each pair describes an <a href=files.php>input file</a>");
|
2004-02-09 05:11:05 +00:00
|
|
|
list_item(htmlspecialchars("<command_line>"),
|
|
|
|
"The command-line arguments to be passed to the main program.");
|
2004-04-13 23:55:05 +00:00
|
|
|
list_item("Other elements",
|
|
|
|
"<a href=work.php>Work unit attributes</a>"
|
|
|
|
);
|
2004-02-09 05:11:05 +00:00
|
|
|
list_end();
|
|
|
|
echo"
|
|
|
|
When a workunit is created, the template file is processed as follows:
|
2002-05-24 04:29:10 +00:00
|
|
|
<ul>
|
2002-08-19 18:43:10 +00:00
|
|
|
<li>
|
2002-12-12 01:07:24 +00:00
|
|
|
Within a <file_info> element,
|
|
|
|
<number>x</number> identifies the order of the file.
|
|
|
|
It is replaced with elements giving
|
|
|
|
the filename, download URL, MD5 checksum, and size.
|
2002-08-19 18:43:10 +00:00
|
|
|
<li>
|
2002-12-12 01:07:24 +00:00
|
|
|
Within a <file_ref> element,
|
2004-04-13 23:55:05 +00:00
|
|
|
<file_number>x</file_number> is replaced with an element
|
|
|
|
giving the filename.
|
2002-05-24 04:29:10 +00:00
|
|
|
</ul>
|
2005-01-02 07:44:40 +00:00
|
|
|
|
2004-02-15 19:22:01 +00:00
|
|
|
<p>
|
|
|
|
A result template file has the form
|
|
|
|
<pre>", htmlspecialchars("
|
|
|
|
<file_info>
|
|
|
|
<name><OUTFILE_0/></name>
|
|
|
|
<generated_locally/>
|
|
|
|
<upload_when_present/>
|
|
|
|
<max_nbytes>32768</max_nbytes>
|
|
|
|
<url><UPLOAD_URL/></url>
|
|
|
|
</file_info>
|
|
|
|
<result>
|
|
|
|
<file_ref>
|
|
|
|
<file_name><OUTFILE_0/></file_name>
|
|
|
|
<open_name>result.sah</open_name>
|
|
|
|
</file_ref>
|
|
|
|
</result>
|
|
|
|
"), "</pre>
|
2002-05-24 04:29:10 +00:00
|
|
|
<p>
|
2002-11-07 19:31:34 +00:00
|
|
|
The result file template is macro-substituted as follows:
|
2002-05-24 04:29:10 +00:00
|
|
|
<ul>
|
2002-08-19 18:43:10 +00:00
|
|
|
<li>
|
2002-11-07 19:31:34 +00:00
|
|
|
<OUTFILE_n> is replaced with a string of the form
|
2003-08-19 06:44:58 +00:00
|
|
|
'wuname_resultnum_n' where wuname is the workunit name and resultnum is
|
2002-07-29 19:01:38 +00:00
|
|
|
the ordinal number of the result (0, 1, ...).
|
2002-08-19 18:43:10 +00:00
|
|
|
<li>
|
2004-12-01 05:03:53 +00:00
|
|
|
<UPLOAD_URL/> is replaced with the upload URL.
|
2002-05-24 04:29:10 +00:00
|
|
|
</ul>
|
|
|
|
<p>
|
2005-01-02 07:44:40 +00:00
|
|
|
|
2005-01-02 08:19:43 +00:00
|
|
|
<h2>Moving input files to the download directory</h2>
|
2005-01-02 07:44:40 +00:00
|
|
|
|
2005-01-02 08:19:43 +00:00
|
|
|
If you're a flat download directory, just put input files in that directory.
|
2005-01-02 07:44:40 +00:00
|
|
|
If you're using <a href=hier_dir.php>hierarchical upload/download directories</a>,
|
2005-01-02 08:19:43 +00:00
|
|
|
you must put each input file in the appropriate directory;
|
2005-01-02 07:44:40 +00:00
|
|
|
the directory is determined by the file's name.
|
|
|
|
To find this directory, call the C++ function
|
|
|
|
<pre>
|
|
|
|
dir_hier_path(
|
2005-01-02 08:19:43 +00:00
|
|
|
const char* filename,
|
|
|
|
const char* root, // root of download directory
|
|
|
|
int fanout, // from config.xml
|
|
|
|
bool new_hash, // use true here
|
|
|
|
char* result // path of file in hierarchy
|
|
|
|
);
|
2005-01-02 07:44:40 +00:00
|
|
|
</pre>
|
|
|
|
If you're using scripts, you can invoke the program
|
|
|
|
<pre>
|
2005-01-02 08:19:43 +00:00
|
|
|
dir_hier_path filename
|
2005-01-02 07:44:40 +00:00
|
|
|
</pre>
|
2005-01-02 08:19:43 +00:00
|
|
|
It prints the full pathname.
|
|
|
|
Run this in the project's root directory.
|
2005-02-01 21:11:08 +00:00
|
|
|
For example:
|
|
|
|
<pre>
|
|
|
|
cp test_workunits/12ja04aa `bin/dir_hier_path 12ja04aa`
|
|
|
|
</pre>
|
|
|
|
copies an input file from the test_workunits directory
|
|
|
|
to the download directory hierarchy.
|
2005-01-02 07:44:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
<h2>Creating workunit records</h2>
|
|
|
|
<p>
|
|
|
|
Workunits can be created using either a script
|
2005-02-01 21:11:08 +00:00
|
|
|
(using the <code>create_work</code> program)
|
2005-01-02 07:44:40 +00:00
|
|
|
or a program (using the <code>create_work()</code> function).
|
2005-02-01 21:11:08 +00:00
|
|
|
The input files must already be in the download directory.
|
2004-02-09 05:11:05 +00:00
|
|
|
<p>
|
|
|
|
The utility program is
|
|
|
|
<pre>
|
|
|
|
create_work
|
2004-07-10 07:27:00 +00:00
|
|
|
-appname name // application name
|
|
|
|
-wu_name name // workunit name
|
|
|
|
-wu_template filename // WU template filename
|
|
|
|
// relative to project root
|
|
|
|
-result_template filename // result template filename
|
|
|
|
// relative to project root
|
2004-11-25 07:47:52 +00:00
|
|
|
[ -batch n ]
|
|
|
|
[ -priority n ]
|
2004-04-13 23:55:05 +00:00
|
|
|
|
|
|
|
// The following are normally supplied in the WU template:
|
2004-02-15 19:22:01 +00:00
|
|
|
[ -rsc_fpops_est x ]
|
|
|
|
[ -rsc_fpops_bound x ]
|
|
|
|
[ -rsc_memory_bound x ]
|
|
|
|
[ -rsc_disk_bound x ]
|
|
|
|
[ -delay_bound x ]
|
|
|
|
[ -min_quorum x ]
|
|
|
|
[ -target_nresults x ]
|
|
|
|
[ -max_error_results x ]
|
|
|
|
[ -max_total_results x ]
|
|
|
|
[ -max_success_results x ]
|
2004-04-13 23:55:05 +00:00
|
|
|
|
2004-02-09 05:11:05 +00:00
|
|
|
infile_1 ... infile_m // input files
|
|
|
|
</pre>
|
2004-02-15 19:22:01 +00:00
|
|
|
The workunit parameters are documented <a href=work.php>here</a>.
|
2005-02-01 21:11:08 +00:00
|
|
|
The program must be run in the project root directory.
|
2004-02-15 19:22:01 +00:00
|
|
|
|
2002-05-24 04:29:10 +00:00
|
|
|
<p>
|
2004-11-25 07:47:52 +00:00
|
|
|
The C++ library (crypt.C, backend_lib.C,h) provides the functions:
|
2002-05-24 04:29:10 +00:00
|
|
|
<pre>
|
2003-01-09 21:48:33 +00:00
|
|
|
int read_key_file(char* path, R_RSA_PRIVATE_KEY& key);
|
|
|
|
|
2002-05-24 04:29:10 +00:00
|
|
|
int create_work(
|
2004-07-10 07:27:00 +00:00
|
|
|
DB_WORKUNIT&,
|
|
|
|
const char* wu_template, // contents, not path
|
|
|
|
const char* result_template_filename, // relative to project root
|
|
|
|
const char* result_template_filepath, // absolute,
|
|
|
|
// or relative to current dir
|
|
|
|
const char* infile_dir, // where input files are
|
|
|
|
const char** infiles, // array of input file names
|
2002-05-24 04:29:10 +00:00
|
|
|
int ninfiles
|
2003-01-09 21:48:33 +00:00
|
|
|
R_RSA_PRIVATE_KEY& key, // upload authentication key
|
2004-11-25 07:47:52 +00:00
|
|
|
SCHED_CONFIG&
|
2002-05-24 04:29:10 +00:00
|
|
|
);
|
2002-11-07 19:31:34 +00:00
|
|
|
</pre>
|
2002-05-24 04:29:10 +00:00
|
|
|
<p>
|
2003-01-09 21:48:33 +00:00
|
|
|
<b>read_key_file()</b> reads a private key from a file.
|
|
|
|
Use this to read the file upload authentication key.
|
|
|
|
<p>
|
|
|
|
<b>create_work()</b>
|
|
|
|
creates a workunit and one or more results.
|
2002-11-07 19:31:34 +00:00
|
|
|
The arguments are similar to those of the utility program;
|
2003-01-09 21:48:33 +00:00
|
|
|
some of the information is passed in the WORKUNIT structure,
|
|
|
|
namely the following fields:
|
|
|
|
<pre>
|
|
|
|
name
|
2003-01-14 23:50:33 +00:00
|
|
|
appid
|
|
|
|
batch
|
2003-01-09 21:48:33 +00:00
|
|
|
rsc_fpops
|
|
|
|
rsc_iops
|
|
|
|
rsc_memory
|
|
|
|
rsc_disk
|
|
|
|
delay_bound
|
|
|
|
</pre>
|
2003-01-14 23:50:33 +00:00
|
|
|
All other fields should be zeroed.
|
2004-04-13 21:31:55 +00:00
|
|
|
|
2003-08-19 06:44:58 +00:00
|
|
|
";
|
2004-04-13 21:31:55 +00:00
|
|
|
|
2003-08-19 06:44:58 +00:00
|
|
|
page_tail();
|
|
|
|
?>
|