IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33600


Ignore:
Timestamp:
Mar 23, 2012, 2:19:56 PM (14 years ago)
Author:
eugene
Message:

improve verbosity; clear some memory leaks in parallel ops

Location:
branches/eam_branches/ipp-20111122/Ohana/src
Files:
1 added
23 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/libdvo/include/dvo.h

    r33574 r33600  
    628628HostTable    *HostTableLoad (char *catdir, char *rootname);
    629629int HostTableWaitJobs (HostTable *table, char *file, int lineno);
    630 int HostTableWaitJobsGetIO (HostTable *table, char *file, int lineno);
     630int HostTableWaitJobsGetIO (HostTable *table, char *file, int lineno, int VERBOSE);
    631631int HostTableTestHost (SkyRegion *region, int hostID);
    632632
  • branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/HostTable.c

    r33584 r33600  
    2929}
    3030
     31void FreeTable (HostTable *table) {
     32
     33  if (!table) return;
     34  if (table->hosts) {
     35    FreeHosts (table->hosts, table->Nhosts);
     36  }
     37  if (table->index) free (table->index);
     38  free (table);
     39  return;
     40}
     41
    3142HostTable *HostTableLoad (char *catdir, char *rootname) {
    3243
     
    4152  if (!f) {
    4253    fprintf (stderr, "failed to open host table %s\n", filename);
     54    free (filename);
    4355    return NULL;
    4456  }
     
    7385      fprintf (stderr, "error reading line %d of host table %s\n", Nline, filename);
    7486      FreeHosts (hosts, Nhosts);
     87      free (filename);
    7588      return NULL;
    7689    }
     
    119132  }
    120133
     134  free (filename);
    121135  return table;
    122136}
     
    196210
    197211// wait for all children to complete, report output to stdout
    198 int HostTableWaitJobsGetIO (HostTable *table, char *file, int lineno) {
     212int HostTableWaitJobsGetIO (HostTable *table, char *file, int lineno, int VERBOSE) {
    199213
    200214  // we have launched table->Nhosts jobs; wait for all of them to complete...
     
    257271        // if (table->hosts[i].stdout.Nbuffer > 0x10000) {
    258272        if (table->hosts[i].stdout.Nbuffer > 0x1000) {
    259           fprintf (stdout, "--- stdout from %s ---\n", table->hosts[i].hostname);
     273          int printHead = VERBOSE || table->hosts[i].stdout.Nbuffer;
     274          if (printHead) fprintf (stdout, "--- stdout from %s ---\n", table->hosts[i].hostname);
    260275          write (STDOUT_FILENO, table->hosts[i].stdout.buffer, table->hosts[i].stdout.Nbuffer);
    261276          FlushIOBuffer (&table->hosts[i].stdout);
    262           fprintf (stdout, "\n");
     277          if (printHead) fprintf (stdout, "\n");
    263278        }
    264279      }
     
    269284        // if (table->hosts[i].stderr.Nbuffer > 0x10000) {
    270285        if (table->hosts[i].stderr.Nbuffer > 0x1000) {
    271           fprintf (stdout, "--- stderr from %s ---\n", table->hosts[i].hostname);
     286          int printHead = VERBOSE || table->hosts[i].stderr.Nbuffer;
     287          if (printHead) fprintf (stdout, "--- stderr from %s ---\n", table->hosts[i].hostname);
    272288          write (STDOUT_FILENO, table->hosts[i].stderr.buffer, table->hosts[i].stderr.Nbuffer);
    273289          FlushIOBuffer (&table->hosts[i].stderr);
    274           fprintf (stdout, "\n");
     290          if (printHead) fprintf (stdout, "\n");
    275291        }
    276292      }
     
    301317
    302318        // check on the status of this and report any output?
    303         fprintf (stdout, "job finished for %s (%d)\n", host->hostname, pid);
     319        if (VERBOSE) fprintf (stdout, "job finished for %s (%d)\n", host->hostname, pid);
    304320
    305321        // read stdout
     322        int printHead;
     323        printHead = VERBOSE || host->stdout.Nbuffer;
    306324        EmptyIOBuffer (&host->stdout, 100, host->stdio[HOST_STDOUT]);
    307         fprintf (stdout, "--- stdout from %s ---\n", host->hostname);
     325        if (printHead) fprintf (stdout, "--- stdout from %s ---\n", host->hostname);
    308326        write (STDOUT_FILENO, host->stdout.buffer, host->stdout.Nbuffer);
    309327        FlushIOBuffer (&host->stdout);
    310         fprintf (stdout, "\n");
     328        if (printHead) fprintf (stdout, "\n");
    311329           
    312330        // read stderr
     331        printHead = VERBOSE || host->stderr.Nbuffer;
    313332        EmptyIOBuffer (&host->stderr, 100, host->stdio[HOST_STDERR]);
    314         fprintf (stdout, "--- stderr from %s ---\n", host->hostname);
     333        if (printHead) fprintf (stdout, "--- stderr from %s ---\n", host->hostname);
    315334        write (STDOUT_FILENO, host->stderr.buffer, host->stderr.Nbuffer);
    316335        FlushIOBuffer (&host->stderr);
    317         fprintf (stdout, "\n");
     336        if (printHead) fprintf (stdout, "\n");
    318337
    319338        if (WIFEXITED(status)) {
    320           fprintf (stdout, "normal completion, exit status is %d\n", WEXITSTATUS(status));
     339          if (VERBOSE) fprintf (stdout, "normal completion, exit status is %d\n", WEXITSTATUS(status));
    321340          host->status = WEXITSTATUS(status);
    322341          if (host->status) {
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.data/Makefile

    r31635 r33600  
    123123$(SRC)/swapbytes.$(ARCH).o         \
    124124$(SRC)/textline.$(ARCH).o          \
     125$(SRC)/threshold.$(ARCH).o              \
    125126$(SRC)/tv.$(ARCH).o                \
    126127$(SRC)/tvchannel.$(ARCH).o         \
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.data/cumulative.c

    r20936 r33600  
    2323    opihi_flt *Vi = ivec[0].elements.Flt;
    2424    *Vo = *Vi;
     25    Vi++;
     26    Vo++;
    2527    for (i = 1; i < ivec[0].Nelements; i++, Vi++, Vo++) {
    2628      *Vo = Vo[-1] + *Vi;
     
    2931    opihi_int *Vi = ivec[0].elements.Int;
    3032    *Vo = *Vi;
     33    Vi++;
     34    Vo++;
    3135    for (i = 1; i < ivec[0].Nelements; i++, Vi++, Vo++) {
    3236      *Vo = Vo[-1] + *Vi;
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.data/init.c

    r33476 r33600  
    112112int swapbytes        PROTO((int, char **));
    113113int textline         PROTO((int, char **));
     114int threshold        PROTO((int, char **));
    114115int tv               PROTO((int, char **));
    115116int tvchannel        PROTO((int, char **));
     
    262263  {1, "swapbytes",    swapbytes,        "byte swap thing"},
    263264  {1, "textline",     textline,         "write text line on graph"},
     265  {1, "threshold",    threshold,        "find (interpolate) location of transition"},
    264266  {1, "tv",           tv,               "display an image on the Kii window"},
    265267  {1, "tvchannel",    tvchannel,        "set the current tv channel"},
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/cmd.data/line.c

    r13479 r33600  
    33int line (int argc, char **argv) {
    44 
    5   int kapa;
     5  int kapa, N;
    66  Graphdata graphmode;
    77  float x[2], y[2];
     8
     9  /* FracPositions uses coordinates of 0-1 relative to axis range */
     10  int FracPositions = FALSE;
     11  if ((N = get_argument (argc, argv, "-frac"))) {
     12    remove_argument (N, &argc, argv);
     13    FracPositions = TRUE;
     14  }
    815
    916  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
     
    1825  y[1] = atof(argv[5]);
    1926
     27  if (FracPositions) {
     28    x[0] =  x[0] * (graphmode.xmax - graphmode.xmin) + graphmode.xmin;
     29    y[0] =  y[0] * (graphmode.ymax - graphmode.ymin) + graphmode.ymin;
     30    x[1] =  x[1] * (graphmode.xmax - graphmode.xmin) + graphmode.xmin;
     31    y[1] =  y[1] * (graphmode.ymax - graphmode.ymin) + graphmode.ymin;
     32  }   
     33
    2034  /* set point style and errorbar mode (these are NOT sticky) */
    2135  graphmode.style = 0;
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/Makefile

    r33543 r33600  
    5252$(SRC)/gimages.$(ARCH).o                \
    5353$(SRC)/gstar.$(ARCH).o                  \
     54$(SRC)/hosts.$(ARCH).o          \
    5455$(SRC)/images.$(ARCH).o         \
    5556$(SRC)/imbox.$(ARCH).o                  \
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/avextract.c

    r33583 r33600  
    4141    remove_argument (N, &argc, argv);
    4242    PARALLEL = TRUE;
     43  }
     44
     45  // use remote tables, but not dvo_client..
     46  int PARALLEL_LOCAL = FALSE;
     47  HostTable *table = NULL;
     48  if ((N = get_argument (argc, argv, "-parallel-local"))) {
     49    remove_argument (N, &argc, argv);
     50    PARALLEL_LOCAL = TRUE;
     51
     52    char *CATDIR = GetCATDIR();
     53    if (!CATDIR) {
     54      gprint (GP_ERR, "CATDIR is not set\n");
     55      return FALSE;
     56    }
     57    SkyTable *sky = GetSkyTable();
     58    if (!sky) {
     59      gprint (GP_ERR, "failed to load sky table for database\n");
     60      return FALSE;
     61    }
     62    table = HostTableLoad (CATDIR, sky->hosts);
     63    if (!table) {
     64      gprint (GP_ERR, "ERROR: failure reading Host Table %s for database %s\n", sky->hosts, CATDIR);
     65      return FALSE;
     66    }   
    4367  }
    4468
     
    96120  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
    97121  if (PARALLEL && !HOST_ID) {
    98     int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0);
     122    int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
    99123
    100124    dbFreeFields (fields, Nfields);
     
    141165    /* lock, load, unlock catalog */
    142166    char hostfile[1024];
     167    if (PARALLEL_LOCAL) {
     168      int hostID = skylist[0].regions[i]->hostID;
     169      int seq = table->index[hostID];
     170      HOSTDIR = table->hosts[seq].pathname;
     171    }
    143172    snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name);
    144     catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i];
     173    catalog.filename = (HOST_ID || PARALLEL_LOCAL) ? hostfile : skylist[0].filename[i];
    145174    catalog.catflags = LOAD_AVES | LOAD_SECF;
    146175    if (needMeasures) {
     
    205234  }
    206235
     236  if (table) free (table);
    207237  if (vec) free (vec);
    208238  if (values) free (values);
     
    215245
    216246 escape:
     247  if (table) free (table);
    217248  if (vec) free (vec);
    218249  if (values) free (values);
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/avmatch.c

    r33583 r33600  
    9292
    9393    // I need to pass the RA & DEC vectors to the remote clients...
    94     int status = HostTableParallelOps (argc, argv, RESULT_FILE, RAvec->Nelements);
     94    int status = HostTableParallelOps (argc, argv, RESULT_FILE, RAvec->Nelements, VERBOSE);
    9595    if (vec) free (vec);
    9696   
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/dvo_host_utils.c

    r33564 r33600  
    6969// concatenated, but for avmatch, the vectors are merged by index into a pre-known
    7070// length.  this is probably not a solution to a general problem..
    71 int HostTableParallelOps (int argc, char **argv, char *ResultFile, int Nelements) {
     71int HostTableParallelOps (int argc, char **argv, char *ResultFile, int Nelements, int VERBOSE) {
    7272
    7373  int i;
     
    135135  }
    136136  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    137     HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     137    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    138138  }
    139139
     
    146146    int    Ninvec = 0;
    147147    Vector **invec = ReadVectorTableFITS (table->hosts[i].results, "RESULT", &Ninvec);
     148    if (!invec) {
     149      // failed to read the file, now what?
     150      gprint (GP_ERR, "failed to read remote result file : %s\n", table->hosts[i].results);
     151      free (table->hosts[i].results);
     152      table->hosts[i].results = NULL;
     153      continue;
     154    }
    148155    free (table->hosts[i].results);
    149156    table->hosts[i].results = NULL;
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/init.c

    r31450 r33600  
    2727int gstar           PROTO((int, char **));
    2828int gtypes          PROTO((int, char **));
     29int hosts           PROTO((int, char **));
    2930int images          PROTO((int, char **));
    3031int imbox           PROTO((int, char **));
     
    7980  {1, "gimages",     gimages,      "get images at location"},
    8081  {1, "gstar",       gstar,        "get star statistics"},
     82  {1, "hosts",       hosts,        "remote host support functions"},
    8183  {1, "images",      images,       "plot image boxes"},
    8284  {1, "imbox",       imbox,        "plot expected image box"},
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/dvo/mextract.c

    r33583 r33600  
    9898  // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
    9999  if (PARALLEL && !HOST_ID) {
    100     int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0);
     100    int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
    101101
    102102    dbFreeFields (fields, Nfields);
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/include/dvoshell.h

    r33563 r33600  
    100100
    101101int          HostTableLaunchJobs    PROTO((HostTable *table, char *basecmd, char *options));
    102 int          HostTableParallelOps   PROTO((int argc, char **argv, char *ResultFile, int Nelements));
     102int          HostTableParallelOps   PROTO((int argc, char **argv, char *ResultFile, int Nelements, int VERBOSE));
    103103# endif
  • branches/eam_branches/ipp-20111122/Ohana/src/opihi/lib.shell/VectorOps.c

    r33543 r33600  
    122122  /* is an old vector */
    123123  if (mode == NEWVECTOR) goto error;
     124  if (vectors[i]) {
     125    if (vectors[i][0].elements.Ptr) free (vectors[i][0].elements.Ptr);
     126    free (vectors[i]);
     127  }
    124128  vectors[i] = vec;
    125129  return TRUE;
     
    351355  }
    352356
    353   myAssert (*Nvec == Ninvec, "programming error (1)");
     357  myAssert (*Nvec == Ninvec, "programming error (1) %d vs %d", *Nvec, Ninvec);
    354358
    355359  for (i = 0; i < Ninvec; i++) {
    356     myAssert (!strcmp(vec[i]->name, invec[i]->name), "programming error (2)");
    357     myAssert (vec[i]->type == invec[i]->type, "programming error (2)");
     360    myAssert (!strcmp(vec[i]->name, invec[i]->name), "programming error (2) %s vs %s", vec[i]->name, invec[i]->name);
     361    myAssert (vec[i]->type == invec[i]->type, "programming error (3), %d vs %d", vec[i]->type, invec[i]->type);
    358362
    359363    int N = vec[i]->Nelements;
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/photdbc_catalogs.c

    r33585 r33600  
    121121    if (PHOTCODE_DROP_LIST) { snprintf (tmpline, MAX_PATH_LENGTH, "%s -photcode-drop %s", command, PHOTCODE_DROP_LIST);         strcpy (command, tmpline); }
    122122    if (PHOTCODE_SKIP_LIST) { snprintf (tmpline, MAX_PATH_LENGTH, "%s -photcode-skip %s", command, PHOTCODE_SKIP_LIST);         strcpy (command, tmpline); }
    123     if (CATFORMAT)          { snprintf (tmpline, MAX_PATH_LENGTH, "%s -catformat %s",     command, CATFORMAT);                  strcpy (command, tmpline); }
    124     if (CATMODE)            { snprintf (tmpline, MAX_PATH_LENGTH, "%s -catmode %s",       command, CATMODE);                    strcpy (command, tmpline); }
     123    if (CATFORMAT)          { snprintf (tmpline, MAX_PATH_LENGTH, "%s -set-format %s",    command, CATFORMAT);                  strcpy (command, tmpline); }
     124    if (CATMODE)            { snprintf (tmpline, MAX_PATH_LENGTH, "%s -set-mode %s",      command, CATMODE);                    strcpy (command, tmpline); }
    125125
    126126    fprintf (stderr, "command: %s\n", command);
     
    151151  }
    152152  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    153     HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     153    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    154154  }
    155155
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/UpdateObjectOffsets.c

    r33580 r33600  
    159159  }
    160160  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    161     HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     161    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    162162  }
    163163
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/high_speed_catalogs.c

    r33580 r33600  
    196196  }
    197197  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    198     HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     198    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    199199  }
    200200
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/load_catalogs.c

    r33580 r33600  
    201201  }
    202202  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    203     HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     203    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    204204  }
    205205
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/relastro_objects.c

    r33580 r33600  
    187187  }
    188188  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    189     HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     189    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    190190  }
    191191
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/load_catalogs.c

    r33581 r33600  
    190190  }
    191191  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    192     HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     192    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    193193  }
    194194
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/reload_catalogs.c

    r33581 r33600  
    201201  }
    202202  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    203     HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     203    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    204204  }
    205205  return (TRUE);
  • branches/eam_branches/ipp-20111122/Ohana/src/relphot/src/relphot_objects.c

    r33581 r33600  
    181181  }
    182182  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    183     HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     183    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    184184  }
    185185
  • branches/eam_branches/ipp-20111122/Ohana/src/uniphot/src/update_dvo_setphot.c

    r33582 r33600  
    147147  }
    148148  if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
    149     int status = HostTableWaitJobsGetIO (table, __FILE__, __LINE__);
     149    int status = HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    150150    if (!status) return FALSE;
    151151  }
Note: See TracChangeset for help on using the changeset viewer.