IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34654


Ignore:
Timestamp:
Nov 5, 2012, 5:47:27 AM (14 years ago)
Author:
eugene
Message:

option to remote command to avoid loading results (but save the remote result names)

Location:
branches/eam_branches/ipp-20120905/Ohana/src/opihi
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.astro

  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/avextract.c

    r34405 r34654  
    137137  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
    138138  if (PARALLEL && !HOST_ID) {
    139     int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
     139    int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);
    140140
    141141    dbFreeFields (fields, Nfields);
  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/avmatch.c

    r34468 r34654  
    9595
    9696    // I need to pass the RA & DEC vectors to the remote clients...
    97     int status = HostTableParallelOps (argc, argv, RESULT_FILE, RAvec->Nelements, VERBOSE);
     97    int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, RAvec->Nelements, VERBOSE);
    9898    if (vec) free (vec);
    9999   
  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/dvo_host_utils.c

    r34260 r34654  
    7979}
    8080
    81 // bundle the arguments into a command and pass to dvo_client.  this implementation
    82 // expects there to be a result file from the clients, and to load this into vectors in
    83 // the main shell.  'Nelements' is a temp hack : for most commands, the result vectors are
    84 // concatenated, but for avmatch, the vectors are merged by index into a pre-known
    85 // length.  this is probably not a solution to a general problem..
    86 int HostTableParallelOps (int argc, char **argv, char *ResultFile, int Nelements, int VERBOSE) {
     81// bundle the arguments into a command and pass to dvo_client. 
     82
     83// the normal ending step expects there to be a result file from the clients, and to load
     84// this into vectors in the main shell.  'Nelements' is a temp hack : for most commands,
     85// the result vectors are concatenated, but for avmatch, the vectors are merged by index
     86// into a pre-known length.  this is probably not a solution to a general problem..
     87
     88// an alternative ending step ignores the result files and instead saves the names into
     89// the list 'result:n' for the user to access as desired
     90int HostTableParallelOps (int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE) {
    8791
    8892  int i;
     
    153157  }
    154158
     159  // create the result file list
     160  char name[256];
     161  snprintf (name, 256, "RESULT_FILE:n");
     162  set_int_variable (name, table->Nhosts);
     163  snprintf (name, 256, "RESULT_DATA:n");
     164  set_int_variable (name, table->Nhosts);
     165  snprintf (name, 256, "RESULT_STATUS:n");
     166  set_int_variable (name, table->Nhosts);
     167
    155168  // load fields from file
    156169  int    Nvec = 0;
    157170  Vector **vec = NULL;
    158171  for (i = 0; i < table->Nhosts; i++) {
     172
     173    snprintf (name, 256, "RESULT_FILE:%d", i);
     174    set_str_variable (name, table->hosts[i].results);
     175
     176    // DATA : 0 (unread), 1 (read)
     177    snprintf (name, 256, "RESULT_DATA:%d", i);
     178    set_int_variable (name, 0);
     179
     180    // STATUS : 0 (normal exit), -1 (crash), N (failure exit status)
     181    snprintf (name, 256, "RESULT_STATUS:%d", i);
     182    set_int_variable (name, table->hosts[i].status);
     183
    159184    if (table->hosts[i].status) continue;
     185
     186    if (ReadVectors) {
     187      int    Ninvec = 0;
     188      Vector **invec = ReadVectorTableFITS (table->hosts[i].results, "RESULT", &Ninvec);
     189      if (!invec) {
     190        // failed to read the file, now what?
     191        gprint (GP_ERR, "failed to read remote result file : %s\n", table->hosts[i].results);
     192        free (table->hosts[i].results);
     193        table->hosts[i].results = NULL;
     194        continue;
     195      }
     196      free (table->hosts[i].results);
     197      table->hosts[i].results = NULL;
     198      set_int_variable (name, 1); // result file has been read
     199
     200      if (Nelements == 0) {
     201        vec = MergeVectors (vec, &Nvec, invec, Ninvec);
     202        if (vec != invec) {
     203          FreeVectorArray (invec, Ninvec);
     204        }
     205      } else {
     206        vec = MergeVectorsByIndex (vec, &Nvec, invec, Ninvec, Nelements);
     207        FreeVectorArray (invec, Ninvec);
     208      }
     209    }
     210  }
     211
     212  // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)
     213  if (ResultFile) {
     214    int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, NULL);
     215    if (!status) {
     216      gprint (GP_ERR, "failed to write result file %s\n", ResultFile);
     217      return FALSE;
     218    }
     219  }
     220
     221  for (i = 0; i < Nvec; i++) {
     222    AssignVector (vec[i], vec[i]->name, ANYVECTOR, TRUE);
     223  }
     224  free (vec);
     225
     226  free (table);
     227  return TRUE;
     228}
     229
     230// re-gather the remote results files: this can be used in case one of the clients failed,
     231// and has since been re-run
     232int HostTableReloadResults (char *uniquer, int VERBOSE) {
     233
     234  int i;
     235
     236  // load the list of hosts
     237  SkyTable *sky = GetSkyTable();
     238  if (!sky) {
     239    gprint (GP_ERR, "failed to load sky table for database\n");
     240    return FALSE;
     241  }
     242
     243  char *CATDIR = GetCATDIR ();
     244  if (!CATDIR) {
     245    gprint (GP_ERR, "failed to get CATDIR for database\n");
     246    return FALSE;
     247  }
     248
     249  HostTable *table = HostTableLoad (CATDIR, sky->hosts);
     250  if (!table) {
     251    gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
     252    return FALSE;
     253  }   
     254
     255  // load fields from file
     256  int    Nvec = 0;
     257  Vector **vec = NULL;
     258  for (i = 0; i < table->Nhosts; i++) {
     259    // ensure that the paths are absolute path names
     260    char *tmppath = abspath (table->hosts[i].pathname, DVO_MAX_PATH);
     261    free (table->hosts[i].pathname);
     262    table->hosts[i].pathname = tmppath;
     263
     264    // need to save the results filename with the uniquer
     265    // XXX a bit of a waste (but only 1024 * 60 bytes or so
     266    ALLOCATE (table->hosts[i].results, char, DVO_MAX_PATH);
     267    snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer);
    160268
    161269    int    Ninvec = 0;
     
    171279    table->hosts[i].results = NULL;
    172280
    173     if (Nelements == 0) {
    174       vec = MergeVectors (vec, &Nvec, invec, Ninvec);
    175       if (vec != invec) {
    176         FreeVectorArray (invec, Ninvec);
    177       }
    178     } else {
    179       vec = MergeVectorsByIndex (vec, &Nvec, invec, Ninvec, Nelements);
     281    // fprintf (stderr, "%s : %d\n", table->hosts[i].pathname, invec[0]->Nelements);
     282
     283    vec = MergeVectors (vec, &Nvec, invec, Ninvec);
     284    if (vec != invec) {
    180285      FreeVectorArray (invec, Ninvec);
    181     }
    182   }
    183 
    184   // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere)
    185   if (ResultFile) {
    186     int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, NULL);
    187     if (!status) {
    188       gprint (GP_ERR, "failed to write result file %s\n", ResultFile);
    189       return FALSE;
    190286    }
    191287  }
     
    199295  return TRUE;
    200296}
    201 
    202 // re-gather the remote results files: this can be used in case one of the clients failed,
    203 // and has since been re-run
    204 int HostTableReloadResults (char *uniquer, int VERBOSE) {
    205 
    206   int i;
    207 
    208   // load the list of hosts
    209   SkyTable *sky = GetSkyTable();
    210   if (!sky) {
    211     gprint (GP_ERR, "failed to load sky table for database\n");
    212     return FALSE;
    213   }
    214 
    215   char *CATDIR = GetCATDIR ();
    216   if (!CATDIR) {
    217     gprint (GP_ERR, "failed to get CATDIR for database\n");
    218     return FALSE;
    219   }
    220 
    221   HostTable *table = HostTableLoad (CATDIR, sky->hosts);
    222   if (!table) {
    223     gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
    224     return FALSE;
    225   }   
    226 
    227   // load fields from file
    228   int    Nvec = 0;
    229   Vector **vec = NULL;
    230   for (i = 0; i < table->Nhosts; i++) {
    231     // ensure that the paths are absolute path names
    232     char *tmppath = abspath (table->hosts[i].pathname, DVO_MAX_PATH);
    233     free (table->hosts[i].pathname);
    234     table->hosts[i].pathname = tmppath;
    235 
    236     // need to save the results filename with the uniquer
    237     // XXX a bit of a waste (but only 1024 * 60 bytes or so
    238     ALLOCATE (table->hosts[i].results, char, DVO_MAX_PATH);
    239     snprintf (table->hosts[i].results, DVO_MAX_PATH, "%s/dvo.results.%s.fits", table->hosts[i].pathname, uniquer);
    240 
    241     int    Ninvec = 0;
    242     Vector **invec = ReadVectorTableFITS (table->hosts[i].results, "RESULT", &Ninvec);
    243     if (!invec) {
    244       // failed to read the file, now what?
    245       gprint (GP_ERR, "failed to read remote result file : %s\n", table->hosts[i].results);
    246       free (table->hosts[i].results);
    247       table->hosts[i].results = NULL;
    248       continue;
    249     }
    250     free (table->hosts[i].results);
    251     table->hosts[i].results = NULL;
    252 
    253     // fprintf (stderr, "%s : %d\n", table->hosts[i].pathname, invec[0]->Nelements);
    254 
    255     vec = MergeVectors (vec, &Nvec, invec, Ninvec);
    256     if (vec != invec) {
    257       FreeVectorArray (invec, Ninvec);
    258     }
    259   }
    260 
    261   for (i = 0; i < Nvec; i++) {
    262     AssignVector (vec[i], vec[i]->name, ANYVECTOR, TRUE);
    263   }
    264   free (vec);
    265 
    266   free (table);
    267   return TRUE;
    268 }
  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/mextract.c

    r34260 r34654  
    108108  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
    109109  if (PARALLEL && !HOST_ID) {
    110     int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
     110    int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);
    111111
    112112    dbFreeFields (fields, Nfields);
  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/mmatch.c

    r34468 r34654  
    124124
    125125    // call the remote client
    126     int status = HostTableParallelOps (targc, targv, RESULT_FILE, 0, VERBOSE);
     126    int status = HostTableParallelOps (targc, targv, RESULT_FILE, TRUE, 0, VERBOSE);
    127127    if (vec) free (vec);
    128128   
  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/dvo/remote.c

    r33963 r34654  
    1212    remove_argument (N, &argc, argv);
    1313    VERBOSE = TRUE;
     14  }
     15
     16  int ReadVectors = TRUE;
     17  if ((N = get_argument (argc, argv, "-skip-result"))) {
     18    remove_argument (N, &argc, argv);
     19    ReadVectors = FALSE;
    1420  }
    1521
     
    4349
    4450  // strip of the 'remote' and send the remaining arguments to the remote machine
    45   int status = HostTableParallelOps (argc - 1, &argv[1], NULL, 0, VERBOSE);
     51  int status = HostTableParallelOps (argc - 1, &argv[1], NULL, ReadVectors, 0, VERBOSE);
    4652  return status;
    4753}
  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/include/dvoshell.h

    r33963 r34654  
    100100
    101101int          HostTableLaunchJobs    PROTO((HostTable *table, char *basecmd, char *options, int VERBOSE));
    102 int          HostTableParallelOps   PROTO((int argc, char **argv, char *ResultFile, int Nelements, int VERBOSE));
     102int          HostTableParallelOps   PROTO((int argc, char **argv, char *ResultFile, int ReadVectors, int Nelements, int VERBOSE));
    103103int          HostTableReloadResults PROTO((char *uniquer, int VERBOSE));
    104104
Note: See TracChangeset for help on using the changeset viewer.