Changeset 33475
- Timestamp:
- Mar 10, 2012, 2:56:07 PM (14 years ago)
- Location:
- branches/eam_branches/ipp-20111122/Ohana/src
- Files:
-
- 6 edited
-
libdvo/include/dvo.h (modified) (3 diffs)
-
libdvo/src/HostTable.c (modified) (7 diffs)
-
relastro/Makefile (modified) (3 diffs)
-
relastro/include/relastro.h (modified) (1 diff)
-
relastro/src/high_speed_catalogs.c (modified) (1 diff)
-
relastro/src/initialize.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/libdvo/include/dvo.h
r33454 r33475 242 242 } SkyTableDataFlags; 243 243 244 typedef enum { 245 HOST_STDIN = 0, 246 HOST_STDOUT = 1, 247 HOST_STDERR = 2, 248 } HostInfoIOfd; 249 244 250 typedef struct { 245 251 char *hostname; // name of remote machine … … 249 255 int pid; // remote process ID 250 256 int status; // job exit status 257 IOBuffer stdout; 258 IOBuffer stderr; 251 259 } HostInfo; 252 260 … … 614 622 HostTable *HostTableLoad (char *catdir, char *rootname); 615 623 int HostTableWaitJobs (HostTable *table, char *file, int lineno); 624 int HostTableWaitJobsGetIO (HostTable *table, char *file, int lineno); 616 625 617 626 // functions to support tiny versions of Average and Measure -
branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c
r33474 r33475 9 9 hosts[i].hostname = NULL; 10 10 hosts[i].pathname = NULL; 11 hosts[i].stdio[ 0] = -1;12 hosts[i].stdio[ 1] = -1;13 hosts[i].stdio[ 2] = -1;11 hosts[i].stdio[HOST_STDIN] = -1; 12 hosts[i].stdio[HOST_STDOUT] = -1; 13 hosts[i].stdio[HOST_STDERR] = -1; 14 14 hosts[i].pid = 0; 15 15 } … … 91 91 hosts[Nhosts].pathname = strcreate(tmppath); 92 92 93 InitIOBuffer (&hosts[Nhosts].stdout, 1000); 94 InitIOBuffer (&hosts[Nhosts].stderr, 1000); 95 93 96 Nhosts ++; 94 97 if (Nhosts >= NHOSTS) { … … 146 149 } 147 150 } 151 152 // when the host has finished, close the open sockets 148 153 149 154 // find the host which has finished … … 158 163 IOBuffer buffer; 159 164 InitIOBuffer (&buffer, 100); 160 EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[ 1]);165 EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[HOST_STDOUT]); 161 166 fprintf (stderr, "--- stdout from %s ---\n", table->hosts[j].hostname); 162 167 write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer); … … 164 169 165 170 InitIOBuffer (&buffer, 100); 166 EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[ 2]);171 EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[HOST_STDERR]); 167 172 fprintf (stderr, "--- stderr from %s ---\n", table->hosts[j].hostname); 168 173 write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer); … … 192 197 int HostTableWaitJobsGetIO (HostTable *table, char *file, int lineno) { 193 198 194 int i;195 196 199 // we have launched table->Nhosts jobs; wait for all of them to complete... 197 200 // if one (N) failed to launch, we will get an ECHILD error from the last (N) calls … … 201 204 // timeouts for both 202 205 206 // add all hosts' sockets to the fd_sets 207 fd_set rdSet, wtSet; 208 FD_ZERO (&rdSet); 209 FD_ZERO (&wtSet); 210 211 // XXX can I set the fd_sets once, since I am not actually closing the fd's? 212 213 int i; 214 int Nmax = 0; 215 for (i = 0; i < table->Nhosts; i++) { 216 FD_SET (table->hosts[i].stdio[HOST_STDIN], &wtSet); 217 Nmax = MAX (Nmax, table->hosts[i].stdio[HOST_STDIN]); 218 FD_SET (table->hosts[i].stdio[HOST_STDOUT], &rdSet); 219 Nmax = MAX (Nmax, table->hosts[i].stdio[HOST_STDOUT]); 220 FD_SET (table->hosts[i].stdio[HOST_STDERR], &rdSet); 221 Nmax = MAX (Nmax, table->hosts[i].stdio[HOST_STDERR]); 222 } 223 Nmax ++; 224 225 int Nfound = 0; 226 227 // this loop has 2 chunks: (a) check for I/O + (b) check for jobs done 203 228 while (1) { 204 229 205 // is anyone done? 206 int status = 0; 207 208 // XXX we'll need to pass in WNOHANG and keep retrying if we want to have a timeout... 209 int pid = waitpid (-1, &status, WNOHANG); 210 if (pid) { 211 if (pid == -1) { 212 switch (errno) { 213 case ECHILD: 214 done = TRUE; 215 // no more children, need to exit ... 216 break; 217 default: 218 fprintf (stderr, "programming error (2)? %s %d", file, lineno); 219 exit (2); 230 // Wait up to 0.5 second for host to provide I/O 231 // timeout gets mucked: need to reset before each select 232 struct timeval timeout; 233 timeout.tv_sec = 10; 234 timeout.tv_usec = 500000; 235 236 int status = select (Nmax, &rdSet, &wtSet, NULL, &timeout); 237 if (status == -1) { 238 perror("select()"); 239 exit (2); 240 } 241 242 // we have some sockets to check, check sockets for all hosts 243 for (i = 0; (status > 0) && (i < table->Nhosts); i++) { 244 if (FALSE && FD_ISSET (table->hosts[i].stdio[HOST_STDIN], &wtSet)) { 245 // this host is waiting for input : this is an error, so exit 246 fprintf (stderr, "host %s is waiting for input\n", table->hosts[i].hostname); 247 abort(); 248 } 249 250 if (FD_ISSET (table->hosts[i].stdio[HOST_STDOUT], &rdSet)) { 251 // this host has waiting output : read to buffer, and dump if necessary 252 ReadtoIOBuffer (&table->hosts[i].stdout, table->hosts[i].stdio[HOST_STDOUT]); 253 if (table->hosts[i].stdout.Nbuffer > 0x10000) { 254 fprintf (stdout, "--- stdout from %s ---\n", table->hosts[i].hostname); 255 write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer); 256 fprintf (stdout, "\n"); 220 257 } 221 } else { 222 // handle 223 224 225 226 // find the host which has finished 227 int j; 228 int found = FALSE; 229 for (j = 0; j < table->Nhosts; j++) { 230 if (table->hosts[j].pid != pid) continue; 231 found = TRUE; 232 // check on the status of this and report any output? 233 fprintf (stderr, "job finished for %s (%d)\n", table->hosts[j].hostname, pid); 234 // read the stderr and stdout 235 IOBuffer buffer; 236 InitIOBuffer (&buffer, 100); 237 EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[1]); 238 fprintf (stderr, "--- stdout from %s ---\n", table->hosts[j].hostname); 239 write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer); 240 fprintf (stderr, "\n"); 241 242 InitIOBuffer (&buffer, 100); 243 EmptyIOBuffer (&buffer, 100, table->hosts[j].stdio[2]); 244 fprintf (stderr, "--- stderr from %s ---\n", table->hosts[j].hostname); 245 write (STDOUT_FILENO, buffer.buffer, buffer.Nbuffer); 246 fprintf (stderr, "\n"); 247 if (WIFEXITED(status)) { 248 fprintf (stderr, "normal completion, exit status is %d\n", WEXITSTATUS(status)); 249 table->hosts[j].status = WEXITSTATUS(status); 250 if (table->hosts[j].status) { 251 fprintf (stderr, "job failed on %s\n", table->hosts[j].hostname); 258 } 259 260 if (FD_ISSET (table->hosts[i].stdio[HOST_STDERR], &rdSet)) { 261 // this host has waiting output : read to buffer, and dump if necessary 262 ReadtoIOBuffer (&table->hosts[i].stderr, table->hosts[i].stdio[HOST_STDERR]); 263 if (table->hosts[i].stderr.Nbuffer > 0x10000) { 264 fprintf (stdout, "--- stderr from %s ---\n", table->hosts[i].hostname); 265 write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer); 266 fprintf (stdout, "\n"); 267 } 268 } 269 } 270 271 // now check if any children have finished... 272 while (TRUE) { 273 int status = 0; 274 int pid = waitpid (-1, &status, WNOHANG); 275 if (!pid) { 276 break; // no outstanding jobs have finished 277 fprintf (stderr, "no hosts to harvest\n"); 278 usleep (500000); 279 } 280 if ((pid == -1) && (errno == ECHILD)) goto escape; // no more jobs on which to wait 281 if ((pid == -1) && (errno != ECHILD)) { 282 fprintf (stderr, "programming error (2)? %s %d", file, lineno); 283 exit (2); 284 } 285 286 // find the host which has finished 287 int j; 288 int found = FALSE; 289 for (j = 0; (j < table->Nhosts) && !found; j++) { 290 if (table->hosts[j].pid != pid) continue; 291 found = TRUE; 292 293 // check on the status of this and report any output? 294 fprintf (stdout, "job finished for %s (%d)\n", table->hosts[j].hostname, pid); 295 296 // read stdout 297 EmptyIOBuffer (&table->hosts[j].stdout, 100, table->hosts[j].stdio[HOST_STDOUT]); 298 fprintf (stdout, "--- stdout from %s ---\n", table->hosts[j].hostname); 299 write (STDOUT_FILENO, table->hosts[j].stdout.buffer, table->hosts[j].stdout.Nbuffer); 300 fprintf (stdout, "\n"); 301 302 // read stderr 303 EmptyIOBuffer (&table->hosts[j].stderr, 100, table->hosts[j].stdio[HOST_STDERR]); 304 fprintf (stdout, "--- stderr from %s ---\n", table->hosts[j].hostname); 305 write (STDOUT_FILENO, table->hosts[j].stderr.buffer, table->hosts[j].stderr.Nbuffer); 306 fprintf (stdout, "\n"); 307 308 if (WIFEXITED(status)) { 309 fprintf (stdout, "normal completion, exit status is %d\n", WEXITSTATUS(status)); 310 table->hosts[j].status = WEXITSTATUS(status); 311 if (table->hosts[j].status) { 312 fprintf (stdout, "job failed on %s\n", table->hosts[j].hostname); 313 } 314 } else { 315 table->hosts[j].status = -1; 316 fprintf (stdout, "job exited abnormally on %s\n", table->hosts[j].hostname); 252 317 continue; 253 318 } 254 } else {255 table->hosts[j].status = -1; 256 fprintf (stderr, " job exited abnormally on %s\n", table->hosts[j].hostname);257 continue;258 } 259 }260 if (!found) {261 fprintf (stderr, "Programming error: failed to matched finished job to known host!\n");262 exit (2);263 } 264 } 319 } 320 if (!found) { 321 fprintf (stderr, "Programming error: failed to matched finished job to known host!\n"); 322 exit (2); 323 } 324 Nfound ++; 325 if (Nfound == table->Nhosts) goto escape; // we've harvested all jobs 326 } 327 } 328 329 escape: 265 330 return TRUE; 266 331 } -
branches/eam_branches/ipp-20111122/Ohana/src/relastro/Makefile
r33448 r33475 71 71 #$(SRC)/write_coords.$(ARCH).o \ 72 72 73 $(RELASTRO): $(INC)/relastro.h $(KAPA_INCS)74 $(BIN)/relastro.$(ARCH): $(RELASTRO) $(KAPA_LIBS)73 $(RELASTRO): $(INC)/relastro.h 74 $(BIN)/relastro.$(ARCH): $(RELASTRO) 75 75 76 76 RELASTRO_CLIENT = \ … … 122 122 #$(SRC)/StarMaps.$(ARCH).o \ 123 123 124 $(RELASTRO_CLIENT): $(INC)/relastro.h $(KAPA_INCS)125 $(BIN)/relastro_client.$(ARCH): $(RELASTRO_CLIENT) $(KAPA_LIBS)124 $(RELASTRO_CLIENT): $(INC)/relastro.h 125 $(BIN)/relastro_client.$(ARCH): $(RELASTRO_CLIENT) 126 126 127 127 testparallax: $(BIN)/testparallax.$(ARCH) … … 134 134 $(SRC)/testparallax.$(ARCH).o 135 135 136 $(TESTPAR): $(INC)/relastro.h $(KAPA_INCS)137 $(BIN)/testparallax.$(ARCH): $(TESTPAR) $(KAPA_LIBS)136 $(TESTPAR): $(INC)/relastro.h 137 $(BIN)/testparallax.$(ARCH): $(TESTPAR) -
branches/eam_branches/ipp-20111122/Ohana/src/relastro/include/relastro.h
r33448 r33475 418 418 int BrightCatalogSplit (CatalogSplitter *catalogs, BrightCatalog *bcatalog); 419 419 int BrightCatalogSplitFree (CatalogSplitter *catalogs); 420 421 PhotCode **ParsePhotcodeList (char *rawlist, int *nphotcodes); -
branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/high_speed_catalogs.c
r33473 r33475 161 161 } 162 162 if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) { 163 HostTableWaitJobs (table, __FILE__, __LINE__);163 HostTableWaitJobsGetIO (table, __FILE__, __LINE__); 164 164 } 165 165 -
branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/initialize.c
r33473 r33475 2 2 3 3 void initialize (int argc, char **argv) { 4 5 int NPHOTCODES;6 char *codename, *ptr, *list;7 8 ptr = NULL;9 4 10 5 ConfigInit (&argc, argv); … … 48 43 void initialize_client (int argc, char **argv) { 49 44 50 int NPHOTCODES;51 char *codename, *ptr, *list;52 53 ptr = NULL;54 55 45 ConfigInit (&argc, argv); 56 46 args_client (argc, argv); … … 73 63 } 74 64 75 PhotCode * ParsePhotcodeList (char *rawlist, int *nphotcodes) {65 PhotCode **ParsePhotcodeList (char *rawlist, int *nphotcodes) { 76 66 77 67 *nphotcodes = 0; 78 68 if (!rawlist) return NULL; 79 69 80 Nphotcodes = 0; 81 photcodes = NULL; 70 int Nphotcodes = 0; 82 71 int NPHOTCODES = 10; 72 PhotCode **photcodes = NULL; 83 73 ALLOCATE (photcodes, PhotCode *, NPHOTCODES); 84 74
Note:
See TracChangeset
for help on using the changeset viewer.
