IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19015


Ignore:
Timestamp:
Aug 11, 2008, 5:08:41 PM (18 years ago)
Author:
Paul Price
Message:

Adding functions to control threading of psImageConvolve functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageConvolve.c

    r18957 r19015  
    77/// @author Eugene Magnier, IfA
    88///
    9 /// @version $Revision: 1.72 $ $Name: not supported by cvs2svn $
    10 /// @date $Date: 2008-08-08 18:07:30 $
     9/// @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2008-08-12 03:08:41 $
    1111///
    1212/// Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    3333
    3434#include "psImageConvolve.h"
     35
     36static bool threaded = false;           // Run image convolution threaded?
     37
     38
     39
    3540
    3641static void kernelFree(psKernel *kernel)
     
    865870}
    866871
    867 
    868872psImage *psImageConvolveMask(psImage *out, const psImage *mask, psMaskType maskVal,
    869873                             psMaskType setVal, int xMin, int xMax, int yMin, int yMax)
     
    899903    }
    900904
    901     static bool threadsInit = false;    // Threads initialised?
    902     int numThreads = psThreadPoolSize();// Number of threads
    903     if (numThreads > 0 && !threadsInit) {
    904         psThreadTask *task = psThreadTaskAlloc("PSLIB_IMAGE_CONVOLVE_MASK", 8);
    905         task->function = &imageConvolveMaskThread;
    906         psThreadTaskAdd(task);
    907         psFree(task);
    908         threadsInit = true;
    909     }
    910 
    911905    int numRows = mask->numRows;        // Number of rows
    912906    int numCols = mask->numCols;        // Number of columns
     
    925919
    926920    // Rows
    927     if (numThreads > 0) {
     921    if (threaded) {
     922        int numThreads = psThreadPoolSize(); // Number of threads
    928923        float cols = (float)numCols / (float)numThreads; // Number of cols to do at once
    929924        for (int i = 0; i < numThreads; i++) {
     
    963958
    964959    // Columns
    965     if (numThreads > 0) {
     960    if (threaded) {
     961        int numThreads = psThreadPoolSize(); // Number of threads
    966962        float cols = (float)numCols / (float)numThreads; // Number of columns to do at once
    967963        for (int i = 0; i < numThreads; i++) {
     
    10641060}
    10651061
     1062
     1063void psImageConvolveSetThreads(bool set)
     1064{
     1065    if (set && !threaded) {
     1066        {
     1067            psThreadTask *task = psThreadTaskAlloc("PSLIB_IMAGE_CONVOLVE_MASK", 8);
     1068            task->function = &imageConvolveMaskThread;
     1069            psThreadTaskAdd(task);
     1070            psFree(task);
     1071        }
     1072    } else if (!set && threaded) {
     1073        psThreadTaskDelete("PSLIB_IMAGE_CONVOLVE_MASK");
     1074    }
     1075
     1076    threaded = set;
     1077
     1078}
     1079
     1080bool psImageConvolveGetThreads(void)
     1081{
     1082    return threaded;
     1083}
     1084
Note: See TracChangeset for help on using the changeset viewer.