Skip to content

Commit 7140e76

Browse files
Various BUDA-related bugs and enhancements
- client: include resource_usage in WORKUNIT::write() - docker_wrapper: on Mac need to use full paths for mounts. But on Win, full path includes :, which breaks the -v command! So use . for current dir - client: add sub_appname to WORKUNIT. This is the BUDA app long name. - create_work: add --sub_appname arg; adds it to the <workunit> - buda_submit.php: pass --sub_appname to create_work
1 parent 369991c commit 7140e76

File tree

6 files changed

+104
-54
lines changed

6 files changed

+104
-54
lines changed

client/client_types.cpp

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,11 @@ void RESOURCE_USAGE::clear() {
797797
missing_coproc_name[0] = 0;
798798
}
799799

800-
void RESOURCE_USAGE::check_gpu(char* plan_class) {
800+
// see if we have the GPU libraries (OpenCL/CUDA/CAL)
801+
// required by the plan class.
802+
// If not, set missing_coproc
803+
//
804+
void RESOURCE_USAGE::check_gpu_libs(char* plan_class) {
801805
int rt = rsc_type;
802806
if (!rt) return;
803807
if (strstr(plan_class, "opencl")) {
@@ -827,6 +831,41 @@ void RESOURCE_USAGE::check_gpu(char* plan_class) {
827831
}
828832
}
829833

834+
void RESOURCE_USAGE::write(MIOFILE& out) {
835+
out.printf(
836+
" <avg_ncpus>%f</avg_ncpus>\n"
837+
" <flops>%f</flops>\n",
838+
avg_ncpus,
839+
flops
840+
);
841+
if (rsc_type) {
842+
out.printf(
843+
" <coproc>\n"
844+
" <type>%s</type>\n"
845+
" <count>%f</count>\n"
846+
" </coproc>\n",
847+
rsc_name(rsc_type),
848+
coproc_usage
849+
);
850+
}
851+
if (missing_coproc && strlen(missing_coproc_name)) {
852+
out.printf(
853+
" <coproc>\n"
854+
" <type>%s</type>\n"
855+
" <count>%f</count>\n"
856+
" </coproc>\n",
857+
missing_coproc_name,
858+
coproc_usage
859+
);
860+
}
861+
if (gpu_ram) {
862+
out.printf(
863+
" <gpu_ram>%f</gpu_ram>\n",
864+
gpu_ram
865+
);
866+
}
867+
}
868+
830869
void APP_VERSION::init() {
831870
safe_strcpy(app_name, "");
832871
version_num = 0;
@@ -858,7 +897,7 @@ int APP_VERSION::parse(XML_PARSER& xp) {
858897
init();
859898
while (!xp.get_tag()) {
860899
if (xp.match_tag("/app_version")) {
861-
resource_usage.check_gpu(plan_class);
900+
resource_usage.check_gpu_libs(plan_class);
862901
if (resource_usage.rsc_type || is_wrapper) {
863902
dont_throttle = true;
864903
}
@@ -944,14 +983,10 @@ int APP_VERSION::write(MIOFILE& out, bool write_file_info) {
944983
"<app_version>\n"
945984
" <app_name>%s</app_name>\n"
946985
" <version_num>%d</version_num>\n"
947-
" <platform>%s</platform>\n"
948-
" <avg_ncpus>%f</avg_ncpus>\n"
949-
" <flops>%f</flops>\n",
986+
" <platform>%s</platform>\n",
950987
app_name,
951988
version_num,
952-
platform,
953-
resource_usage.avg_ncpus,
954-
resource_usage.flops
989+
platform
955990
);
956991
if (strlen(plan_class)) {
957992
out.printf(" <plan_class>%s</plan_class>\n", plan_class);
@@ -971,32 +1006,7 @@ int APP_VERSION::write(MIOFILE& out, bool write_file_info) {
9711006
if (retval) return retval;
9721007
}
9731008
}
974-
if (resource_usage.rsc_type) {
975-
out.printf(
976-
" <coproc>\n"
977-
" <type>%s</type>\n"
978-
" <count>%f</count>\n"
979-
" </coproc>\n",
980-
rsc_name(resource_usage.rsc_type),
981-
resource_usage.coproc_usage
982-
);
983-
}
984-
if (resource_usage.missing_coproc && strlen(resource_usage.missing_coproc_name)) {
985-
out.printf(
986-
" <coproc>\n"
987-
" <type>%s</type>\n"
988-
" <count>%f</count>\n"
989-
" </coproc>\n",
990-
resource_usage.missing_coproc_name,
991-
resource_usage.coproc_usage
992-
);
993-
}
994-
if (resource_usage.gpu_ram) {
995-
out.printf(
996-
" <gpu_ram>%f</gpu_ram>\n",
997-
resource_usage.gpu_ram
998-
);
999-
}
1009+
resource_usage.write(out);
10001010
if (dont_throttle) {
10011011
out.printf(
10021012
" <dont_throttle/>\n"
@@ -1172,7 +1182,7 @@ int WORKUNIT::parse(XML_PARSER& xp) {
11721182
|| resource_usage.rsc_type!=0
11731183
|| resource_usage.missing_coproc;
11741184
if (has_resource_usage) {
1175-
resource_usage.check_gpu(plan_class);
1185+
resource_usage.check_gpu_libs(plan_class);
11761186
}
11771187
return 0;
11781188
}
@@ -1203,6 +1213,7 @@ int WORKUNIT::parse(XML_PARSER& xp) {
12031213
continue;
12041214
}
12051215
if (xp.parse_str("plan_class", plan_class, sizeof(plan_class))) continue;
1216+
if (xp.parse_str("sub_appname", sub_appname, sizeof(sub_appname))) continue;
12061217
if (xp.parse_double("avg_ncpus", resource_usage.avg_ncpus)) continue;
12071218
if (xp.parse_double("flops", dtemp)) {
12081219
if (dtemp <= 0) {
@@ -1286,6 +1297,13 @@ int WORKUNIT::write(MIOFILE& out, bool gui) {
12861297
for (i=0; i<input_files.size(); i++) {
12871298
input_files[i].write(out);
12881299
}
1300+
if (strlen(sub_appname)) {
1301+
out.printf(
1302+
" <sub_appname>%s</sub_appname>\n",
1303+
sub_appname
1304+
);
1305+
}
1306+
resource_usage.write(out);
12891307

12901308
if (!job_keyword_ids.empty()) {
12911309
if (gui) {

client/client_types.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ struct RESOURCE_USAGE {
330330
char missing_coproc_name[256];
331331

332332
void clear();
333-
void check_gpu(char* plan_class);
333+
void check_gpu_libs(char* plan_class);
334+
void write(MIOFILE&);
334335
};
335336

336337
// if you add anything, initialize it in init()
@@ -407,10 +408,14 @@ struct WORKUNIT {
407408
int version_num;
408409
// Deprecated, but need to keep around to let people revert
409410
// to versions before multi-platform support
410-
bool has_resource_usage;
411+
412+
// the following for BUDA jobs
413+
char sub_appname[256];
411414
char plan_class[256];
412-
// for BUDA jobs, the BUDA variant
415+
// the BUDA variant
416+
bool has_resource_usage;
413417
RESOURCE_USAGE resource_usage;
418+
414419
std::string command_line;
415420
std::vector<FILE_REF> input_files;
416421
PROJECT* project;
@@ -423,10 +428,11 @@ struct WORKUNIT {
423428
JOB_KEYWORD_IDS job_keyword_ids;
424429

425430
WORKUNIT(){
426-
safe_strcpy(name, "");
427-
safe_strcpy(app_name, "");
431+
name[0] = 0;
432+
app_name[0] = 0;
428433
version_num = 0;
429434
has_resource_usage = false;
435+
sub_appname[0] = 0;
430436
plan_class[0] = 0;
431437
resource_usage.clear();
432438
command_line.clear();

html/user/buda_submit.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
require_once('../inc/util.inc');
2222
require_once('../inc/submit_util.inc');
2323
require_once('../inc/sandbox.inc');
24+
require_once('../inc/buda.inc');
2425

2526
display_errors();
2627

@@ -191,7 +192,7 @@ function stage_input_files($batch_dir, $batch_desc, $batch_id) {
191192
// Use --stdin, where each job is described by a line
192193
//
193194
function create_jobs(
194-
$app, $variant, $variant_desc,
195+
$app, $app_desc, $variant, $variant_desc,
195196
$batch_desc, $batch_id, $batch_dir_name,
196197
$wrapper_verbose, $cmdline
197198
) {
@@ -221,15 +222,17 @@ function create_jobs(
221222
}
222223
$job_cmds .= "$job_cmd\n";
223224
}
224-
$cw_cmdline = sprintf('"--dockerfile %s %s %s"',
225+
$wrapper_cmdline = sprintf('"--dockerfile %s %s %s"',
225226
$variant_desc->dockerfile,
226227
$wrapper_verbose?'--verbose':'',
227228
$cmdline
228229
);
229230
$cmd = sprintf(
230-
'cd ../..; bin/create_work --appname %s --batch %d --stdin --command_line %s --wu_template %s --result_template %s',
231-
$buda_boinc_app->name, $batch_id,
232-
$cw_cmdline,
231+
'cd ../..; bin/create_work --appname %s --sub_appname "%s" --batch %d --stdin --command_line %s --wu_template %s --result_template %s',
232+
$buda_boinc_app->name,
233+
$app_desc->long_name,
234+
$batch_id,
235+
$wrapper_cmdline,
233236
"buda_apps/$app/$variant/template_in",
234237
"buda_apps/$app/$variant/template_out"
235238
);
@@ -250,6 +253,8 @@ function create_jobs(
250253
}
251254

252255
function handle_submit($user) {
256+
global $buda_root;
257+
253258
$app = get_str('app');
254259
if (!is_valid_filename($app)) die('bad arg');
255260
$variant = get_str('variant');
@@ -259,7 +264,9 @@ function handle_submit($user) {
259264
$wrapper_verbose = get_str('wrapper_verbose', true);
260265
$cmdline = get_str('cmdline');
261266

262-
$variant_dir = "../../buda_apps/$app/$variant";
267+
$app_desc = get_buda_desc($app);
268+
269+
$variant_dir = "$buda_root/$app/$variant";
263270
$variant_desc = json_decode(
264271
file_get_contents("$variant_dir/variant.json")
265272
);
@@ -280,7 +287,7 @@ function handle_submit($user) {
280287
stage_input_files($batch_dir, $batch_desc, $batch->id);
281288

282289
create_jobs(
283-
$app, $variant, $variant_desc,
290+
$app, $app_desc, $variant, $variant_desc,
284291
$batch_desc, $batch->id, $batch_dir_name,
285292
$wrapper_verbose, $cmdline
286293
);

samples/docker_wrapper/docker_wrapper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,13 @@ int create_container() {
375375
if (retval) return retval;
376376

377377
// on MacOS/podman, you need the full path, not .
378+
// Win: use . since full path has :
378379
//
380+
#ifdef __APPLE__
379381
getcwd(cwd, sizeof(cwd));
382+
#else
383+
strcpy(cwd, ".");
384+
#endif
380385
snprintf(slot_cmd, sizeof(slot_cmd), " -v %s:%s", cwd, config.workdir.c_str());
381386
if (config.project_dir_mount.empty()) {
382387
project_cmd[0] = 0;

tools/backend_lib.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
// You should have received a copy of the GNU Lesser General Public License
1616
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
1717

18+
// functions called from backend programs (scheduler, transitioner etc.)
19+
// to create result records and other utilities
20+
1821
#include "config.h"
1922
#include "boinc_stdio.h"
2023
#include <cstdlib>
@@ -28,7 +31,6 @@
2831
#include <sys/types.h>
2932
#include <sys/stat.h>
3033

31-
3234
#include "boinc_db.h"
3335
#include "common_defs.h"
3436
#include "crypt.h"

tools/create_work.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ void usage() {
9696
" [ --rsc_memory_bound x ]\n"
9797
" [ --size_class n ]\n"
9898
" [ --stdin ]\n"
99+
" [ --sub_appname 'foo bar' ]\n"
99100
" [ --target_host ID ]\n"
100101
" [ --target_nresults n ]\n"
101102
" [ --target_team ID ]\n"
@@ -143,16 +144,18 @@ struct JOB_DESC {
143144
bool assign_multi;
144145
int assign_id;
145146
int assign_type;
147+
char sub_appname[256];
146148

147149
JOB_DESC() {
148150
wu.clear();
149-
strcpy(command_line, "");
151+
command_line[0] = 0;
150152
assign_flag = false;
151153
assign_multi = false;
152-
strcpy(wu_template_file, "");
153-
strcpy(result_template_file, "");
154+
wu_template_file[0] = 0;
155+
result_template_file[0] = 0;
154156
assign_id = 0;
155157
assign_type = ASSIGN_NONE;
158+
sub_appname[0] = 0;
156159

157160
// defaults (in case they're not in WU template)
158161
//
@@ -312,8 +315,6 @@ int main(int argc, char** argv) {
312315
jd.wu.max_total_results = atoi(argv[++i]);
313316
} else if (arg(argv, i, "max_success_results")) {
314317
jd.wu.max_success_results = atoi(argv[++i]);
315-
} else if (arg(argv, i, "opaque")) {
316-
jd.wu.opaque = atoi(argv[++i]);
317318
} else if (arg(argv, i, "command_line")) {
318319
strcpy(jd.command_line, argv[++i]);
319320
} else if (arg(argv, i, "wu_id")) {
@@ -367,6 +368,8 @@ int main(int argc, char** argv) {
367368
continue_on_error = true;
368369
} else if (arg(argv, i, "keywords")) {
369370
strcpy(jd.wu.keywords, argv[++i]);
371+
} else if (arg(argv, i, "sub_appname")) {
372+
strcpy(jd.sub_appname, argv[++i]);
370373
} else {
371374
if (!strncmp("-", argv[i], 1)) {
372375
fprintf(stderr, "create_work: bad argument '%s'\n", argv[i]);
@@ -578,14 +581,23 @@ void JOB_DESC::create() {
578581
if (assign_flag) {
579582
wu.transitioner_flags = assign_multi?TRANSITION_NONE:TRANSITION_NO_NEW_RESULTS;
580583
}
584+
char sub_appname_buf[256];
585+
sub_appname_buf[0] = 0;
586+
if (strlen(sub_appname)) {
587+
snprintf(sub_appname_buf, sizeof(sub_appname_buf),
588+
" <sub_appname>%s</sub_appname>",
589+
sub_appname
590+
);
591+
}
581592
int retval = create_work2(
582593
wu,
583594
wu_template,
584595
result_template_file,
585596
result_template_path,
586597
infiles,
587598
config,
588-
command_line
599+
command_line,
600+
sub_appname_buf
589601
);
590602
if (retval) {
591603
fprintf(stderr, "create_work: %s\n", boincerror(retval));

0 commit comments

Comments
 (0)