IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32717


Ignore:
Timestamp:
Nov 18, 2011, 4:54:08 PM (15 years ago)
Author:
eugene
Message:

attempt to avoid the memory corruption we have been hitting : use volatile marker for memBlock and lastMemBlockAllocated; allow job args to have non-zero default size and increment by 8

Location:
tags/ipp-20111110/psLib/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20111110/psLib/src/imageops/psImageConvolve.c

    r30595 r32717  
    859859
    860860            psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_SMOOTHMASK_PIXELS");
    861             psArrayAdd(job->args, 1, out);
    862             psArrayAdd(job->args, 1, (psImage*)image);
    863             psArrayAdd(job->args, 1, (psImage*)mask);
     861            psArrayAdd(job->args, 0, out);
     862            psArrayAdd(job->args, 0, (psImage*)image);
     863            psArrayAdd(job->args, 0, (psImage*)mask);
    864864            PS_ARRAY_ADD_SCALAR(job->args, maskVal, PS_TYPE_IMAGE_MASK);
    865             psArrayAdd(job->args, 1, (psVector*)x);
    866             psArrayAdd(job->args, 1, (psVector*)y);
    867             psArrayAdd(job->args, 1, gaussNorm);
     865            psArrayAdd(job->args, 0, (psVector*)x);
     866            psArrayAdd(job->args, 0, (psVector*)y);
     867            psArrayAdd(job->args, 0, gaussNorm);
    868868            PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
    869869            PS_ARRAY_ADD_SCALAR(job->args, size, PS_TYPE_S32);
     
    12031203                  // allocate a job, construct the arguments for this job
    12041204                  psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_SMOOTHMASK_SCANROWS");
    1205                   psArrayAdd(job->args, 1, calculation);
    1206                   psArrayAdd(job->args, 1, calcMask);
    1207                   psArrayAdd(job->args, 1, (psImage *) image); // cast away const
    1208                   psArrayAdd(job->args, 1, (psImage *) mask); // cast away const
     1205                  psArrayAdd(job->args, 0, calculation);
     1206                  psArrayAdd(job->args, 0, calcMask);
     1207                  psArrayAdd(job->args, 0, (psImage *) image); // cast away const
     1208                  psArrayAdd(job->args, 0, (psImage *) mask); // cast away const
    12091209                  PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
    1210                   psArrayAdd(job->args, 1, gaussNorm);
     1210                  psArrayAdd(job->args, 0, gaussNorm);
    12111211                  PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
    12121212                  PS_ARRAY_ADD_SCALAR(job->args, size,     PS_TYPE_S32);
     
    12501250                  // allocate a job, construct the arguments for this job
    12511251                  psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_SMOOTHMASK_SCANCOLS");
    1252                   psArrayAdd(job->args, 1, output);
    1253                   psArrayAdd(job->args, 1, calculation);
    1254                   psArrayAdd(job->args, 1, calcMask);
     1252                  psArrayAdd(job->args, 0, output);
     1253                  psArrayAdd(job->args, 0, calculation);
     1254                  psArrayAdd(job->args, 0, calcMask);
    12551255                  PS_ARRAY_ADD_SCALAR(job->args, maskVal,  PS_TYPE_IMAGE_MASK);
    1256                   psArrayAdd(job->args, 1, gaussNorm);
     1256                  psArrayAdd(job->args, 0, gaussNorm);
    12571257                  PS_ARRAY_ADD_SCALAR(job->args, minGauss, PS_TYPE_F32);
    12581258                  PS_ARRAY_ADD_SCALAR(job->args, size,     PS_TYPE_S32);
     
    15721572
    15731573            psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_CONVOLVE_MASK");
    1574             psArrayAdd(job->args, 1, conv);
    1575             psArrayAdd(job->args, 1, (psImage*)mask); // Casting away const to put on arguments
     1574            psArrayAdd(job->args, 0, conv);
     1575            psArrayAdd(job->args, 0, (psImage*)mask); // Casting away const to put on arguments
    15761576            PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32);
    15771577            PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32);
     
    16071607
    16081608            psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_CONVOLVE_MASK");
    1609             psArrayAdd(job->args, 1, out);
    1610             psArrayAdd(job->args, 1, conv);
     1609            psArrayAdd(job->args, 0, out);
     1610            psArrayAdd(job->args, 0, conv);
    16111611            PS_ARRAY_ADD_SCALAR(job->args, start, PS_TYPE_S32);
    16121612            PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32);
  • tags/ipp-20111110/psLib/src/imageops/psImageCovariance.c

    r30595 r32717  
    177177            if (threaded) {
    178178                psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_COVARIANCE_CALCULATE");
    179                 psArrayAdd(job->args, 1, out);
    180                 psArrayAdd(job->args, 1, covar);
    181                 psArrayAdd(job->args, 1, (psKernel*)kernel); // Casting away const
     179                psArrayAdd(job->args, 0, out);
     180                psArrayAdd(job->args, 0, covar);
     181                psArrayAdd(job->args, 0, (psKernel*)kernel); // Casting away const
    182182                PS_ARRAY_ADD_SCALAR(job->args, x, PS_TYPE_S32);
    183183                PS_ARRAY_ADD_SCALAR(job->args, y, PS_TYPE_S32);
     
    345345            if (threaded) {
    346346                psThreadJob *job = psThreadJobAlloc("PSLIB_IMAGE_COVARIANCE_BIN");
    347                 psArrayAdd(job->args, 1, out);
    348                 psArrayAdd(job->args, 1, covar);
     347                psArrayAdd(job->args, 0, out);
     348                psArrayAdd(job->args, 0, covar);
    349349                PS_ARRAY_ADD_SCALAR(job->args, bin, PS_TYPE_S32);
    350350                PS_ARRAY_ADD_SCALAR(job->args, binVal, PS_TYPE_F32);
  • tags/ipp-20111110/psLib/src/sys/psMemory.c

    r32276 r32717  
    5656
    5757# define USE_SPINLOCK 0
    58 # define USE_HARDLOCK 0
     58# define USE_HARDLOCK 1
    5959
    6060# if (USE_SPINLOCK)
     
    337337/**** Unique ID for allocated blocks and associated accessor functions
    338338 */
    339 static psMemId memid = 0;
     339static volatile psMemId memid = 0;
    340340
    341341/* Return memory ID counter for next block to be allocated
     
    384384// pointer to the last mem block that was allocated.
    385385// This is the root of the entire memory list
    386 static psMemBlock *lastMemBlockAllocated = NULL;
     386static volatile psMemBlock *lastMemBlockAllocated = NULL;
    387387
    388388// set lock on lastMemBlockAllocated
     
    655655    memBlock->refCounter = 1;                   // one user so far
    656656
    657     psMemBlock *last0 = lastMemBlockAllocated;
    658     int flight0 = (lastMemBlockAllocated) ? lastMemBlockAllocated->inFlight : 10;
     657    // XXX these lines are test lines that potentially access invalid memory
     658    // XXX psMemBlock *last0 = lastMemBlockAllocated;
     659    // XXX int flight0 = (lastMemBlockAllocated) ? lastMemBlockAllocated->inFlight : 10;
    659660
    660661    // need exclusive access of the memory block list now...
     
    663664    BLOCKLAST_LOCK ();
    664665
    665     psMemBlock *last1 = lastMemBlockAllocated;
    666     int flight1 = (lastMemBlockAllocated) ? lastMemBlockAllocated->inFlight : 10;
    667 
    668     if (false) {
    669         fprintf (stderr, "last 0 : %lld, last 1 : %lld, flight0: %d, flight1: %d\n", (long long int) last0, (long long int) last1, (int) flight0, (int) flight1);
    670     }
     666    // XXX psMemBlock *last1 = lastMemBlockAllocated;
     667    // XXX int flight1 = (lastMemBlockAllocated) ? lastMemBlockAllocated->inFlight : 10;
     668
     669    // XXX if (false) {
     670    // XXX      fprintf (stderr, "last 0 : %lld, last 1 : %lld, flight0: %d, flight1: %d\n", (long long int) last0, (long long int) last1, (int) flight0, (int) flight1);
     671    // XXX }
    671672
    672673    // increment the memory id only after we've grabbed the memBlockListMutex this value is
     
    679680        lastMemBlockAllocated->previousBlock = memBlock;
    680681    }
    681     memBlock->nextBlock = lastMemBlockAllocated;
     682    memBlock->nextBlock = (psMemBlock *) lastMemBlockAllocated;
    682683    lastMemBlockAllocated = memBlock;
    683684
     
    909910    psS32 nleak = 0;
    910911    psS32 j = 0;
    911     psMemBlock *topBlock = lastMemBlockAllocated;
     912    psMemBlock *topBlock = (psMemBlock *) lastMemBlockAllocated;
    912913
    913914    // XXX move this elsewhere?
    914915    if (fd != NULL) {
     916# if (USE_HARDLOCK)
     917# else
    915918      fprintf (fd, "set %d locks, cleared %d locks, retry on %d locks (memID %ld)\n", setLock, clearLock, retryLock, memid);
     919# endif
    916920    }
    917921
     
    12931297
    12941298    psS32 nbad = 0;               // number of bad blocks
    1295     for (psMemBlock *memBlock = lastMemBlockAllocated; memBlock != NULL; memBlock = memBlock->nextBlock) {
     1299    for (psMemBlock *memBlock = (psMemBlock *) lastMemBlockAllocated; memBlock != NULL; memBlock = memBlock->nextBlock) {
    12961300        if (isBadMemBlock(output, memBlock, __FILE__, __LINE__, __func__)) {
    12971301            nbad++;
     
    13241328
    13251329    // loop through the linked list of memBlocks looking for a matching pointer
    1326     for (psMemBlock *memBlock = lastMemBlockAllocated; memBlock != NULL; memBlock = memBlock->nextBlock) {
     1330    for (psMemBlock *memBlock = (psMemBlock *) lastMemBlockAllocated; memBlock != NULL; memBlock = memBlock->nextBlock) {
    13271331        if (memBlock == addr) {
    13281332            // we found the memBlock
     
    13751379    size_t alloc = 0, persist = 0;
    13761380    size_t nalloc = 0, npersist = 0;
    1377     for (psMemBlock* ptr = lastMemBlockAllocated; ptr != NULL; ptr = ptr->nextBlock) {
     1381    for (psMemBlock* ptr = (psMemBlock *) lastMemBlockAllocated; ptr != NULL; ptr = ptr->nextBlock) {
    13781382        assert (ptr->refCounter > 0);
    13791383
  • tags/ipp-20111110/psLib/src/sys/psThread.c

    r32481 r32717  
    9191
    9292    job->type = psStringCopy(type);
    93     job->args = psArrayAlloc(0);
     93    job->args = psArrayAllocEmpty(16);
    9494    job->results = NULL;
    9595    return job;
  • tags/ipp-20111110/psLib/src/types/psArray.c

    r26892 r32717  
    3535#include "psSort.h"
    3636
    37 #define DEFAULT_ARRAY_ADD 10            // Default number to add to an array when not specified
     37#define DEFAULT_ARRAY_ADD 8            // Default number to add to an array when not specified
    3838
    3939/*****************************************************************************
  • tags/ipp-20111110/psLib/src/types/psArray.h

    r26892 r32717  
    171171#define PS_ARRAY_ADD_SCALAR(ARRAY, VALUE, TYPE) { \
    172172      psScalar *scalar = psScalarAlloc(VALUE, TYPE); \
    173       psArrayAdd(ARRAY, 1, scalar); \
     173      psArrayAdd(ARRAY, 0, scalar); \
    174174      psFree(scalar); \
    175175}
Note: See TracChangeset for help on using the changeset viewer.