仕事の生成 |
|
プロジェクトのテスト期間中においては、 仕事の供給を定常的に維持するため、所与のワークユニットから複製を作りつづける make_work デーモンを使うことができます。 このデーモンは、テストの最中と、アプリケーションのデバッグのときに有用です。
ワークユニットのテンプレートファイルは、以下の例の形をしています。
<file_info>
<number>0</number>
[ <sticky/>, other attributes]
</file_info>
[ ... ]
<workunit>
<file_ref>
<file_number>0</file_number>
<open_name>NAME</open_name>
</file_ref>
[ ... ]
[ <command_line>-flags xyz</command_line> ]
[ <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> ]
[ <max_success_results>x</max_success_results> ]
</workunit>
上記に含まれる要素は以下のとおりです:
| <file_info>, <file_ref> | それぞれの対が、入力ファイル と それを指し示す名前 の 1組を表現します。 |
| <command_line> | 主プログラムに渡されるコマンドライン引数です。 |
| その他の要素 | ワークユニット属性 |
ワークユニットのデータベース・レコードには 'xml_doc_in' というフィールドがあり、 そこには、ワークユニットの入力ファイルの記述が、XML 形式で格納されています。 それはリザルトのテンプレートから以下のように導出されます。
リザルトのテンプレートファイルは、以下の形をしています。
<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>
リザルトのデータベース・レコードには 'xml_doc_in' というフィールドがあり、 そこには、リザルトの出力ファイルの記述が、XML 形式で格納されています。 それはリザルトのテンプレートから以下のように導出されます。
dir_hier_path(
const char* filename,
const char* root, // ダウンロードディレクトリのルート
int fanout, // config.xml から得た値
char* result, // 階層の中に置くべきファイルの位置
bool create_dir=false // ディレクトリが無いときにそれを作るか否か
);
スクリプトを使っているならば、下記のプログラムを呼ぶこともできます。
dir_hier_path filenameこのプログラムはフルパス名を出力し、必要ならそのディレクトリを作ります。 このプログラムは、プロジェクトのルートディレクトリで走らせて下さい。 たとえば、
cp test_workunits/12ja04aa `bin/dir_hier_path 12ja04aa`とすれば、入力ファイルを test_workunits ディレクトリから、 階層化してあるダウンロードディレクトリの中へ複写します。
ワークユニットは、スクリプト(create_work プログラムを使うもの)
を使って作るか、プログラム(create_work 関数を呼ぶもの)
を走らせて作ります。
入力ファイルはあらかじめ階層化されたダウンロードディレクトリになければなりません。
そのユーティリティ・プログラムとは、以下のものです。
create_work
-appname name // アプリケーション名
-wu_name name // ワークユニット名
-wu_template filename // WU テンプレートファイル名
// project root からの相対。 普通は、template/ 内 です。
-result_template filename // リザルトのテンプレートファイル名
// project root からの相対。 普通は、template/ 内 です。
[ -config_dir path ] // 'config.xml' の位置。 省略時の解釈は、'.'
[ -batch n ]
[ -priority n ]
// これ以降は、ワークユニットテンプレート ファイルの中から与えてもよく、
// あるいは、create_work へのコマンドライン引数として与えることもできます。
// さらにどこにも与えなくても構いません(省略時の解釈が適用されます)
[ -command_line "-flags foo" ]
[ -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 ]
infile_1 ... infile_m // 入力ファイル群
ワークユニットのパラメタは、左記のリンクの先で説明されています。
このプログラムは、プロジェクトのルートディレクトリで走らせる必要があります。
BOINC の ライブラリ (backend_lib.C,h) は以下の関数を提供します:
int create_work(
DB_WORKUNIT&,
const char* wu_template, // 内容そのもの, パスではない
const char* result_template_filename, // project rootに対する相対名
const char* result_template_filepath, // 絶対パス または カレントディレクトリからの相対パス
const char** infiles, // 入力ファイル名の配列
int ninfiles
SCHED_CONFIG&,
const char* command_line = NULL
);
create_work() 関数は ワークユニットを1つ 生成します。
引数は、ユーティリティ・プログラムのものと似ています。
それらのうち、いくつかの情報は WORKUNIT 構造体で運ばれます。
この構造体のフィールドは以下のとおりです:
name appid以下のものは、DB_WORKUNIT 構造体の中、または、ワークユニットのテンプレートファイルの中に入れて渡されます。
rsc_fpops_est rsc_fpops_bound rsc_memory_bound rsc_disk_bound batch delay_bound min_quorum target_nresults max_error_results max_total_results max_success_results
以下に、ワークユニットを1つ生成するプログラムの例を示します。 (明解にするため誤り検査は省略してあります)。
#include "backend_lib.h"
main() {
DB_APP app;
DB_WORKUNIT wu;
char wu_template[LARGE_BLOB_SIZE];
char* infiles[] = {"infile"};
SCHED_CONFIG config;
config.parse_file();
boinc_db.open(config.db_name, config.db_host, config.db_passwd);
app.lookup("where name='myappname'");
wu.clear(); // zeroes all fields
wu.appid = app.id;
wu.min_quorum = 2;
wu.target_nresults = 2;
wu.max_error_results = 5;
wu.max_total_results = 5;
wu.max_success_results = 5;
wu.rsc_fpops_est = 1e10;
wu.rsc_fpops_bound = 1e11;
wu.rsc_memory_bound = 1e8;
wu.rsc_disk_bound = 1e8;
wu.delay_bound = 7*86400;
read_filename("templates/wu_template.xml", wu_template, sizeof(wu_template));
create_work(
wu,
wu_template,
"templates/results_template.xml",
"templates/results_template.xml",
infiles,
1,
config
);
}
|
たくさんのワークユニットを生成しているなら(たとえば、並列計算の種々の部分を実施するためなどに)、 ワークユニットの種類によって入力ファイルが違ったり、コマンドライン引数が異なったり、 あるいはその両方、ということをしたくなるでしょう。
例えば、あるプログラムを 10個の入力ファイル 'file0', 'file1', ..., 'file9' に対して走らせたいとしましょう。 あなたは、前述のプログラムを以下のように直そうとするかもしれません。
char filename[256];
char* infiles[1];
infiles[0] = filename;
...
for (i=0; i<10; i++) {
sprintf(filename, "file%d", i);
create_work(
wu,
wu_template,
"templates/results_template.xml",
"templates/results_template.xml",
infiles,
1,
config
);
}
|
次に、あるプログラムを 1つの入力ファイルについて実行し、 10個のコマンドラインオプションの変種 '-flag 0', '-flag 1', ..., '-flag 9' で 起動したいとしましょう。 あなたは、前述のプログラムを以下のように直そうとするかもしれません。
char command_line[256];
...
for (i=0; i<10; i++) {
sprintf(command_line, "-flag %d", i);
create_work(
wu,
wu_template,
"templates/results_template.xml",
"templates/results_template.xml",
infiles,
1,
config,
command_line
);
}
|
最終更新時刻 00:51:52, 2006年08月12日(JST)
Copyright © 2008 University of California.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License,
Version 1.2 or any later version published by the Free Software Foundation.
Copyright © 2008 Komori Hitoshi(je2bwm at jarl.com).
Japanese translation from English web pages on BOINC.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License,
Version 1.2 or any later version published by the Free Software Foundation.