IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 11, 2012, 10:16:48 AM (14 years ago)
Author:
bills
Message:

Fix problems with IPP threading. In psThreadPoolWait wait until all threads have
finished before returning even if one of the threads has a fault.
Return false if any thread faults. Also add a new argument bool harvestOnFailure
which tells psThreadPoolWait to harvest the done jobs if there is a failure.
Many functions previously used psThreadPoolWait(harvest = false) because they
wanted to examine the jobs structs afterwards. However they weren't cleaning up the
jobs in the failure case.
These now call psThreadPoolWait(harvest = false, harvestOnFailure = true)
which causes the jobs to be cleaned up on fault. These lingering jobs were the
cause of the "Unknown task" failure in psImageConvolve*
Also changed psphotReadout to check for failure of psphotGuessModels and return
to the caller. This yields quality = 3007

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psThread.c

    r32715 r33089  
    179179    PS_ASSERT_THREAD_TASK_NON_NULL(task, false);
    180180
     181    // fprintf(stderr, "adding task %s\n", task->type);
     182
    181183    if (!tasks) {
    182184        tasks = psHashAlloc(TASK_BUCKETS);
     
    189191{
    190192    PS_ASSERT_STRING_NON_EMPTY(type, false);
     193    // fprintf(stderr, "removing task %s\n", type);
    191194
    192195    return psHashRemove(tasks, type);
     
    223226
    224227        psThreadTask *task = psHashLookup(tasks, job->type); // Task to execute job
     228        // fprintf(stderr, "launching job %s\n", job->type);
    225229#ifdef HAVE_BACKTRACE
    226230        if (!task && bt_buffer) {
     
    246250                 "invalid number of arguments to %s (%ld supplied, expected %d)",
    247251                 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
    248255        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);
    249258
    250259        // Put the completed job on the 'done' queue
     
    306315
    307316// call this function after you have added jobs to the queue and
    308 bool psThreadPoolWait(bool harvest)
    309 {
     317bool psThreadPoolWait(bool harvest, bool harvestOnFailure)
     318{
     319    // fprintf(stderr, "psThreadPoolWait called with harvest: %d\n", harvest);
    310320    if (!pool || pool->n == 0) {
    311321        // No threads initialised, so everything's done
     
    326336#endif
    327337
     338    // accumulate the number of faulted jobs that we encounter
     339    int numFaults = 0;
    328340    while (1) {
    329341        // check for an error
     
    331343            psThread *thread = pool->data[i];
    332344            if (thread->fault) {
    333                 return false;
     345                numFaults++;
    334346            }
    335347        }
     
    354366            // Nothing in the queue and nothing more to add
    355367            // Ensure everything is harvested, if requested
    356             if (harvest) {
     368            if (harvest || (numFaults && harvestOnFailure)) {
    357369                psThreadJobHarvest();
    358370            }
    359371            psThreadUnlock();
    360             return true;
     372            return numFaults == 0;
    361373        }
    362374
Note: See TracChangeset for help on using the changeset viewer.