IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38292


Ignore:
Timestamp:
May 19, 2015, 7:46:25 AM (11 years ago)
Author:
eugene
Message:

pre-allocate groups of lists for all Nsecfilt values; we will accumulate these lists as we go

Location:
branches/eam_branches/ipp-20150419/Ohana/src/relphot
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150419/Ohana/src/relphot/include/relphot.h

    r38062 r38292  
    9696
    9797typedef struct {
     98  double *flxlist;           // list of measure.mag values for a given star
     99  double *errlist;            // mag errors for a star
     100  double *wgtlist;            // weights to use for mean mags
     101} StatDataSet;
     102
     103typedef struct {
    98104  int Nfew;
    99105  int Ncode;
     
    105111
    106112  // NOTE: the following arrays are (possibly) pre-allocated and carried down to each
    107   // thread.  The first 3 (list, dlist, wlist) are used in all relphot analyses; the
    108   // others are only used on the final output steps.
    109 
    110   double *Mpsflist;           // list of measure.mag values for a given star
    111   double *dpsflist;           // mag errors for a star
    112   double *wpsflist;           // weights to use for mean mags
    113 
    114   double *Maplist;            // ap mags for a star
    115   double *daplist;            // ap mags for a star
    116   double *waplist;            // ap mags for a star
    117 
    118   double *Mkronlist;          // kron mags for a star
    119   double *dkronlist;          // kron mag errors
    120   double *wkronlist;          // kron mag errors
     113  // thread.  The psfData are used in all relphot analyses; the others are only used on
     114  // the final output steps.
     115
     116  StatDataSet  *psfData; // one is allocated for each primary (average) photcode
     117  StatDataSet *aperData;
     118  StatDataSet *kronData;
    121119
    122120  double *psfqf_list;         // psfqf for all filters
  • branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/StarOps.c

    r37116 r38292  
    11# include "relphot.h"
    2 
    3 static int Nmax;
    42
    53enum {THREAD_RUN, THREAD_DONE};
     
    2018int print_measure_set (Average *average, SecFilt *secfilt, Measure *measure);
    2119
    22 // we want to allocate the stats list,dlist arrays only once (or once per thread).
    23 // this function finds the largest array so we can allocate that max size when needed
     20// we want to allocate the StatDataSet arrays only once (or once per thread).  this
     21// function finds the largest value of Nmeasure so we can allocate that max size when
     22// needed
     23static int Nmax;
    2424void initMrel (Catalog *catalog, int Ncatalog) {
    2525
     
    5454}
    5555
    56 void SetMrelInfoInit (SetMrelInfo *results, int allocLists) {
     56StatDataSet *StatDataSetAlloc (int Nsecfilt, int Nmax) {
     57
     58  int i;
     59
     60  StatDataSet *dataset = NULL;
     61  ALLOCATE (dataset, StatDataSet, Nsecfilt);
     62  for (i = 0; i < Nsecfilt; i++) {
     63    ALLOCATE (dataset[i].flxlist, double, Nmax);
     64    ALLOCATE (dataset[i].wgtlist, double, Nmax);
     65    ALLOCATE (dataset[i].errlist, double, Nmax);
     66  } 
     67  return dataset;
     68}
     69
     70void StatDataSetFree (StatDataSet *, int Nsecfilt) {
     71
     72  int i;
     73
     74  for (i = 0; i < Nsecfilt; i++) {
     75    FREE (dataset[i].flxlist);
     76    FREE (dataset[i].wgtlist);
     77    FREE (dataset[i].errlist);
     78  } 
     79  FREE (dataset);
     80}
     81
     82void SetMrelInfoReset (SetMrelInfo *results) {
    5783  results->Nfew  = 0;
    5884  results->Ncode  = 0;
     
    6288  results->Nmos  = 0;
    6389  results->Ngrid = 0;
     90}
     91
     92void SetMrelInfoInit (SetMrelInfo *results, int allocLists) {
     93  SetMrelInfoReset (results);
    6494  if (allocLists) {
    65     ALLOCATE (results->Mpsflist, double, Nmax);
    66     ALLOCATE (results->dpsflist, double, Nmax);
    67     ALLOCATE (results->wpsflist, double, Nmax);
     95    results->Nsecfilt = GetPhotcodeNsecfilt ();
     96    results->psfData  = StatDataSetAlloc (results->Nsecfilt, Nmax);
     97    results->aperData = StatDataSetAlloc (results->Nsecfilt, Nmax);
     98    results->kronData = StatDataSetAlloc (results->Nsecfilt, Nmax);
     99    ALLOCATE (results->psfqf_list,     double, Nmax);
     100    ALLOCATE (results->psfqfperf_list, double, Nmax);
     101    ALLOCATE (results->stargal_list,   double, Nmax);
     102  } else {
     103    results->Nsecfilt = 0;
     104    results->psfData  = NULL;
     105    results->aperData = NULL;
     106    results->kronData = NULL;
     107    results->psfqf_list     = NULL;
     108    results->psfqfperf_list = NULL;
     109    results->stargal_list   = NULL;
    68110  }
    69111}
    70112
    71113void SetMrelInfoFree (SetMrelInfo *results) {
    72   free (results->Mpsflist);
    73   free (results->dpsflist);
    74   free (results->wpsflist);
     114  StatDataSetFree (results->psfdata,  results->Nsecfilt);
     115  StatDataSetFree (results->aperdata, results->Nsecfilt);
     116  StatDataSetFree (results->krondata, results->Nsecfilt);
     117  FREE (results.psfqf_list);
     118  FREE (results.psfqfperf_list);
     119  FREE (results.stargal_list);
    75120}
    76121
     
    162207  SetMrelInfoInit (&results, TRUE); // allocates results->list,dlist,wlist
    163208
    164   ALLOCATE (results.Maplist,  double, Nmax);
    165   ALLOCATE (results.daplist,  double, Nmax);
    166   ALLOCATE (results.waplist,  double, Nmax);
    167 
    168   ALLOCATE (results.Mkronlist, double, Nmax);
    169   ALLOCATE (results.dkronlist, double, Nmax);
    170   ALLOCATE (results.wkronlist, double, Nmax);
    171 
    172   ALLOCATE (results.psfqf_list, double, Nmax);
    173   ALLOCATE (results.psfqfperf_list, double, Nmax);
    174   ALLOCATE (results.stargal_list, double, Nmax);
    175 
    176209  for (i = 0; i < Ncatalog; i++) {
    177210    switch (SET_MREL_VERSION) {
     
    191224
    192225  SetMrelInfoFree (&results);
    193   free (results.Maplist);
    194   free (results.daplist);
    195   free (results.waplist);
    196 
    197   free (results.Mkronlist);
    198   free (results.dkronlist);
    199   free (results.wkronlist);
    200 
    201   free (results.psfqf_list);
    202   free (results.psfqfperf_list);
    203   free (results.stargal_list);
    204226  return (TRUE);
    205227}
  • branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/setMrelCatalog.c

    r38289 r38292  
    4040  off_t j;
    4141
    42   liststats_setmode (&results->psfstats, STATMODE);
    43   liststats_setmode (&results->apstats, STATMODE);
     42  liststats_setmode (&results->psfstats,  STATMODE);
     43  liststats_setmode (&results->apstats,   STATMODE);
    4444  liststats_setmode (&results->kronstats, STATMODE);
    4545
    46   SetMrelInfoInit (results, FALSE); // do not allocate list,dlist,wlist arrays
     46  SetMrelInfoReset (results); // reset the countesrs
    4747
    4848  int isSetMrelFinal = (pass >= 0);
    49 
    50   // XX char *primaryCell = NULL;
    51   // XX if (isSetMrelFinal) {
    52   // XX   ALLOCATE (primaryCell, char, DVO_MAX_PATH);
    53   // XX }
    5449
    5550  for (j = 0; j < catalog[Nc].Naverage; j++) {
Note: See TracChangeset for help on using the changeset viewer.