static void skipWriteUnlock(skipList list) {

  int flush;

  if(! list->threaded)
    return;

  if((list->cached > list->flushLimit) && (! list->flushing)) {
    list->flushing = TRUE;
    flush = TRUE;
  }
  else {
    flush = FALSE;
  }

  writeUnlock(list);                      /* let any pending writes complete */
  readUnlock(list, NULL, NULL);                         /* no longer reading */

  if(flush) {
                                        /* we are now flushing deleted items */

    readBlock(list);                               /* acquire all read locks */

                              /* at this point no readers/writers are active */

    skipFlushDeleted(list, FALSE);                    /* flush deleted items */

    list->flushing = FALSE;                                 /* done flushing */

    readUnblock(list);                              /* let everyone continue */
  }

  return;
}
Example #2
0
double Matrix::average() const
{
    if (isUniform()) {
        return getUniformValue();
    } else {
        const int dev = computeStrategy1();
        readLock(dev);
        const double avg = matty::getDevice(dev)->average(getArray(dev));
        readUnlock(dev);
        return avg;
    }
}
Example #3
0
double Matrix::sum() const
{
    if (isUniform()) {
        return getUniformValue() * getShape().getNumEl();
    } else {
        const int dev = computeStrategy1();
        readLock(dev);
        const double sum = matty::getDevice(dev)->sum(getArray(dev));
        readUnlock(dev);
        return sum;
    }
}
Example #4
0
double Matrix::minimum() const
{
    if (isUniform()) {
        return getUniformValue();
    } else {
        const int dev = computeStrategy1();
        readLock(dev);
        const double min = matty::getDevice(dev)->minimum(getArray(dev));
        readUnlock(dev);
        return min;
    }
}
Example #5
0
void Matrix::scale(double factor)
{
    if (factor == 0.0) {
        fill(0.0);
    } else if (isUniform()) {
        fill(getUniformValue() * factor);
    } else {
        const int dev = computeStrategy1();
        readLock(dev);
        matty::getDevice(dev)->scale(getArray(dev), factor);
        readUnlock(dev);
    }
}
Example #6
0
double VectorMatrix::absMax() const
{
	if (isUniform()) {
		const double x = uval[0], y = uval[1], z = uval[2];
		return std::sqrt(x*x+y*y+z*z);
	} else {
		const int dev = computeStrategy1();
		readLock(dev); 
		const double max = matty::getDevice(dev)->absmax3(
			this->getArray(dev, 0), this->getArray(dev, 1), this->getArray(dev, 2)
		);
		readUnlock(dev);
		return max;
	}
}
Example #7
0
void VectorMatrix::scale(double factor)
{
	if (factor == 0.0) {
		fill(Vector3d(0.0, 0.0, 0.0));
	} else if (isUniform()) {
		fill(getUniformValue() * factor);
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		for (int c=0; c<num_arrays; ++c) {
			matty::getDevice(dev)->scale(getArray(dev, c), factor);
		}
		readUnlock(dev);
	}
}
Example #8
0
Vector3d VectorMatrix::average() const
{
	if (isUniform()) {
		return getUniformValue();
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		const Vector3d avg(
			matty::getDevice(dev)->average(getArray(dev, 0)),
			matty::getDevice(dev)->average(getArray(dev, 1)),
			matty::getDevice(dev)->average(getArray(dev, 2))
		);
		readUnlock(dev);
		return avg;
	}
}
Example #9
0
Vector3d VectorMatrix::maximum() const
{
	if (isUniform()) {
		return getUniformValue();
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		const Vector3d max(
			matty::getDevice(dev)->maximum(getArray(dev, 0)),
			matty::getDevice(dev)->maximum(getArray(dev, 1)),
			matty::getDevice(dev)->maximum(getArray(dev, 2))
		);
		readUnlock(dev);
		return max;
	}
}
Example #10
0
void VectorMatrix::scale(const Vector3d &factors)
{
	if (factors == Vector3d(0.0, 0.0, 0.0)) {
		fill(Vector3d(0.0, 0.0, 0.0));
	} else if (isUniform()) {
		const Vector3d uni = getUniformValue();
		fill(Vector3d(uni.x*factors.x, uni.y*factors.y, uni.z*factors.z));
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		matty::getDevice(dev)->scale(getArray(dev, 0), factors.x);
		matty::getDevice(dev)->scale(getArray(dev, 1), factors.y);
		matty::getDevice(dev)->scale(getArray(dev, 2), factors.z);
		readUnlock(dev);
	}
}
Example #11
0
double VectorMatrix::dotSum(const VectorMatrix &other) const
{
	if (isUniform() && other.isUniform()) {
		const double x = uval[0], y = uval[1], z = uval[2];
		const double dot = x*x + y*y + z*z;
		return size() * dot;
	} else {
		const int dev = computeStrategy2(other);
		readLock(dev); if (this != &other) other.readLock(dev);
		const double sum = matty::getDevice(dev)->sumdot3(
			this->getArray(dev, 0), this->getArray(dev, 1), this->getArray(dev, 2),
			other.getArray(dev, 0), other.getArray(dev, 1), other.getArray(dev, 2)
		);
		if (this != &other) other.readUnlock(dev); readUnlock(dev);
		return sum;
	}
}
Example #12
0
Vector3d VectorMatrix::sum() const
{
	if (isUniform()) {
		return getUniformValue() * getShape().getNumEl();
	} else {
		const int dev = computeStrategy1();
		readLock(dev);
		
		const Vector3d sum(
			matty::getDevice(dev)->sum(getArray(dev, 0)),
			matty::getDevice(dev)->sum(getArray(dev, 1)),
			matty::getDevice(dev)->sum(getArray(dev, 2))
		);
		readUnlock(dev);
		return sum;
	}
}
void *skipSearch(skipList list, UINT32 key, void **plock) {

  skipItem y;
  void *value;

  y = skipFind(list, key);                                      /* find item */

  if(y->key == key) {                     /* y has our key, or it isn't here */
    value = y->value;
  }
  else {                              /* didn't find item, don't allow locks */
    value = NULL;
    plock = NULL;
  }

  readUnlock(list, y, plock);

  return value;
}
void *skipNext(skipList list, UINT32 *pkey, void **plock) {

  skipItem y;
  void *value;

  y = skipFind(list, *pkey);                                    /* find item */

  if((y->key == *pkey) && (y != list->tail))      /* skip to next if found y */
    y = y->next[0];

  if(y != list->tail) {                   /* reset key to next, return value */
    *pkey = y->key;
    value = y->value;
  }
  else {                                  /* no next item, don't allow locks */
    value = NULL;
    plock = NULL;
  }

  readUnlock(list, y, plock);

  return value;
}