Changeset 33089
- Timestamp:
- Jan 11, 2012, 10:16:48 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 27 edited
-
psLib/src/imageops/psImageConvolve.c (modified) (5 diffs)
-
psLib/src/imageops/psImageCovariance.c (modified) (2 diffs)
-
psLib/src/sys/psThread.c (modified) (8 diffs)
-
psLib/src/sys/psThread.h (modified) (1 diff)
-
psModules/src/camera/pmReadoutFake.c (modified) (1 diff)
-
psModules/src/detrend/pmBias.c (modified) (1 diff)
-
psModules/src/detrend/pmDark.c (modified) (1 diff)
-
psModules/src/detrend/pmFlatField.c (modified) (1 diff)
-
psModules/src/detrend/pmShutterCorrection.c (modified) (1 diff)
-
psModules/src/imcombine/pmStackReject.c (modified) (1 diff)
-
psModules/src/imcombine/pmSubtraction.c (modified) (2 diffs)
-
psModules/src/imcombine/pmSubtractionEquation.c (modified) (1 diff)
-
psModules/src/imcombine/pmSubtractionEquation.v0.c (modified) (1 diff)
-
psModules/src/imcombine/pmSubtractionMatch.c (modified) (1 diff)
-
psphot/src/psphotApResid.c (modified) (1 diff)
-
psphot/src/psphotBlendFit.c (modified) (1 diff)
-
psphot/src/psphotExtendedSourceAnalysis.c (modified) (1 diff)
-
psphot/src/psphotExtendedSourceFits.c (modified) (1 diff)
-
psphot/src/psphotFindFootprints.c (modified) (1 diff)
-
psphot/src/psphotGuessModels.c (modified) (1 diff)
-
psphot/src/psphotKronIterate.c (modified) (1 diff)
-
psphot/src/psphotMagnitudes.c (modified) (2 diffs)
-
psphot/src/psphotRadialApertures.c (modified) (1 diff)
-
psphot/src/psphotRadialProfileWings.c (modified) (1 diff)
-
psphot/src/psphotReadout.c (modified) (2 diffs)
-
psphot/src/psphotSourceStats.c (modified) (2 diffs)
-
psphot/src/psphotTest.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageConvolve.c
r32745 r33089 1039 1039 } 1040 1040 } 1041 if (!psThreadPoolWait(true )) {1041 if (!psThreadPoolWait(true, true)) { 1042 1042 psError(PS_ERR_UNKNOWN, false, "Error waiting for threads."); 1043 1043 psFree(gaussNorm); … … 1390 1390 } 1391 1391 // wait here for the threaded jobs to finish (NOP if threading is not active) 1392 if (!psThreadPoolWait(true )) {1392 if (!psThreadPoolWait(true, true)) { 1393 1393 psError(PS_ERR_UNKNOWN, false, "Unable to smooth image"); 1394 1394 psFree(calculation); … … 1437 1437 1438 1438 // wait here for the threaded jobs to finish (NOP if threading is not active) 1439 if (!psThreadPoolWait(true )) {1439 if (!psThreadPoolWait(true, true)) { 1440 1440 psError(PS_ERR_UNKNOWN, false, "Unable to smooth image"); 1441 1441 psFree(calculation); … … 1752 1752 } 1753 1753 } 1754 if (!psThreadPoolWait(true )) {1754 if (!psThreadPoolWait(true, true)) { 1755 1755 psError(PS_ERR_UNKNOWN, false, "Error waiting for threads."); 1756 1756 psFree(conv); … … 1787 1787 } 1788 1788 } 1789 if (!psThreadPoolWait(true )) {1789 if (!psThreadPoolWait(true, true)) { 1790 1790 psError(PS_ERR_UNKNOWN, false, "Error waiting for threads."); 1791 1791 psFree(conv); -
trunk/psLib/src/imageops/psImageCovariance.c
r32714 r33089 193 193 } 194 194 195 if (threaded && !psThreadPoolWait(true )) {195 if (threaded && !psThreadPoolWait(true, true)) { 196 196 psError(PS_ERR_UNKNOWN, false, "Error waiting for threads."); 197 197 return false; … … 360 360 } 361 361 } 362 if (threaded && !psThreadPoolWait(true )) {362 if (threaded && !psThreadPoolWait(true, true)) { 363 363 psError(PS_ERR_UNKNOWN, false, "Error waiting for threads."); 364 364 return false; -
trunk/psLib/src/sys/psThread.c
r32715 r33089 179 179 PS_ASSERT_THREAD_TASK_NON_NULL(task, false); 180 180 181 // fprintf(stderr, "adding task %s\n", task->type); 182 181 183 if (!tasks) { 182 184 tasks = psHashAlloc(TASK_BUCKETS); … … 189 191 { 190 192 PS_ASSERT_STRING_NON_EMPTY(type, false); 193 // fprintf(stderr, "removing task %s\n", type); 191 194 192 195 return psHashRemove(tasks, type); … … 223 226 224 227 psThreadTask *task = psHashLookup(tasks, job->type); // Task to execute job 228 // fprintf(stderr, "launching job %s\n", job->type); 225 229 #ifdef HAVE_BACKTRACE 226 230 if (!task && bt_buffer) { … … 246 250 "invalid number of arguments to %s (%ld supplied, expected %d)", 247 251 task->type, job->args->n, task->nArgs); 252 // fprintf(stderr, " thread for %s %p launching on %p\n", job->type, task->function, self); 253 254 // Run the job's function 248 255 bool status = task->function(job); // Status of executing task 256 257 // fprintf(stderr, " thread for %s %p finished on %p with status %d\n", job->type, task->function, self, status); 249 258 250 259 // Put the completed job on the 'done' queue … … 306 315 307 316 // call this function after you have added jobs to the queue and 308 bool psThreadPoolWait(bool harvest) 309 { 317 bool psThreadPoolWait(bool harvest, bool harvestOnFailure) 318 { 319 // fprintf(stderr, "psThreadPoolWait called with harvest: %d\n", harvest); 310 320 if (!pool || pool->n == 0) { 311 321 // No threads initialised, so everything's done … … 326 336 #endif 327 337 338 // accumulate the number of faulted jobs that we encounter 339 int numFaults = 0; 328 340 while (1) { 329 341 // check for an error … … 331 343 psThread *thread = pool->data[i]; 332 344 if (thread->fault) { 333 return false;345 numFaults++; 334 346 } 335 347 } … … 354 366 // Nothing in the queue and nothing more to add 355 367 // Ensure everything is harvested, if requested 356 if (harvest ) {368 if (harvest || (numFaults && harvestOnFailure)) { 357 369 psThreadJobHarvest(); 358 370 } 359 371 psThreadUnlock(); 360 return true;372 return numFaults == 0; 361 373 } 362 374 -
trunk/psLib/src/sys/psThread.h
r28405 r33089 116 116 /// Wait for the thread pool to finish 117 117 /// 118 /// This function blocks (waits in usleep) until either an error is detected on one of the threads or until ll 119 /// threads are idle and no jobs are left on the queue 120 bool psThreadPoolWait(bool harvest // Harvest the jobs from the queue? 118 /// This function blocks (waits in usleep) until all threads are idle and no jobs 119 /// are left on the queue 120 /// returns success if all jobs return success, otherwise returns false 121 bool psThreadPoolWait(bool harvest, // Harvest the jobs from the queue? 122 bool harvestOnFailure // If harvest is false, harvest the jobs if a failure is encountered 121 123 ); 122 124 -
trunk/psModules/src/camera/pmReadoutFake.c
r32347 r33089 314 314 } 315 315 } 316 if (!psThreadPoolWait(true )) {316 if (!psThreadPoolWait(true, true)) { 317 317 psError(PS_ERR_UNKNOWN, false, "Error waiting for threads."); 318 318 psFree(groups); -
trunk/psModules/src/detrend/pmBias.c
r29833 r33089 154 154 if (threaded) { 155 155 // wait here for the threaded jobs to finish 156 if (!psThreadPoolWait(true )) {156 if (!psThreadPoolWait(true, true)) { 157 157 psError(PS_ERR_UNKNOWN, false, "Unable to apply bias correction."); 158 158 return false; -
trunk/psModules/src/detrend/pmDark.c
r28405 r33089 601 601 if (threaded) { 602 602 // wait here for the threaded jobs to finish 603 if (!psThreadPoolWait(true )) {603 if (!psThreadPoolWait(true, true)) { 604 604 psError(PS_ERR_UNKNOWN, false, "Unable to apply dark."); 605 605 psFree(orders); -
trunk/psModules/src/detrend/pmFlatField.c
r28405 r33089 161 161 if (threaded) { 162 162 // wait here for the threaded jobs to finish 163 if (!psThreadPoolWait(true )) {163 if (!psThreadPoolWait(true, true)) { 164 164 psError(PS_ERR_UNKNOWN, false, "Unable to flat-field image."); 165 165 return false; -
trunk/psModules/src/detrend/pmShutterCorrection.c
r29004 r33089 805 805 if (threaded) { 806 806 // wait here for the threaded jobs to finish 807 if (!psThreadPoolWait(true )) {807 if (!psThreadPoolWait(true, true)) { 808 808 psError(PS_ERR_UNKNOWN, false, "Unable to apply shutter correction."); 809 809 psFree(shutterImage); -
trunk/psModules/src/imcombine/pmStackReject.c
r31435 r33089 313 313 } 314 314 315 if (!psThreadPoolWait(false )) {315 if (!psThreadPoolWait(false, true)) { 316 316 psError(psErrorCodeLast(), false, "Unable to grow bad pixels."); 317 317 psFree(source); -
trunk/psModules/src/imcombine/pmSubtraction.c
r32695 r33089 905 905 } 906 906 } 907 if (!psThreadPoolWait(true )) {907 if (!psThreadPoolWait(true, true)) { 908 908 psError(psErrorCodeLast(), false, "Error waiting for threads."); 909 909 return false; … … 1427 1427 } 1428 1428 1429 if (!psThreadPoolWait(false )) {1429 if (!psThreadPoolWait(false, true)) { 1430 1430 psError(psErrorCodeLast(), false, "Error waiting for threads."); 1431 1431 return false; -
trunk/psModules/src/imcombine/pmSubtractionEquation.c
r30622 r33089 958 958 } 959 959 960 if (!psThreadPoolWait(true )) {960 if (!psThreadPoolWait(true, true)) { 961 961 psError(psErrorCodeLast(), false, "Error waiting for threads."); 962 962 return false; -
trunk/psModules/src/imcombine/pmSubtractionEquation.v0.c
r30622 r33089 882 882 } 883 883 884 if (!psThreadPoolWait(true )) {884 if (!psThreadPoolWait(true, true)) { 885 885 psError(psErrorCodeLast(), false, "Error waiting for threads."); 886 886 return false; -
trunk/psModules/src/imcombine/pmSubtractionMatch.c
r31671 r33089 1091 1091 } 1092 1092 1093 if (!psThreadPoolWait(true )) {1093 if (!psThreadPoolWait(true, true)) { 1094 1094 psError(psErrorCodeLast(), false, "Error waiting for threads."); 1095 1095 psFree(models); -
trunk/psphot/src/psphotApResid.c
r32348 r33089 154 154 155 155 // wait for the threads to finish and manage results 156 if (!psThreadPoolWait (false )) {156 if (!psThreadPoolWait (false, true)) { 157 157 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 158 psFree(cellGroups); 158 159 return false; 159 160 } -
trunk/psphot/src/psphotBlendFit.c
r32695 r33089 151 151 152 152 // wait for the threads to finish and manage results 153 if (!psThreadPoolWait (false )) {153 if (!psThreadPoolWait (false, true)) { 154 154 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 155 155 psFree (fitOptions); -
trunk/psphot/src/psphotExtendedSourceAnalysis.c
r32633 r33089 134 134 135 135 // wait for the threads to finish and manage results 136 if (!psThreadPoolWait (false )) {136 if (!psThreadPoolWait (false, true)) { 137 137 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 138 138 psFree(AnalysisRegion); -
trunk/psphot/src/psphotExtendedSourceFits.c
r32744 r33089 218 218 219 219 // wait for the threads to finish and manage results 220 if (!psThreadPoolWait (false )) {220 if (!psThreadPoolWait (false, true)) { 221 221 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 222 222 psFree(AnalysisRegion); -
trunk/psphot/src/psphotFindFootprints.c
r32348 r33089 35 35 psArray *tmp = pmFootprintArrayGrow(footprints, growRadius); 36 36 psImageConvolveSetThreads(oldThreads); 37 psLogMsg ("psphot", PS_LOG_MINUTIA, "grow footprint coverage by %d pixels, %ld footprints become %ld footprints: %f sec\n", growRadius, footprints->n, tmp->n, psTimerMark ("psphot.footprints")); 38 psFree(footprints); 39 footprints = tmp; 37 psLogMsg ("psphot", PS_LOG_MINUTIA, "grow footprint coverage by %d pixels, %ld footprints become %ld footprints: %f sec\n", growRadius, footprints->n, tmp ? tmp->n : 0, psTimerMark ("psphot.footprints")); 38 if (tmp) { 39 psFree(footprints); 40 footprints = tmp; 41 } else { 42 psLogMsg ("psphot", PS_LOG_WARN, "pmFootprintArray grow returned NULL\n"); 43 } 44 40 45 } 41 46 -
trunk/psphot/src/psphotGuessModels.c
r32996 r33089 112 112 // wait here for the threaded jobs to finish 113 113 // fprintf (stderr, "wait for threads (%d, %d)\n", jx, jy); 114 if (!psThreadPoolWait (false)) { 114 if (!psThreadPoolWait (false, true)) { 115 // harvest our jobs 116 psFree(cellGroups); 115 117 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 116 118 return false; -
trunk/psphot/src/psphotKronIterate.c
r32996 r33089 158 158 159 159 // wait for the threads to finish and manage results 160 if (!psThreadPoolWait (false )) {160 if (!psThreadPoolWait (false, true)) { 161 161 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 162 162 return false; -
trunk/psphot/src/psphotMagnitudes.c
r32348 r33089 129 129 130 130 // wait for the threads to finish and manage results 131 if (!psThreadPoolWait (false )) {131 if (!psThreadPoolWait (false, true)) { 132 132 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 133 133 return false; … … 309 309 310 310 // wait for the threads to finish and manage results 311 if (!psThreadPoolWait (false )) {311 if (!psThreadPoolWait (false, true)) { 312 312 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 313 313 return false; -
trunk/psphot/src/psphotRadialApertures.c
r32633 r33089 176 176 177 177 // wait for the threads to finish and manage results 178 if (!psThreadPoolWait (false )) {178 if (!psThreadPoolWait (false, true)) { 179 179 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 180 180 psFree(AnalysisRegion); -
trunk/psphot/src/psphotRadialProfileWings.c
r32996 r33089 147 147 148 148 // wait for the threads to finish and manage results 149 if (!psThreadPoolWait (false )) {149 if (!psThreadPoolWait (false, true)) { 150 150 psError(PS_ERR_UNKNOWN, false, "Unable to guess model."); 151 151 return false; -
trunk/psphot/src/psphotReadout.c
r32996 r33089 133 133 // Construct an initial model for each object, set the radius to fitRadius, set circular 134 134 // fit mask. NOTE: only applied to sources without guess models 135 psphotGuessModels (config, view, filerule); // pass 1 135 // pass 1 136 if (!psphotGuessModels (config, view, filerule)) { 137 psLogMsg ("psphot", 3, "failure to Guess Model - pass 1"); 138 return psphotReadoutCleanup (config, view, filerule); 139 } 136 140 137 141 // linear PSF fit to source peaks, subtract the models from the image (in PSF mask) … … 155 159 // non-linear PSF and EXT fit to brighter sources 156 160 // replace model flux, adjust mask as needed, fit, subtract the models (full stamp) 161 // XXX: can leave faulted job in done queue 157 162 psphotBlendFit (config, view, filerule); // pass 1 (detections->allSources) 158 163 -
trunk/psphot/src/psphotSourceStats.c
r32699 r33089 216 216 217 217 // wait for the threads to finish and manage results 218 if (!psThreadPoolWait (false )) {218 if (!psThreadPoolWait (false, true)) { 219 219 psError(PS_ERR_UNKNOWN, false, "Failure in thread job PSPHOT_SOURCE_STATS"); 220 220 psFree(detections->newSources); … … 347 347 348 348 // wait for the threads to finish and manage results 349 if (!psThreadPoolWait (false )) {349 if (!psThreadPoolWait (false, true)) { 350 350 psError(PS_ERR_UNKNOWN, false, "Failure in thread job PSPHOT_SOURCE_STATS"); 351 351 return NULL; -
trunk/psphot/src/psphotTest.c
r29936 r33089 85 85 86 86 // wait for the threads to finish and manage results 87 if (!psThreadPoolWait (true )) {87 if (!psThreadPoolWait (true, true)) { 88 88 fprintf (stderr, "failure to run FillImage (2)"); 89 89 exit (1);
Note:
See TracChangeset
for help on using the changeset viewer.
