00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifdef HAS_PVM
00011
00012 #include "scatter3.h"
00013 #include "pvm_scatt.h"
00014 #include "pvm3.h"
00015 #include <unistd.h>
00016
00017 extern "C" int gethostname(char*, unsigned int);
00018
00019 #define FORCE_TIMEOUT 0
00020 #define TIME_TIMEOUT 100 // (seconds)
00021
00022 void main()
00023 {
00024
00025
00026 char name[100];
00027 gethostname(name, 100);
00028
00029 pvm_initsend(PvmDataRaw);
00030 pvm_pkstr(name);
00031 pvm_send(pvm_parent(), HANDSHAKE_MSG);
00032
00033 while (1) {
00034
00035
00036
00037 int bufid = pvm_recv(pvm_parent(), -1);
00038
00039 int length, msgid, source;
00040 int info = pvm_bufinfo(bufid, &length, &msgid, &source);
00041
00042 if (info < 0 || msgid != SEND_DATA_MSG || source != pvm_parent()) {
00043 pvm_exit();
00044 exit(0);
00045 }
00046
00047
00048
00049 int n_rand;
00050 pvm_upkint(&n_rand, 1, 1);
00051
00052 initial_state3 init;
00053 unpack(init);
00054
00055 real cpu_time_check, dt_out, dt_snap, snap_cube_size;
00056 pvm_upkdouble(&cpu_time_check, 1, 1);
00057 pvm_upkdouble(&dt_snap, 1, 1);
00058 pvm_upkdouble(&snap_cube_size, 1, 1);
00059
00060
00061
00062
00063
00064
00065
00066 intermediate_state3 inter;
00067 final_state3 final;
00068 real cpu_scatter = cpu_time();
00069
00070 int result = single_scatter(init, inter, final,
00071 cpu_time_check, dt_snap, snap_cube_size);
00072 cpu_scatter = cpu_time() - cpu_scatter;
00073
00074
00075
00076
00077 #if FORCE_TIMEOUT
00078
00079
00080
00081 if (cpu_scatter > TIME_TIMEOUT) {
00082
00083
00084
00085 real x = 0;
00086 for (int j = 0; j < 1000000; j++)
00087 for (int i = 0; i < 1000000000; i++)
00088 x += sqrt(0.1*i + j);
00089
00090 cpu_scatter = x;
00091
00092 }
00093
00094 #endif
00095
00096
00097
00098 pvm_initsend(PvmDataRaw);
00099
00100 pvm_pkint(&n_rand, 1, 1);
00101
00102 pack(init);
00103 pack(inter);
00104 pack(final);
00105
00106 pvm_pkint(&result, 1, 1);
00107 pvm_pkdouble(&cpu_scatter, 1, 1);
00108
00109
00110
00111 if (pvm_send(pvm_parent(), RETURN_DATA_MSG) < 0) {
00112 cerr << "Error returning data from " << name << endl;
00113 cerr << "CPU time = " << cpu_scatter << endl;
00114 }
00115
00116 }
00117 }
00118
00119 #else
00120
00121 #include "stdinc.h"
00122
00123 void main()
00124 {
00125 err_exit("PVM not available");
00126 }
00127
00128 #endif