IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15746


Ignore:
Timestamp:
Dec 6, 2007, 3:39:40 PM (18 years ago)
Author:
eugene
Message:

fixing up dvosplit to free memory as needed

Location:
trunk/Ohana/src/dvosplit/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/dvosplit/src/dvosplit.c

    r15743 r15746  
    6161    // split_missings (&incatalog, outlist, outcatalogs, avelinks);
    6262
     63    free (avelinks[0].outref);
     64    free (avelinks[0].outcat);
     65
    6366    dvo_catalog_unlock (&incatalog);
    6467
     
    7275      outlist[0].regions[j][0].table = TRUE;
    7376    }
    74 
    7577  }
    7678
    7779  // save sky table copy
    7880  sprintf (filename, "%s/SkyTable.fits", CATDIR);
    79   check_file_access (filename, FALSE, VERBOSE);
     81  check_file_access (filename, TRUE, VERBOSE);
    8082  if (!SkyTableSave (sky, filename)) {
    8183    fprintf (stderr, "ERROR: failed to save sky table for %s\n", CATDIR);
  • trunk/Ohana/src/dvosplit/src/split_averages.c

    r15743 r15746  
    11# include "dvosplit.h"
    22# define NROWS 100000 /* ~10MB per block for measures */
     3# define DNOUT 1000
    34
    45AveLinks *split_averages (Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs) {
     
    67  double inR, inD;
    78  int n, block, ave, cat, averef, Nblocks, Ncat, Nout, Nsecfilt;
    8   int *outref, *outcat;
     9  int *outref, *outcat, *outmem;
    910  AveLinks *avelinks;
    1011
    1112  ALLOCATE (outref, int, incatalog[0].Naves_disk);
    1213  ALLOCATE (outcat, int, incatalog[0].Naves_disk);
     14  ALLOCATE (outmem, int, outlist[0].Nregions);
    1315
    1416  Nsecfilt = GetPhotcodeNsecfilt ();
     
    1719  // contains primary photcodes, which will increase Nsecfilt by one.
    1820  for (cat = 0; cat < outlist[0].Nregions; cat++) {
    19     REALLOCATE (outcatalogs[cat].average, Average, NROWS);
    20     REALLOCATE (outcatalogs[cat].secfilt, SecFilt, NROWS*(Nsecfilt + 1));
     21    outmem[cat] = DNOUT;
     22    REALLOCATE (outcatalogs[cat].average, Average, outmem[cat]);
     23    REALLOCATE (outcatalogs[cat].secfilt, SecFilt, outmem[cat]*(Nsecfilt + 1));
    2124  }
    2225
     
    2932    // read up to NROWS at a time
    3033    dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS);
     34    fprintf (stderr, "splitting %s (averages) .. %d of %d\n", incatalog[0].filename, block, Nblocks);
     35
    3136    assert (block*NROWS == incatalog[0].Naves_off);
    3237
     38    // distribute data to the output catalogs
    3339    for (ave = 0; ave < incatalog[0].Naverage; ave++) {
    3440      averef = ave + incatalog[0].Naves_off;
     
    6773        outcatalogs[Ncat].Nsecf_mem++;
    6874      }
     75
     76      if (outcatalogs[Ncat].Naverage >= outmem[Ncat]) {
     77        outmem[Ncat] += DNOUT;
     78        REALLOCATE (outcatalogs[Ncat].average, Average, outmem[Ncat]);
     79        REALLOCATE (outcatalogs[Ncat].secfilt, SecFilt, outmem[Ncat]*(Nsecfilt + 1));
     80      }
    6981    }
     82    dvo_catalog_free_data (incatalog);
    7083
    7184    // double check the values of Naverage, Nsecf_mem?
     
    7588      outcatalogs[cat].catflags = LOAD_AVES | LOAD_SECF;
    7689
    77       fprintf (stderr, "secfilt: %d %d %d %d\n", outcatalogs[cat].Nsecf_mem, outcatalogs[cat].Nsecf_disk, outcatalogs[cat].Nsecf_off, outcatalogs[cat].Naverage, outcatalogs[cat].Nsecfilt);
    7890      dvo_catalog_save (&outcatalogs[cat], VERBOSE);
    79       fprintf (stderr, "secfilt: %d %d %d %d\n", outcatalogs[cat].Nsecf_mem, outcatalogs[cat].Nsecf_disk, outcatalogs[cat].Nsecf_off, outcatalogs[cat].Naverage, outcatalogs[cat].Nsecfilt);
     91      // fprintf (stderr, "secfilt: %d %d %d %d\n", outcatalogs[cat].Nsecf_mem, outcatalogs[cat].Nsecf_disk, outcatalogs[cat].Nsecf_off, outcatalogs[cat].Naverage, outcatalogs[cat].Nsecfilt);
    8092
    81       // XXX I need to advance the pointers and free the current data
     93      // advance the pointers and free the current data
    8294      // XXX these should be done within save segment:
    8395      outcatalogs[cat].Naves_disk += outcatalogs[cat].Naverage;
     
    92104  }
    93105
     106  for (cat = 0; cat < outlist[0].Nregions; cat++) {
     107    dvo_catalog_free_data (&outcatalogs[cat]);
     108  }
     109
     110  free (outmem);
     111
    94112  ALLOCATE (avelinks, AveLinks, 1);
    95113  avelinks[0].outref = outref;
    96114  avelinks[0].outcat = outcat;
    97115
     116
    98117  return (avelinks);
    99118}
  • trunk/Ohana/src/dvosplit/src/split_measures.c

    r15743 r15746  
    11# include "dvosplit.h"
    22# define NROWS 100000 /* ~10MB per row for measures */
     3# define DNOUT 1000
    34
    45int split_measures (Catalog *incatalog, SkyList *outlist, Catalog *outcatalogs, AveLinks *avelinks) {
    56
    67  int block, meas, cat, Nblocks, Ncat, Nout, averef;
    7   int *outref, *outcat;
     8  int *outref, *outcat, *outmem;
    89
    910  outref = avelinks->outref;
    1011  outcat = avelinks->outcat;
     12  ALLOCATE (outmem, int, outlist[0].Nregions);
    1113
    1214  // allocate enough space for the output buffer
    1315  for (cat = 0; cat < outlist[0].Nregions; cat++) {
    14     REALLOCATE (outcatalogs[cat].measure, Measure, NROWS);
     16    outmem[cat] = DNOUT;
     17    REALLOCATE (outcatalogs[cat].measure, Measure, outmem[cat]);
    1518  }
    1619
     
    2326    // read up to NROWS at a time
    2427    dvo_catalog_load_segment (incatalog, VERBOSE, block*NROWS, NROWS);
     28    fprintf (stderr, "splitting %s (measures) .. %d of %d\n", incatalog[0].filename, block, Nblocks);
     29
     30    assert (block*NROWS == incatalog[0].Nmeas_off);
    2531
    2632    for (meas = 0; meas < incatalog[0].Nmeasure; meas++) {
     
    3339      outcatalogs[Ncat].measure[Nout].averef = outref[averef];
    3440      outcatalogs[Ncat].Nmeasure++;
     41
     42      if (outcatalogs[Ncat].Nmeasure >= outmem[Ncat]) {
     43        outmem[Ncat] += DNOUT;
     44        REALLOCATE (outcatalogs[Ncat].measure, Measure, outmem[Ncat]);
     45      }
    3546    }
     47    dvo_catalog_free_data (incatalog);
    3648
    3749    for (cat = 0; cat < outlist[0].Nregions; cat++) {
     
    4557    }
    4658  }
     59
     60  for (cat = 0; cat < outlist[0].Nregions; cat++) {
     61    dvo_catalog_free_data (&outcatalogs[cat]);
     62  }
     63
     64  free (outmem);
     65
    4766  return (TRUE);
    4867}
Note: See TracChangeset for help on using the changeset viewer.