IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33906


Ignore:
Timestamp:
May 23, 2012, 11:03:24 AM (14 years ago)
Author:
eugene
Message:

save Image IDmap in parallel mode so client need not load the full image table

Location:
branches/eam_branches/ipp-20120405/Ohana/src/dvomerge
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/Makefile

    r33900 r33906  
    3434$(SRC)/dvomergeImageIDs.$(ARCH).o \
    3535$(SRC)/dvo_image_merge_dbs.$(ARCH).o \
     36$(SRC)/IDmapIO.$(ARCH).o \
    3637$(SRC)/SetSignals.$(ARCH).o \
    3738$(SRC)/ConfigInit.$(ARCH).o \
     
    5657$(SRC)/dvomergeImageIDs.$(ARCH).o \
    5758$(SRC)/dvo_image_merge_dbs.$(ARCH).o \
     59$(SRC)/IDmapIO.$(ARCH).o \
    5860$(SRC)/SetSignals.$(ARCH).o \
    5961$(SRC)/ConfigInit.$(ARCH).o \
  • branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/include/dvomerge.h

    r33900 r33906  
    4242
    4343typedef struct {
    44   off_t Nmap;
    45   off_t *old;
    46   off_t *new;
     44  unsigned int Nmap;
     45  unsigned int *old;
     46  unsigned int *new;
    4747} IDmapType;
    4848
     
    125125int        dvomergeFromList       PROTO((int argc, char **argv));
    126126int        dvomergeUpdate_threaded PROTO((int argc, char **argv));
    127 int        dvomergeUpdate_catalogs PROTO((char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType IDmap, int *secfiltMap));
     127int        dvomergeUpdate_catalogs PROTO((char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType *IDmap, int *secfiltMap));
    128128
    129129int        replace_match           PROTO((Average *average_out, Measure *measure_out, Average *average_in, Measure *measure_in));
     130
     131int        IDmapSave               PROTO((char *filename, IDmapType *IDmap));
     132IDmapType *IDmapLoad               PROTO((char *filename));
  • branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c

    r33738 r33906  
    11# include "dvomerge.h"
    22
     3// utility functions
    34void sort_IDmap (IDmapType *IDmap);
    4 
    5 off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt) {
    6 
    7   // use bisection to find the starting entry by time
    8 
    9   off_t Nlo, Nhi, N;
    10 
    11   // find the last TGT before start
    12   Nlo = 0; Nhi = NimagesTgt;
    13   while (Nhi - Nlo > 10) {
    14     N = 0.5*(Nlo + Nhi);
    15     if (TgtTimes[N] < start) {
    16       Nlo = MAX(N, 0);
    17     } else {
    18       Nhi = MIN(N + 1, NimagesTgt);
    19     }
    20   }
    21 
    22   // check for the matched mosaic starting from Nlo
    23   // we may have to go much beyond Nlo since stop is not sorted
    24   // can we use a sorted version of stop to check when we are beyond the valid range??
    25   for (N = Nlo; N < NimagesTgt; N++) {
    26     if (TgtTimes[N] < start) continue;
    27     if (TgtTimes[N] > stop) return (-1);
    28     if (TgtCodes[N] != photcode) continue;
    29     return (TgtIndex[N]);
    30   }
    31   return (-1);
    32 }
    33 
    34 // sort two times vectors and an index by first time vector
    35 void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N) {
    36 
    37 # define SWAPFUNC(A,B){ e_time tmp_t; off_t tmp_i; short tmp_c;         \
    38   tmp_t = S[A]; S[A] = S[B]; S[B] = tmp_t; \
    39   tmp_i = I[A]; I[A] = I[B]; I[B] = tmp_i; \
    40   tmp_c = C[A]; C[A] = C[B]; C[B] = tmp_c; \
    41 }
    42 # define COMPARE(A,B)(S[A] < S[B])
    43 
    44   OHANA_SORT (N, COMPARE, SWAPFUNC);
    45 
    46 # undef SWAPFUNC
    47 # undef COMPARE
    48 
    49 }
     5void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N);
     6off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt);
    507
    518// we have two tables; 'tgt' contains some exposures from 'src' : find them and match a map
     
    7128  }
    7229
    73   ALLOCATE (IDmap->old, off_t, NimagesSrc);
    74   ALLOCATE (IDmap->new, off_t, NimagesSrc);
     30  ALLOCATE (IDmap->old, unsigned int, NimagesSrc);
     31  ALLOCATE (IDmap->new, unsigned int, NimagesSrc);
    7532  IDmap->Nmap = NimagesSrc;
    7633
     
    13087  }
    13188
    132   ALLOCATE (IDmap->old, off_t, Nimages);
    133   ALLOCATE (IDmap->new, off_t, Nimages);
     89  ALLOCATE (IDmap->old, unsigned int, Nimages);
     90  ALLOCATE (IDmap->new, unsigned int, Nimages);
    13491  IDmap->Nmap = Nimages;
    13592
     
    165122}
    166123
    167 // XXX isn't the map just ID_new = ID_old + offset ??
     124// map this ID to the new table
     125// XXX isn't the map just ID_new = ID_old + offset ?? (probably not)
    168126off_t dvo_map_image_ID (IDmapType *IDmap, off_t oldID) {
    169127
     
    199157}
    200158
     159// given a table of detections, update their image IDs based on the new map
    201160int dvo_update_image_IDs (IDmapType *IDmap, Catalog *catalog) {
    202161
     
    237196}
    238197
     198off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt) {
     199
     200  // use bisection to find the starting entry by time
     201
     202  off_t Nlo, Nhi, N;
     203
     204  // find the last TGT before start
     205  Nlo = 0; Nhi = NimagesTgt;
     206  while (Nhi - Nlo > 10) {
     207    N = 0.5*(Nlo + Nhi);
     208    if (TgtTimes[N] < start) {
     209      Nlo = MAX(N, 0);
     210    } else {
     211      Nhi = MIN(N + 1, NimagesTgt);
     212    }
     213  }
     214
     215  // check for the matched mosaic starting from Nlo
     216  // we may have to go much beyond Nlo since stop is not sorted
     217  // can we use a sorted version of stop to check when we are beyond the valid range??
     218  for (N = Nlo; N < NimagesTgt; N++) {
     219    if (TgtTimes[N] < start) continue;
     220    if (TgtTimes[N] > stop) return (-1);
     221    if (TgtCodes[N] != photcode) continue;
     222    return (TgtIndex[N]);
     223  }
     224  return (-1);
     225}
     226
     227// sort two times vectors and an index by first time vector
     228void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N) {
     229
     230# define SWAPFUNC(A,B){ e_time tmp_t; off_t tmp_i; short tmp_c;         \
     231  tmp_t = S[A]; S[A] = S[B]; S[B] = tmp_t; \
     232  tmp_i = I[A]; I[A] = I[B]; I[B] = tmp_i; \
     233  tmp_c = C[A]; C[A] = C[B]; C[B] = tmp_c; \
     234}
     235# define COMPARE(A,B)(S[A] < S[B])
     236
     237  OHANA_SORT (N, COMPARE, SWAPFUNC);
     238
     239# undef SWAPFUNC
     240# undef COMPARE
     241
     242}
     243
  • branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeImageIDs.c

    r33905 r33906  
    11# include "dvomerge.h"
    22
    3 /*** update the image table ***/
     3/*** generate the IDmap for the given databases, and update the output image table ***/
    44int dvomergeImagesUpdate (IDmapType *IDmap, char *input, char *output) {
    55
     
    5353}
    5454
    55 /*** update the image table ***/
     55/*** generate the map for the given 2 databases ***/
    5656int dvomergeImagesGetMap (IDmapType *IDmap, char *input, char *output) {
    5757
  • branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeUpdate.c

    r33834 r33906  
    105105  SetPhotcodeTable(NULL);
    106106
    107   dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, IDmap, secfiltMap);
     107  dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, &IDmap, secfiltMap);
    108108
    109109  // save the output sky table copy
  • branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c

    r33904 r33906  
    88// output tables
    99
    10 int dvomergeUpdate_parallel (char *input, char *output, SkyTable *outsky);
    11 
    12 int dvomergeUpdate_catalogs (char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType IDmap, int *secfiltMap) {
     10int dvomergeUpdate_parallel (char *input, char *output, SkyTable *outsky, IDmapType *IDmap);
     11
     12int dvomergeUpdate_catalogs (char *input, char *output, SkyTable *outsky, SkyList *inlist, int NsecfiltInput, int NsecfiltOutput, IDmapType *IDmap, int *secfiltMap) {
    1313
    1414  off_t i, j;
     
    1717
    1818  if (PARALLEL && !HOST_ID) {
    19     int status = dvomergeUpdate_parallel (input, output, outsky);
     19    int status = dvomergeUpdate_parallel (input, output, outsky, IDmap);
    2020    return status;
    2121  }
     
    145145      LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput);
    146146
    147       dvo_update_image_IDs (&IDmap, &incatalog);
     147      dvo_update_image_IDs (IDmap, &incatalog);
    148148      merge_catalogs_old (outlist[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap);
    149149
     
    185185}
    186186
    187 int dvomergeUpdate_parallel (char *input, char *output, SkyTable *outsky) {
    188 
    189   // launch the dvomergeUpdate_client jobs to the parallel hosts
     187// launch the dvomergeUpdate_client jobs to the parallel hosts
     188int dvomergeUpdate_parallel (char *input, char *output, SkyTable *outsky, IDmapType *IDmap) {
     189
     190  // ensure that the paths are absolute path names
     191  char *absinput  = abspath (input,  DVO_MAX_PATH);
     192  char *absoutput = abspath (output, DVO_MAX_PATH);
     193
     194  // name of image subset file:
     195  char IDmapFilename[DVO_MAX_PATH];
     196  snprintf (IDmapFilename, DVO_MAX_PATH, "%s/IDmap.fits", absoutput);
     197
     198  // save IDmap information
     199  if (!IDmapSave (IDmapFilename, IDmap)) {
     200    fprintf (stderr, "ERROR: failure to save the image ID map\n");
     201    exit (1);
     202  }
    190203
    191204  // load the list of hosts
     
    203216    free (table->hosts[i].pathname);
    204217    table->hosts[i].pathname = tmppath;
    205 
    206     // ensure that the paths are absolute path names
    207     char *absinput  = abspath (input,  DVO_MAX_PATH);
    208     char *absoutput = abspath (output, DVO_MAX_PATH);
    209218
    210219    // options / arguments that can affect relastro_client -update-objects:
  • branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomerge_client.c

    r33834 r33906  
    1010  SkyList *inlist;
    1111  char filename[256], *input, *output;
    12   IDmapType IDmap;
     12  IDmapType *IDmap;
    1313  PhotCodeData *inputPhotcodes;
    1414  PhotCodeData *outputPhotcodes;
     
    5151  }
    5252
    53   dvomergeImagesGetMap (&IDmap, input, output);
     53  char *absoutput = abspath (output, DVO_MAX_PATH);
     54  char IDmapFilename[DVO_MAX_PATH];
     55  snprintf (IDmapFilename, DVO_MAX_PATH, "%s/IDmap.fits", absoutput);
     56
     57  // save IDmap information
     58  IDmap = IDmapLoad (IDmapFilename);
     59  if (!IDmap) {
     60    fprintf (stderr, "ERROR: failure to save the image ID map\n");
     61    exit (1);
     62  }
    5463
    5564  // load the sky table for the existing database
     
    7483  SetPhotcodeTable(NULL);
    7584 
    76    dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, IDmap, secfiltMap);
     85  dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, IDmap, secfiltMap);
    7786
    7887  exit (0);
Note: See TracChangeset for help on using the changeset viewer.