IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 31, 2008, 1:24:22 PM (18 years ago)
Author:
eugene
Message:

some threading simplifications: threaded and unthreaded use the same code; added concept of a thread task

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20080719/pswarp/src/pswarpTransformReadout.c

    r18753 r18822  
    7171            args->goodPixels = 0;
    7272
    73             if (nThreads) {
    74                 // allocate a job
    75                 psThreadJob *job = psThreadJobAlloc ("PSWARP_TRANSFORM_TILE", 0);
     73            // allocate a job
     74            psThreadJob *job = psThreadJobAlloc ("PSWARP_TRANSFORM_TILE");
    7675
    77                 // construct the arguments for this job
    78                 // job is pswarpTransformTile (gridX, gridY);
    79                 psArrayAdd (job->args, 1, args);
    80                 // fprintf (stderr, "adding job %d,%d, Nargs: %ld\n", gridX, gridY, job->args->n);
    81                 psThreadJobAddPending (job);
    82             } else {
    83                 pswarpTransformTile (args);
    84                 goodPixels += args->goodPixels;
     76            // construct the arguments for this job
     77            // job is pswarpTransformTile (gridX, gridY);
     78            psArrayAdd (job->args, 1, args);
     79            // fprintf (stderr, "adding job %d,%d, Nargs: %ld\n", gridX, gridY, job->args->n);
     80
     81            // call: pswarpTransformTile (args);
     82            if (!psThreadJobAddPending (job)) {
     83                psError(PS_ERR_UNKNOWN, false, "Unable to warp image.");
     84                return false;
    8585            }
    8686            psFree (args);
     
    8989
    9090    // wait for the threads to finish and manage results
    91     if (nThreads) {
    92         // wait here for the threaded jobs to finish
    93         if (!psThreadPoolWait ()) {
    94             psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
    95             return false;
     91    // wait here for the threaded jobs to finish
     92    if (!psThreadPoolWait ()) {
     93        psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
     94        return false;
     95    }
     96    fprintf (stderr, "success for threaded jobs\n");
     97
     98    // each job records its own goodPixel values; sum them here
     99    // we have only supplied one type of job, so we can assume the types here
     100    psThreadJob *job = NULL;
     101    while ((job = psThreadJobGetDone()) != NULL) {
     102        if (job->args->n < 1) {
     103            fprintf (stderr, "error with job\n");
     104        } else {
     105            pswarpTransformTileArgs *args = job->args->data[0];
     106            // fprintf (stderr, "finished job %d,%d, Nargs: %ld\n", args->gridX, args->gridY, job->args->n);
     107            goodPixels += args->goodPixels;
    96108        }
    97         fprintf (stderr, "success for threaded jobs\n");
    98 
    99         // each job records its own goodPixel values; sum them here
    100         // we have only supplied one type of job, so we can assume the types here
    101         psThreadJob *job = NULL;
    102         while ((job = psThreadJobGetDone()) != NULL) {
    103             if (job->args->n < 1) {
    104                 fprintf (stderr, "error with job\n");
    105             } else {
    106                 pswarpTransformTileArgs *args = job->args->data[0];
    107                 // fprintf (stderr, "finished job %d,%d, Nargs: %ld\n", args->gridX, args->gridY, job->args->n);
    108                 goodPixels += args->goodPixels;
    109             }
    110             psFree (job);
    111         }
     109        psFree (job);
    112110    }
    113111    psFree(interp);
Note: See TracChangeset for help on using the changeset viewer.