Commit 92995913 authored by David Thompson's avatar David Thompson
Browse files

More realistic bounds on samples required...

... for determining whether an array behaves like a discrete set or not.
We require 32*log2(N) samples instead of just log2(N). This commit
adjusts the test so that it continues to perform random sampling of an
array with the increased minimum number of samples required.

Change-Id: Ia26c3ca0570ac718626c6897cd48bacd4c44bae5
parent 5ab37848
......@@ -101,12 +101,28 @@ static int numUniqueInt2[] = {
static vtkStdString testTuplesString[] = {
/*
To test the log(N) sampling strategy, we must
have more than 64 entries in the array.
have more than 589 entries in the array.
In practice, we need even more as the "cache line"
optimization searches blocks of 8 strings at a time.
This array has 230 values and we should test
max(ceil(log2(230)),min(230,2*32)) = 64 tuples.
This array has 645 values and we should test
max(ceil(32*log2(645)),min(645,2*32)) = 299 tuples.
Because of the cache line size, we actually test 320
tuples. For arrays with fewer than twice as many
tuples as we are set to test, we simply test the whole
array, so *more* than 640 entries are required.
The 4 words marked "not detected" below are placed
so as to avoid the random choice of blocks to test
on at least one platform.
The vtkObject ModificationTime counter is used as a
seed for the random number generator and its count
will vary across platforms and compile-time options,
so we accept anywhere from 4 to 8 values being detected.
*/
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Skeenie", "Beeny", "Piny", "Po", "Po", // not detected.
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
......@@ -153,6 +169,85 @@ static vtkStdString testTuplesString[] = {
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
"Eeny", "Meeny", "Miny", "Mo", "Miny",
};
static int numUniqueString[2] = {
4, 8,
......
......@@ -592,15 +592,21 @@ void vtkAbstractArray::UpdateDiscreteValueSet()
// M is chosen based on the number of bytes per tuple to maximize use of a cache
// line (assuming a 64-byte cache line until kwsys::SystemInformation or the like
// can provide a platform-independent way to query it).
// N is chosen to satisfy M*N = max(ceil(log(T)),min(2*MAX_DISCRETE_VALUES,T))
// N is chosen to satisfy M*N = max(ceil(K*log(T)),min(2*MAX_DISCRETE_VALUES,T))
// where K is VTK_SAMPLE_FACTOR that indicates the constant big-O factor by
// which log2(T) bounds the number of samples we should evaluate.
#define VTK_CACHE_LINE_SIZE 64
#define VTK_SAMPLE_FACTOR 32
int nc = this->NumberOfComponents;
int blockSize = VTK_CACHE_LINE_SIZE / (this->GetDataTypeSize() * nc);
if (!blockSize) blockSize = 4;
int ln2 = 0;
vtkIdType nt = this->GetNumberOfTuples();
if (this->MaxId > 0) frexp(static_cast<double>(nt), &ln2);
vtkIdType numberOfSampleTuples = (ln2 <= 0 ? 1 : ln2);
if (this->MaxId > 0)
{
frexp(static_cast<double>(nt), &ln2);
}
vtkIdType numberOfSampleTuples = VTK_SAMPLE_FACTOR * (ln2 <= 0 ? 1 : ln2);
vtkIdType numberOfBlocks =
numberOfSampleTuples / blockSize +
(numberOfSampleTuples % blockSize ? 1 : 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment