mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=249
This commit is contained in:
parent
220acccd58
commit
9bce75fdf1
|
@ -17,7 +17,7 @@ LIBS = ../api/api.o ../lib/parse.o
|
|||
|
||||
CLIBS = @LIBS@
|
||||
|
||||
APPS = upper_case concat uc_slow concat_slow 1sec
|
||||
APPS = upper_case concat uc_slow concat_slow 1sec uc_cpu
|
||||
|
||||
.C.o:
|
||||
$(CC) -c -o $*.o $<
|
||||
|
@ -38,6 +38,9 @@ concat_slow: concat_slow.o
|
|||
uc_slow: uc_slow.o
|
||||
$(CC) uc_slow.o $(LIBS) -o uc_slow
|
||||
|
||||
uc_cpu: uc_cpu.o
|
||||
$(CC) uc_cpu.o $(LIBS) -o uc_cpu
|
||||
|
||||
1sec: 1sec.o
|
||||
$(CC) 1sec.o $(LIBS) -o 1sec
|
||||
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
// The contents of this file are subject to the Mozilla Public License
|
||||
// Version 1.0 (the "License"); you may not use this file except in
|
||||
// compliance with the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS"
|
||||
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
// License for the specific language governing rights and limitations
|
||||
// under the License.
|
||||
//
|
||||
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
||||
//
|
||||
// The Initial Developer of the Original Code is the SETI@home project.
|
||||
// Portions created by the SETI@home project are Copyright (C) 2002
|
||||
// University of California at Berkeley. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
//
|
||||
|
||||
// read "in", convert to UC, write to "out"
|
||||
//
|
||||
// This version does one char/second,
|
||||
// and writes its state to disk every so often
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "api.h"
|
||||
|
||||
#define CHECKPOINT_FILE "uc_slow_state"
|
||||
|
||||
int do_checkpoint(MFILE& mf, int nchars) {
|
||||
int retval;
|
||||
char resolved_name[512],res_name2[512];
|
||||
|
||||
boinc_resolve_link( "temp", resolved_name );
|
||||
FILE* f = fopen(resolved_name, "w");
|
||||
if (!f) return 1;
|
||||
fprintf(f, "%d", nchars);
|
||||
fclose(f);
|
||||
|
||||
fprintf(stderr, "APP: uc_slow checkpointing\n");
|
||||
|
||||
// hopefully atomic part starts here
|
||||
retval = mf.flush();
|
||||
if (retval) return retval;
|
||||
boinc_resolve_link( CHECKPOINT_FILE, res_name2 );
|
||||
retval = rename(resolved_name, res_name2);
|
||||
if (retval) return retval;
|
||||
// hopefully atomic part ends here
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int c, nchars = 0, retval, n, i;
|
||||
double j;
|
||||
char resolved_name[512];
|
||||
MFILE out, time_file;
|
||||
FILE* state, *in;
|
||||
APP_IN ai;
|
||||
APP_OUT ao;
|
||||
|
||||
boinc_init( ai );
|
||||
|
||||
boinc_resolve_link( "in", resolved_name );
|
||||
in = fopen(resolved_name, "r");
|
||||
boinc_resolve_link( CHECKPOINT_FILE, resolved_name );
|
||||
state = fopen(resolved_name, "r");
|
||||
if (state) {
|
||||
fscanf(state, "%d", &nchars);
|
||||
printf("nchars %d\n", nchars);
|
||||
fseek(in, nchars, SEEK_SET);
|
||||
boinc_resolve_link( "out", resolved_name );
|
||||
retval = out.open(resolved_name, "a");
|
||||
} else {
|
||||
boinc_resolve_link( "out", resolved_name );
|
||||
retval = out.open(resolved_name, "w");
|
||||
}
|
||||
fprintf(stderr, "APP: uc_slow starting\n");
|
||||
if (retval) {
|
||||
fprintf(stderr, "APP: uc_slow output open failed %d\n", retval);
|
||||
exit(1);
|
||||
}
|
||||
time_file.open("../../time.xml", "w");
|
||||
while (1) {
|
||||
c = fgetc(in);
|
||||
if (c == EOF) break;
|
||||
c = toupper(c);
|
||||
out._putchar(c);
|
||||
nchars++;
|
||||
|
||||
n = 0;
|
||||
j = 3.14159;
|
||||
for(i=0; i<10000000; i++) {
|
||||
n++;
|
||||
j *= n+j-3.14159;
|
||||
j /= (float)n;
|
||||
}
|
||||
|
||||
if (time_to_checkpoint()) {
|
||||
retval = do_checkpoint(out, nchars);
|
||||
if (retval) {
|
||||
fprintf(stderr, "APP: uc_slow checkpoint failed %d\n", retval);
|
||||
}
|
||||
ao.percent_done = 1;
|
||||
checkpoint_completed(ao);
|
||||
}
|
||||
}
|
||||
retval = out.flush();
|
||||
if (retval) {
|
||||
fprintf(stderr, "APP: uc_slow flush failed %d\n", retval);
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "APP: uc_slow ending, wrote %d chars\n", nchars);
|
||||
ao.percent_done = 1;
|
||||
app_completed(ao);
|
||||
time_file.printf("%f\n", ao.cpu_time_at_checkpoint);
|
||||
time_file.flush();
|
||||
time_file.close();
|
||||
return 0;
|
||||
}
|
|
@ -1268,4 +1268,7 @@ Michael Gary 7/24/2002
|
|||
init.inc
|
||||
apps/
|
||||
uc_slow.C
|
||||
uc_cpu.C (added)
|
||||
Makefile.in
|
||||
|
||||
|
||||
|
|
|
@ -246,11 +246,15 @@ function clean_api() {
|
|||
}
|
||||
|
||||
function compare_time() {
|
||||
$db_time=mysql_query("select cpu_time from result where name = ucs_wu_0");
|
||||
$epsilon = 0.0001;
|
||||
db_init();
|
||||
$data = mysql_query("select cpu_time from result where name = 'uccpu_wu_0'");
|
||||
$result = mysql_fetch_object($data);
|
||||
$db_time = $result->cpu_time;
|
||||
$time_file = fopen("time.xml", "r");
|
||||
fscanf($time_file, "%f", $app_time);
|
||||
if($db_time != $app_time) {
|
||||
printf("Time mismatch: app %d server %d\n", $app_time, $db_time);
|
||||
if(abs($db_time - $app_time) > $epsilon) {
|
||||
printf("Time mismatch: app %f server %f\n", $app_time, $db_time);
|
||||
}
|
||||
else printf("Times match\n");
|
||||
fclose($time_file);
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
add_platform(null);
|
||||
add_core_client(null);
|
||||
add_user("prefs.xml");
|
||||
add_app("uc_slow", null, null);
|
||||
create_work("-appname uc_slow -wu_name ucs_wu -wu_template ucs_wu -result_template ucs_result -nresults 1 small_input");
|
||||
add_app("uc_cpu", null, null);
|
||||
create_work("-appname uc_cpu -wu_name uccpu_wu -wu_template uccpu_wu -result_template uccpu_result -nresults 1 small_input");
|
||||
start_feeder();
|
||||
run_client("-exit_when_idle");
|
||||
compare_file("ucs_wu_0_0", "uc_small_correct_output");
|
||||
compare_file("uccpu_wu_0_0", "uc_small_correct_output");
|
||||
compare_time();
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue