Changeset 18884 for trunk/pswarp/src/pswarpTransformReadout_Threaded.c
- Timestamp:
- Aug 4, 2008, 11:12:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpTransformReadout_Threaded.c
r18839 r18884 23 23 24 24 // output mask bits 25 psMaskType maskIn = psMetadataLookupU8(&mdok, recipe, "MASK.INPUT"); 26 psMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); 27 psMaskType maskBad = pmConfigMaskGet("BAD.WARP", config); 25 psMaskType maskIn = psMetadataLookupU8(&mdok, recipe, "MASK.INPUT"); 26 psMaskType maskPoor = pmConfigMaskGet("POOR.WARP", config); 27 psMaskType maskBad = pmConfigMaskGet("BAD.WARP", config); 28 28 psAssert (mdok, "MASK.INPUT was not defined"); 29 29 30 30 // Flux fraction for "poor" 31 float poorFrac = psMetadataLookupF32(NULL, config->arguments, "POOR.FRAC"); 31 float poorFrac = psMetadataLookupF32(NULL, config->arguments, "POOR.FRAC"); 32 32 33 33 // find the output pixel range … … 58 58 59 59 // Interpolation options 60 psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(interpolationMode, inImage, 60 psImageInterpolateOptions *interp = psImageInterpolateOptionsAlloc(interpolationMode, inImage, 61 61 inVar, inMask, maskIn, NAN, NAN, 62 62 maskBad, maskPoor, poorFrac); 63 63 64 64 if (inVar && !output->weight) { 65 output->weight = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_F32);66 psImageInit(output->weight, NAN);65 output->weight = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_F32); 66 psImageInit(output->weight, NAN); 67 67 } 68 68 if ((inMask || maskPoor || maskBad) && !output->mask) { 69 output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_MASK);70 psImageInit(output->mask, maskBad);69 output->mask = psImageAlloc(output->image->numCols, output->image->numRows, PS_TYPE_MASK); 70 psImageInit(output->mask, maskBad); 71 71 } 72 72 … … 76 76 // create jobs and supply them to the threads 77 77 for (gridY = 0; gridY < nGridX; gridY++) { 78 for (gridX = 0; gridX < nGridY; gridX++) {79 80 pswarpTransformTileArgs *args = pswarpTransformTileArgsAlloc();81 82 // these items are just views to the data; they are not freed with args83 args->input = input;84 args->output = output;85 args->grid = grid;86 args->interp = interp;87 args->region = region;88 89 args->gridX = gridX;90 args->gridY = gridY;91 args->goodPixels = 0;92 93 # if (THREADED) 94 // allocate a job95 psThreadJob *job = psThreadJobAlloc ("PSWARP_TRANSFORM_TILE", 0);96 97 // construct the arguments for this job98 // job is pswarpTransformTile (gridX, gridY);99 psArrayAdd (job->args, 1, args);100 psThreadJobAddPending (job);78 for (gridX = 0; gridX < nGridY; gridX++) { 79 80 pswarpTransformTileArgs *args = pswarpTransformTileArgsAlloc(); 81 82 // these items are just views to the data; they are not freed with args 83 args->input = input; 84 args->output = output; 85 args->grid = grid; 86 args->interp = interp; 87 args->region = region; 88 89 args->gridX = gridX; 90 args->gridY = gridY; 91 args->goodPixels = 0; 92 93 # if (THREADED) 94 // allocate a job 95 psThreadJob *job = psThreadJobAlloc ("PSWARP_TRANSFORM_TILE", 0); 96 97 // construct the arguments for this job 98 // job is pswarpTransformTile (gridX, gridY); 99 psArrayAdd (job->args, 1, args); 100 psThreadJobAddPending (job); 101 101 # else 102 pswarpTransformTile (args);103 goodPixels += args->goodPixels;102 pswarpTransformTile (args); 103 goodPixels += args->goodPixels; 104 104 # endif 105 psFree (args);106 }107 } 108 109 # if (THREADED) 105 psFree (args); 106 } 107 } 108 109 # if (THREADED) 110 110 // wait here for the threaded jobs to finish 111 111 if (!psThreadPoolWait ()) { 112 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 113 return false; 114 } 115 fprintf (stderr, "success for threaded jobs\n"); 112 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 113 return false; 114 } 116 115 117 116 // each job records its own goodPixel values; sum them here … … 119 118 psThreadJob *job = NULL; 120 119 while ((job = psThreadJobGetDone()) != NULL) { 121 pswarpTransformTileArgs *args = job->args->data[0];122 goodPixels += args->goodPixels;123 psFree (job);120 pswarpTransformTileArgs *args = job->args->data[0]; 121 goodPixels += args->goodPixels; 122 psFree (job); 124 123 } 125 124 # endif
Note:
See TracChangeset
for help on using the changeset viewer.
