Changeset 37089
- Timestamp:
- Jul 20, 2014, 9:40:20 AM (12 years ago)
- Location:
- branches/eam_branches/ipp-20140717/Ohana/src/addstar
- Files:
-
- 1 added
- 1 deleted
- 9 edited
-
Makefile (modified) (2 diffs)
-
include/addstar.h (modified) (2 diffs)
-
src/addstar.c (modified) (3 diffs)
-
src/addstar_client.c (modified) (1 diff)
-
src/args.c (modified) (3 diffs)
-
src/args_parallel_client.c (modified) (2 diffs)
-
src/resort_catalog.c (modified) (2 diffs)
-
src/resort_catalogs.c (added)
-
src/resort_threaded.c (modified) (8 diffs)
-
src/resort_unthreaded.c (modified) (1 diff)
-
src/resort_unthreaded_catalogs.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140717/Ohana/src/addstar/Makefile
r35263 r37089 78 78 $(SRC)/parse_time.$(ARCH).o \ 79 79 $(SRC)/replace_match.$(ARCH).o \ 80 $(SRC)/resort_catalog .$(ARCH).o \80 $(SRC)/resort_catalogs.$(ARCH).o \ 81 81 $(SRC)/resort_threaded.$(ARCH).o \ 82 82 $(SRC)/resort_unthreaded.$(ARCH).o \ 83 $(SRC)/resort_ unthreaded_catalogs.$(ARCH).o \83 $(SRC)/resort_catalog.$(ARCH).o \ 84 84 $(SRC)/StarOps.$(ARCH).o \ 85 85 $(SRC)/ReadStarsFITS.$(ARCH).o \ … … 105 105 $(SRC)/addstar_client.$(ARCH).o \ 106 106 $(SRC)/args_parallel_client.$(ARCH).o \ 107 $(SRC)/resort_catalog .$(ARCH).o \107 $(SRC)/resort_catalogs.$(ARCH).o \ 108 108 $(SRC)/resort_threaded.$(ARCH).o \ 109 109 $(SRC)/resort_unthreaded.$(ARCH).o \ 110 $(SRC)/resort_ unthreaded_catalogs.$(ARCH).o110 $(SRC)/resort_catalog.$(ARCH).o 111 111 112 112 ADDSTARD = \ -
branches/eam_branches/ipp-20140717/Ohana/src/addstar/include/addstar.h
r37036 r37089 237 237 Stars *rd_gsc PROTO((char *filename, unsigned int *nstars)); 238 238 int replace_match PROTO((Average *average, Measure *measure, Stars *star)); 239 int resort_threaded PROTO((AddstarClientOptions *options, SkyTable *sky)); 240 int resort_unthreaded PROTO((AddstarClientOptions *options, SkyTable *sky, int hostID, char *hostpath)); 241 int resort_unthreaded_catalogs PROTO((AddstarClientOptions *options, SkyList *skylist, int hostID, char *hostpath)); 239 int resort_catalogs PROTO((AddstarClientOptions *options, SkyTable *sky)); 240 int resort_catalogs_parallel PROTO((AddstarClientOptions *options, SkyList *sky)); 241 int resort_threaded PROTO((SkyList *skylist, int ForceSort)); 242 int resort_unthreaded PROTO((SkyList *skylist, int ForceSort)); 242 243 void resort_catalog PROTO((Catalog *catalog)); 243 244 void resort_catalog_old PROTO((Catalog *catalog)); 245 244 246 Stars *ReadStarsFITS PROTO((FILE *f, Header *header, Header *in_theader, unsigned int *nstars)); 245 247 Stars *ReadStarsTEXT PROTO((FILE *f, unsigned int *nstars)); … … 316 318 void *memrchr(const void *s, int c, size_t n); 317 319 int addstar_create_ID (); 320 int strextend (char *input, char *format,...); 318 321 319 322 /** -
branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/addstar.c
r37036 r37089 40 40 41 41 if (options.mode == ADDSTAR_MODE_RESORT) { 42 if (NTHREADS == 0) { 43 resort_unthreaded (&options, sky, 0, NULL); 44 } else { 45 resort_threaded (&options, sky); 46 } 42 resort_catalogs (&options, sky); 47 43 exit (0); 48 44 } … … 71 67 skylist = SkyListForStars (sky, -1, stars, Nstars); 72 68 break; 73 case ADDSTAR_MODE_RESORT:74 69 case ADDSTAR_MODE_REFCAT: 75 70 skylist = SkyListByPatch (sky, -1, &UserPatch); … … 161 156 if (Nsubset) free (subset); 162 157 break; 163 case ADDSTAR_MODE_RESORT:164 if (options.nosort == 3) catalog.sorted = FALSE;165 166 // no need to resort empty catalogs167 if (catalog.Naves_disk == 0) {168 dvo_catalog_unlock (&catalog);169 dvo_catalog_free (&catalog);170 continue;171 }172 173 if (OLD_RESORT) {174 resort_catalog_old (&catalog);175 } else {176 resort_catalog (&catalog);177 }178 Nsubset = 1;179 break;180 158 } 181 159 /* report total updated values */ -
branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/addstar_client.c
r33963 r37089 25 25 26 26 if (options.mode == ADDSTAR_MODE_RESORT) { 27 resort_ unthreaded (&options, sky, HOST_ID, HOSTDIR);27 resort_catalogs (&options, sky); 28 28 exit (0); 29 29 } -
branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/args.c
r35760 r37089 34 34 remove_argument (N, &argc, argv); 35 35 } 36 OLD_RESORT = FALSE; 37 if ((N = get_argument (argc, argv, "-old-resort"))) { 38 remove_argument (N, &argc, argv); 39 OLD_RESORT = TRUE; 40 } 41 36 42 if ((N = get_argument (argc, argv, "-create-id"))) { 37 43 options.mode = ADDSTAR_MODE_CREATE_ID; … … 350 356 // XXX for the moment, make this selection manual. it needs to be automatic 351 357 // based on the state of the SkyTable 358 HOST_ID = 0; 359 HOSTDIR = NULL; 352 360 PARALLEL = FALSE; 353 361 if ((N = get_argument (argc, argv, "-parallel"))) { … … 466 474 } 467 475 476 int strextend (char *input, char *format,...) { 477 478 char tmpextra[1024], tmpline[1024]; 479 va_list argp; 480 481 va_start (argp, format); 482 vsnprintf (tmpextra, 1024, format, argp); 483 snprintf (tmpline, 1024, "%s %s", input, tmpextra); 484 strcpy (input, tmpline); 485 486 return TRUE; 487 } 488 468 489 /** addstar modes: 469 490 -
branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/args_parallel_client.c
r33963 r37089 87 87 } 88 88 89 OLD_RESORT = FALSE; 90 if ((N = get_argument (argc, argv, "-old-resort"))) { 91 remove_argument (N, &argc, argv); 92 OLD_RESORT = TRUE; 93 } 94 89 95 /* extra error messages */ 90 96 VERBOSE = FALSE; … … 118 124 exit (2); 119 125 } 126 127 int strextend (char *input, char *format,...) { 128 129 char tmpextra[1024], tmpline[1024]; 130 va_list argp; 131 132 va_start (argp, format); 133 vsnprintf (tmpextra, 1024, format, argp); 134 snprintf (tmpline, 1024, "%s %s", input, tmpextra); 135 strcpy (input, tmpline); 136 137 return TRUE; 138 } 139 -
branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/resort_catalog.c
r37036 r37089 7 7 void resort_catalog_old (Catalog *catalog) { 8 8 9 off_t *next_meas ;10 off_t Naves, Nmeas ;9 off_t *next_meas, *next_lens; 10 off_t Naves, Nmeas, Nlens; 11 11 12 12 if (catalog[0].sorted == TRUE) return; … … 16 16 /* internal counters */ 17 17 Nmeas = catalog[0].Nmeasure; 18 Nlens = catalog[0].Nlensing; 18 19 Naves = catalog[0].Naverage; 19 20 20 21 /* set up pointers for linked list of measure, missing */ 21 22 next_meas = build_measure_links (catalog[0].average, Naves, catalog[0].measure, Nmeas); 23 next_lens = build_lensing_links (catalog[0].average, Naves, catalog[0].lensing, Nlens); 22 24 23 25 catalog[0].sorted = TRUE; 24 26 catalog[0].measure = sort_measure (catalog[0].average, Naves, catalog[0].measure, Nmeas, next_meas); 27 catalog[0].lensing = sort_lensing (catalog[0].average, Naves, catalog[0].lensing, Nlens, next_lens); 25 28 26 29 MARKTIME (" match time %9.4f sec for %7lld measures, %6lld average\n", dtime, (long long) Nmeas, (long long) Naves); -
branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/resort_threaded.c
r37036 r37089 13 13 int iThread; 14 14 int state; 15 int nosort;15 int forcesort; 16 16 char *filename; 17 17 SkyRegion *region; … … 37 37 } 38 38 39 // chose the catalog file (local or remote?) 40 char hostfile[1024]; 41 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, threadData->region->name); 42 catalog.filename = HOST_ID ? hostfile : threadData->filename; 43 39 44 // set the parameters which guide catalog open/load/create 40 catalog.filename = threadData->filename;41 45 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 42 46 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data … … 64 68 65 69 // this is an overloaded value to mean 'force sort' 66 if (threadData-> nosort == 3) catalog.sorted = FALSE;70 if (threadData->forcesort) catalog.sorted = FALSE; 67 71 68 72 if (OLD_RESORT) { … … 88 92 } 89 93 90 int resort_threaded ( AddstarClientOptions *options, SkyTable *sky) {94 int resort_threaded (SkyList *skylist, int ForceSort) { 91 95 92 96 int j, launched, done, Nwait, Nrun; … … 97 101 ThreadData *threadData; 98 102 pthread_t *threads; 99 100 double dtime;101 struct timeval start, stop;102 gettimeofday (&start, NULL);103 104 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);105 106 // in these cases, limit the sky catalogs to an existing subset107 if (options->existing_regions) {108 SkyList *tmp;109 tmp = SkyListExistingSubset (skylist, CATDIR);110 SkyListFree (skylist);111 skylist = tmp;112 }113 if (VERBOSE) fprintf (stderr, "writing to "OFF_T_FMT" regions\n", skylist[0].Nregions);114 115 if (options->only_images) {116 fprintf (stderr, "-image (only images) makes no sense with -resort\n");117 exit (2);118 }119 if (options->only_match) {120 fprintf (stderr, "-only-match makes no sense with -resort\n");121 exit (2);122 }123 if (options->nosort == 1) {124 fprintf (stderr, "-nosort makes no sense with -resort\n");125 exit (2);126 }127 if (options->update) {128 fprintf (stderr, "-update makes no sense with -resort\n");129 exit (2);130 }131 if (options->calibrate) {132 fprintf (stderr, "-cal (calibrate) makes no sense with -resort\n");133 exit (2);134 }135 103 136 104 ALLOCATE(threads, pthread_t, NTHREADS); … … 148 116 Naverage = Nmeasure = 0; 149 117 for (i = 0; i < skylist[0].Nregions; i++) { 118 119 // does this host ID match the desired location for the table? 120 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 150 121 151 122 launched = FALSE; … … 166 137 if (threadData[j].state == TS_FAIL) goto failure; 167 138 if (threadData[j].state != TS_WAIT) continue; 168 threadData[j]. nosort = options->nosort;139 threadData[j].forcesort = ForceSort; 169 140 threadData[j].filename = skylist[0].filename[i]; 170 141 threadData[j].region = skylist[0].regions[i]; … … 203 174 } 204 175 205 gettimeofday (&stop, NULL);206 dtime = DTIME (stop, start);207 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for, "OFF_T_FMT" average, "OFF_T_FMT" measure\n", dtime, Naverage, Nmeasure);208 209 176 // for (i = 0; i < NTHREADS; i++) { 210 177 // pthread_cancel(threads[i]); -
branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/resort_unthreaded.c
r35142 r37089 1 1 # include "addstar.h" 2 2 3 int resort_unthreaded (AddstarClientOptions *options, SkyTable *sky, int hostID, char *hostpath) { 3 // pass in options and skylist? 4 int resort_unthreaded (SkyList *skylist, int ForceSort) { 4 5 5 double dtime; 6 struct timeval start, stop; 6 off_t i; 7 off_t Naverage, Nmeasure; 8 Catalog catalog; 7 9 8 gettimeofday (&start, NULL); 10 /* match stars to existing catalog data (or otherwise manipulate catalog data) */ 11 Naverage = Nmeasure = 0; 12 for (i = 0; i < skylist[0].Nregions; i++) { 9 13 10 SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch); 11 12 // in these cases, limit the sky catalogs to an existing subset 13 if (options->existing_regions) { 14 SkyList *tmp; 15 tmp = SkyListExistingSubset (skylist, CATDIR); 16 SkyListFree (skylist); 17 skylist = tmp; 14 // does this host ID match the desired location for the table? 15 if (!HostTableTestHost(skylist[0].regions[i], HOST_ID)) continue; 16 17 // chose the catalog file (local or remote?) 18 char hostfile[1024]; 19 snprintf (hostfile, 1024, "%s/%s.cpt", HOSTDIR, skylist[0].regions[i]->name); 20 catalog.filename = HOST_ID ? hostfile : skylist[0].filename[i]; 21 22 // set the parameters which guide catalog open/load/create 23 catalog.catformat = dvo_catalog_catformat (CATFORMAT); // set the default catformat from config data 24 catalog.catmode = dvo_catalog_catmode (CATMODE); // set the default catmode from config data 25 catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_LENSING; 26 catalog.Nsecfilt = GetPhotcodeNsecfilt (); 27 28 // an error exit status here is a significant error (disk I/O or file access) 29 if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) { 30 fprintf (stderr, "ERROR: failure to open/create catalog file %s\n", catalog.filename); 31 exit (2); 32 } 33 34 // Naves_disk == 0 implies an empty catalog file, skip empty catalogs 35 if (catalog.Naves_disk == 0) { 36 dvo_catalog_unlock (&catalog); 37 dvo_catalog_free (&catalog); 38 continue; 39 } 40 41 // this is an overloaded value to mean 'force sort' 42 if (ForceSort) catalog.sorted = FALSE; 43 44 if (OLD_RESORT) { 45 resort_catalog_old (&catalog); 46 } else { 47 resort_catalog (&catalog); 48 } 49 50 // report total updated values 51 Naverage += catalog.Naverage; 52 Nmeasure += catalog.Nmeasure; 53 54 // write out catalog, if appropriate 55 SetProtect (TRUE); 56 dvo_catalog_save (&catalog, VERBOSE); 57 SetProtect (FALSE); 58 dvo_catalog_unlock (&catalog); 59 dvo_catalog_free (&catalog); 18 60 } 19 if (VERBOSE) fprintf (stderr, "writing to "OFF_T_FMT" regions\n", skylist[0].Nregions);20 21 if (options->only_images) {22 fprintf (stderr, "-image (only images) makes no sense with -resort\n");23 exit (2);24 }25 if (options->only_match) {26 fprintf (stderr, "-only-match makes no sense with -resort\n");27 exit (2);28 }29 if (options->nosort == 1) {30 fprintf (stderr, "-nosort makes no sense with -resort\n");31 exit (2);32 }33 if (options->update) {34 fprintf (stderr, "-update makes no sense with -resort\n");35 exit (2);36 }37 if (options->calibrate) {38 fprintf (stderr, "-cal (calibrate) makes no sense with -resort\n");39 exit (2);40 }41 42 resort_unthreaded_catalogs (options, skylist, hostID, hostpath);43 44 gettimeofday (&stop, NULL);45 dtime = DTIME (stop, start);46 fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime);47 48 61 return TRUE; 49 62 } 50 63 64
Note:
See TracChangeset
for help on using the changeset viewer.
