IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 6, 2015, 2:28:50 PM (11 years ago)
Author:
eugene
Message:

add timing test; handle empty table

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20150429/src/libfits/table/F_uncompress_T.c

    r38366 r38415  
    4747}
    4848
     49static float timeSum1 = 0.0;
     50static float timeSum2 = 0.0;
     51static float timeSum2a = 0.0;
     52static float timeSum2b = 0.0;
     53static float timeSum2c = 0.0;
     54static float timeSum2d = 0.0;
     55static float timeSum2e = 0.0;
     56static float timeSum2f = 0.0;
     57static float timeSum3 = 0.0;
     58
     59void gfits_uncompress_timing () {
     60  fprintf (stderr, "times: %f %f %f\n", timeSum1, timeSum2, timeSum3);
     61  fprintf (stderr, "times: %f %f %f %f %f %f\n", timeSum2a, timeSum2b, timeSum2c, timeSum2d, timeSum2e, timeSum2f);
     62}
     63
    4964int gfits_uncompress_table (FTable *srctable, FTable *tgttable) {
    5065
     
    5873  Header *srcheader = srctable->header;
    5974  Header *tgtheader = tgttable->header;
     75
     76  // XXX EAM:
     77  struct timeval startTimer, stopTimer;
     78  float dtime;
     79  gettimeofday (&startTimer, (void *) NULL);
    6080
    6181  int ztilelen;
     
    126146  myAssert (Nx == tgtheader->Naxis[0], "table definition error?");
    127147
     148  // XXX TIMER 1
     149  gettimeofday (&stopTimer, (void *) NULL);
     150  dtime = DTIME (stopTimer, startTimer);
     151  timeSum1 += dtime;
     152  gettimeofday (&startTimer, (void *) NULL);
     153
    128154  // this allocates the pointer data array for the full set of tiles (NOT the heap)
    129155  char *tmpbuffer = NULL;
     
    135161   
    136162  int Ntile = srcheader->Naxis[1];
    137   int ztilelast = (tgtheader->Naxis[1] % ztilelen) ? tgtheader->Naxis[1] % ztilelen : ztilelen;
     163  int ztilelast;
     164  if (Ntile == 0) {
     165    ztilelast = 0;
     166  } else {
     167    ztilelast = (tgtheader->Naxis[1] % ztilelen) ? tgtheader->Naxis[1] % ztilelen : ztilelen;
     168  }
    138169
    139170  // allocate the intermediate storage buffers
     
    147178  gfits_dump_cmp_table (srctable, "unc");
    148179
     180  // XXX TIMER 2
     181  gettimeofday (&stopTimer, (void *) NULL);
     182  dtime = DTIME (stopTimer, startTimer);
     183  timeSum2 += dtime;
     184  gettimeofday (&startTimer, (void *) NULL);
     185
    149186  off_t row;
    150187  for (row = 0; row < srcheader->Naxis[1]; row++) {
     
    157194      // XXX note that this function currently byteswaps.  I should redo the code to make
    158195      // byteswap of the varlength data segment a separate function
     196
     197      gettimeofday (&startTimer, (void *) NULL);
    159198
    160199      off_t Nzdata;
     
    173212      }
    174213
    175       if (strcasecmp(fields[i].zctype, "NONE") &&
    176           strcasecmp(fields[i].zctype, "NONE_2") &&
     214      // XXX TIMER 2a
     215      gettimeofday (&stopTimer, (void *) NULL);
     216      dtime = DTIME (stopTimer, startTimer);
     217      timeSum2a += dtime;
     218      gettimeofday (&startTimer, (void *) NULL);
     219 
     220      if (strcasecmp(fields[i].zctype, "NONE_2") &&
    177221          strcasecmp(fields[i].zctype, "GZIP_1") &&
    178222          strcasecmp(fields[i].zctype, "GZIP_2") &&
     
    183227      }
    184228
     229      // XXX TIMER 2b
     230      gettimeofday (&stopTimer, (void *) NULL);
     231      dtime = DTIME (stopTimer, startTimer);
     232      timeSum2b += dtime;
     233      gettimeofday (&startTimer, (void *) NULL);
     234 
    185235      if (VERBOSE_DUMP) {
    186236        int k;
     
    194244      }
    195245
     246      // XXX TIMER 2c
     247      gettimeofday (&stopTimer, (void *) NULL);
     248      dtime = DTIME (stopTimer, startTimer);
     249      timeSum2c += dtime;
     250      gettimeofday (&startTimer, (void *) NULL);
     251 
    196252      int Nrows = (row == Ntile - 1) ? ztilelast : ztilelen;
    197253      int Nraw = Nrows*fields[i].Nvalues*fields[i].pixsize; // expected number of bytes
     
    209265      }
    210266
     267      // XXX TIMER 2d
     268      gettimeofday (&stopTimer, (void *) NULL);
     269      dtime = DTIME (stopTimer, startTimer);
     270      timeSum2d += dtime;
     271      gettimeofday (&startTimer, (void *) NULL);
     272 
    211273      if (!strcasecmp(fields[i].zctype, "GZIP_1")) {
    212274        myAssert ((fields[i].zdef.format != 'C') && (fields[i].zdef.format != 'M'), "swap is probably wrong for C or M columns");
     
    214276      }
    215277
     278      // XXX TIMER 2e
     279      gettimeofday (&stopTimer, (void *) NULL);
     280      dtime = DTIME (stopTimer, startTimer);
     281      timeSum2e += dtime;
     282      gettimeofday (&startTimer, (void *) NULL);
     283 
    216284      if (VERBOSE_DUMP) {
    217285        int k;
     
    237305        if (!gfits_distribute_table_data (tgttable, &fields[i], raw, row_start, Nrows)) ESCAPE;
    238306      }     
     307
     308      // XXX TIMER 2f
     309      gettimeofday (&stopTimer, (void *) NULL);
     310      dtime = DTIME (stopTimer, startTimer);
     311      timeSum2f += dtime;
     312      gettimeofday (&startTimer, (void *) NULL);
    239313    }
    240314  }
     315
     316  // XXX TIMER 3
     317  gettimeofday (&stopTimer, (void *) NULL);
     318  dtime = DTIME (stopTimer, startTimer);
     319  timeSum3 += dtime;
     320  gettimeofday (&startTimer, (void *) NULL);
    241321
    242322  gfits_dump_raw_table (tgttable, "unc");
     
    264344  off_t Nx = table->header->Naxis[0];
    265345
     346  char *tblbuffer = &table->buffer[Nx*row_start + field->offset];
     347
    266348  if (VERBOSE) fprintf (stderr, "distribute: ");
    267   for (i = 0; i < Nrows; i++) {
    268     int row = row_start + i;
    269     memcpy (&table->buffer[Nx*row + field->offset], &raw[i*field->rowsize], field->rowsize);
     349  for (i = 0; i < Nrows; i++, tblbuffer += Nx) {
     350    // int row = row_start + i;
     351    memcpy (tblbuffer, &raw[i*field->rowsize], field->rowsize);
    270352# if (VERBOSE)
    271353    int j; for (j = 0; j < field->rowsize; j++) fprintf (stderr, "0x%02hhx ", table->buffer[Nx*row + field->offset + j]);
     
    284366
    285367  off_t Nx = table->header->Naxis[0];
    286 
     368  int Nvalues = field->Nvalues;
     369  int pixsize = field->pixsize;
     370  int offset = field->offset;
     371
     372  char *rawptr = raw;
     373
     374  for (k = 0; k < field->pixsize; k++) {
     375# ifdef BYTE_SWAP     
     376    char *tblptr_start = &table->buffer[Nx*row_start + offset + (pixsize - k - 1)];
     377# else
     378    char *tblptr_start = &table->buffer[Nx*row_start + offset + k];
     379# endif
     380    for (i = 0; i < Nrows; i++, tblptr_start += Nx) {
     381      char *tblptr = tblptr_start;
     382      for (j = 0; j < Nvalues; j++, tblptr += pixsize, rawptr++) {
     383        *tblptr = *rawptr;
     384      }
     385    }
     386  }
     387  return (TRUE);
     388}
     389
     390int gfits_distribute_table_gzp2_alt (FTable *table, TableField *field, char *raw, int row_start, int Nrows) {
     391 
     392  off_t i, j, k;
     393 
     394  // we are copying NN rows into the column which starts at XX and has MM bytes per row
     395 
     396  off_t Nx = table->header->Naxis[0];
     397 
    287398  for (k = 0; k < field->pixsize; k++) {
    288399    for (i = 0; i < Nrows; i++) {
    289400      int row = row_start + i;
    290401      char *rawptr = &raw[i*field->Nvalues + k*Nrows*field->Nvalues];
    291 # ifdef BYTE_SWAP      
     402# ifdef BYTE_SWAP     
    292403      char *tblptr = &table->buffer[Nx*row + field->offset + (field->pixsize - k - 1)];
    293404# else
Note: See TracChangeset for help on using the changeset viewer.