Commit 0cdf6f37 authored by George Zagaris's avatar George Zagaris
Browse files

Merge remote-tracking branch 'origin/master' into AMR-Refactoring

parents 5ac7dc34 0661c8ba
/*=========================================================================
Program: Visualization Toolkit
Module: TestRandomMomentStatisticsMPI.cxx
Program: Visualization Toolkit
Module: TestRandomMomentStatisticsMPI.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*
......@@ -48,7 +48,11 @@
struct RandomSampleStatisticsArgs
{
int nVals;
bool descOnly;
bool skipDescriptive;
bool skipPDescriptive;
bool skipPCorrelative;
bool skipPMultiCorrelative;
bool skipPPCA;
int* retVal;
int ioRank;
};
......@@ -69,7 +73,7 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
// Seed random number generator
vtkMath::RandomSeed( static_cast<int>( vtkTimerLog::GetUniversalTime() ) * ( myRank + 1 ) );
// Generate an input table that contains samples of mutually independent random variables over [0, 1]
// Generate an input table that contains samples of mutually independent random variables
int nUniform = 2;
int nNormal = 2;
int nVariables = nUniform + nNormal;
......@@ -117,31 +121,16 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
doubleArray[c]->Delete();
}
// "68-95-99.7 rule"
// Actually testing for 1, ..., numRuleVa standard deviations
int numRuleVal = 6;
// Reference values
double sigmaRuleVal[] = { 68.2689492137,
95.4499736104,
99.7300203937,
99.9936657516,
99.9999426697,
99.9999998027 };
// Tolerances
double sigmaRuleTol[] = { 1.,
.5,
.1,
.05,
.01,
.005 };
// Create timer to be used by all tests
vtkTimerLog *timer=vtkTimerLog::New();
// ************************** Descriptive Statistics **************************
// ************************** Serial descriptive Statistics **************************
// Skip serial descriptive statistics if requested
if ( ! args->skipDescriptive )
{
// Synchronize and start clock
com->Barrier();
vtkTimerLog *timer=vtkTimerLog::New();
timer->StartTimer();
// For verification, instantiate a serial descriptive statistics engine and set its ports
......@@ -154,9 +143,9 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
ds->AddColumn( columnNames[c] );
}
// Test (serially) with Learn and Derive options only
// Test (serially) with Learn operation only (this is only to verify parallel statistics)
ds->SetLearnOption( true );
ds->SetDeriveOption( true );
ds->SetDeriveOption( false );
ds->SetAssessOption( false );
ds->SetTestOption( false );
ds->Update();
......@@ -164,7 +153,6 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
// Get output data and meta tables
vtkMultiBlockDataSet* outputMetaDS = vtkMultiBlockDataSet::SafeDownCast( ds->GetOutputDataObject( vtkStatisticsAlgorithm::OUTPUT_MODEL ) );
vtkTable* outputPrimary = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 0 ) );
vtkTable* outputDerived = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 1 ) );
// Collect (local) cardinalities, extrema, and means
int nRows = outputPrimary->GetNumberOfRows();
......@@ -254,7 +242,7 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
if ( com->GetLocalProcessId() == args->ioRank )
{
cout << "\n## Completed serial calculations of descriptive statistics (with assessment):\n"
cout << "\n## Completed serial calculations of descriptive statistics:\n"
<< " With partial aggregation calculated on process "
<< calcProc
<< "\n"
......@@ -262,6 +250,7 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
<< timer->GetElapsedTime()
<< " sec.\n";
cout << " Calculated the following primary statistics:\n";
for ( vtkIdType r = 0; r < nRows; ++ r )
{
cout << " "
......@@ -296,8 +285,37 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
delete [] extrema_g;
ds->Delete();
} // if ( ! args->skipDescriptive )
else if ( com->GetLocalProcessId() == args->ioRank )
{
cout << "\n## Skipped serial calculations of descriptive statistics.\n";
}
// ************************** Parallel Descriptive Statistics **************************
// Skip parallel descriptive statistics if requested
if ( ! args->skipPDescriptive )
{
// Now on to the actual parallel descriptive engine
// "68-95-99.7 rule" for 1 up to numRuleVal standard deviations
int numRuleVal = 6;
// Reference values
double sigmaRuleVal[] = { 68.2689492137,
95.4499736104,
99.7300203937,
99.9936657516,
99.9999426697,
99.9999998027 };
// Tolerances
double sigmaRuleTol[] = { 1.,
.5,
.1,
.05,
.01,
.005 };
// Synchronize and start clock
com->Barrier();
......@@ -313,7 +331,7 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
pds->AddColumn( columnNames[c] );
}
// Test (in parallel) with Learn, Derive, and Assess options turned on
// Test (in parallel) with Learn, Derive, and Assess operations turned on
pds->SetLearnOption( true );
pds->SetDeriveOption( true );
pds->SetAssessOption( true );
......@@ -326,9 +344,9 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
timer->StopTimer();
// Get output data and meta tables
outputMetaDS = vtkMultiBlockDataSet::SafeDownCast( pds->GetOutputDataObject( vtkStatisticsAlgorithm::OUTPUT_MODEL ) );
outputPrimary = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 0 ) );
outputDerived = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 1 ) );
vtkMultiBlockDataSet* outputMetaDS = vtkMultiBlockDataSet::SafeDownCast( pds->GetOutputDataObject( vtkStatisticsAlgorithm::OUTPUT_MODEL ) );
vtkTable* outputPrimary = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 0 ) );
vtkTable* outputDerived = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 1 ) );
vtkTable* outputData = pds->GetOutput( vtkStatisticsAlgorithm::OUTPUT_DATA );
if ( com->GetLocalProcessId() == args->ioRank )
......@@ -452,7 +470,7 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
cout << " "
<< testVal
<< "\\% within "
<< "% within "
<< i + 1
<< " standard deviation(s) from the mean.\n";
......@@ -473,16 +491,17 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
// Clean up
pds->Delete();
// If only descriptive statistics were required, complete clean up and bail out from here
if ( args->descOnly )
} // if ( ! args->skipPDescriptive )
else if ( com->GetLocalProcessId() == args->ioRank )
{
inputData->Delete();
timer->Delete();
return;
cout << "\n## Skipped calculation of parallel descriptive statistics.\n";
}
// ************************** Correlative Statistics **************************
// ************************** Parallel Correlative Statistics **************************
// Skip parallel correlative statistics if requested
if ( ! args->skipPCorrelative )
{
// Synchronize and start clock
com->Barrier();
timer->StartTimer();
......@@ -495,7 +514,7 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
pcs->AddColumnPair( columnNames[0], columnNames[1] );
pcs->AddColumnPair( columnNames[2], columnNames[3] );
// Test (in parallel) with Learn, Derive options turned on
// Test (in parallel) with Learn, Derive operations turned on
pcs->SetLearnOption( true );
pcs->SetDeriveOption( true );
pcs->SetAssessOption( false );
......@@ -503,9 +522,9 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
pcs->Update();
// Get output data and meta tables
outputMetaDS = vtkMultiBlockDataSet::SafeDownCast( pcs->GetOutputDataObject( vtkStatisticsAlgorithm::OUTPUT_MODEL ) );
outputPrimary = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 0 ) );
outputDerived = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 1 ) );
vtkMultiBlockDataSet* outputMetaDS = vtkMultiBlockDataSet::SafeDownCast( pcs->GetOutputDataObject( vtkStatisticsAlgorithm::OUTPUT_MODEL ) );
vtkTable* outputPrimary = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 0 ) );
vtkTable* outputDerived = vtkTable::SafeDownCast( outputMetaDS->GetBlock( 1 ) );
// Synchronize and stop clock
com->Barrier();
......@@ -552,9 +571,17 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
// Clean up
pcs->Delete();
} // if ( ! args->skipPCorrelative )
else if ( com->GetLocalProcessId() == args->ioRank )
{
cout << "\n## Skipped calculation of parallel correlative statistics.\n";
}
// ************************** Multi-Correlative Statistics **************************
// ************************** Parallel Multi-Correlative Statistics **************************
// Skip parallel multi-correlative statistics if requested
if ( ! args->skipPMultiCorrelative )
{
// Synchronize and start clock
com->Barrier();
timer->StartTimer();
......@@ -580,14 +607,15 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
pmcs->SetColumnStatus( columnNames[3], true );
pmcs->RequestSelectedColumns();
// Test (in parallel) with Learn, Derive, and Assess options turned on
// Test (in parallel) with Learn, Derive, and Assess operations turned on
pmcs->SetLearnOption( true );
pmcs->SetDeriveOption( true );
pmcs->SetAssessOption( true );
pmcs->SetTestOption( false );
pmcs->Update();
// Get output meta tables
outputMetaDS = vtkMultiBlockDataSet::SafeDownCast( pmcs->GetOutputDataObject( vtkStatisticsAlgorithm::OUTPUT_MODEL ) );
vtkMultiBlockDataSet* outputMetaDS = vtkMultiBlockDataSet::SafeDownCast( pmcs->GetOutputDataObject( vtkStatisticsAlgorithm::OUTPUT_MODEL ) );
// Synchronize and stop clock
com->Barrier();
......@@ -613,9 +641,17 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
// Clean up
pmcs->Delete();
} // if ( ! args->skipPMultiCorrelative )
else if ( com->GetLocalProcessId() == args->ioRank )
{
cout << "\n## Skipped calculation of parallel multi-correlative statistics.\n";
}
// ************************** PCA Statistics **************************
// ************************** Parallel PCA Statistics **************************
// Skip parallel PCA statistics if requested
if ( ! args->skipPPCA )
{
// Synchronize and start clock
com->Barrier();
timer->StartTimer();
......@@ -641,14 +677,15 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
pcas->SetColumnStatus( columnNames[3], true );
pcas->RequestSelectedColumns();
// Test (in parallel) with Learn, Derive, and Assess options turned on
// Test (in parallel) with all operations turned on (because Test for parallel PCA allows to detect problems)
pcas->SetLearnOption( true );
pcas->SetDeriveOption( true );
pcas->SetAssessOption( true );
pcas->SetTestOption( true );
pcas->Update();
// Get output meta tables
outputMetaDS = vtkMultiBlockDataSet::SafeDownCast( pcas->GetOutputDataObject( vtkStatisticsAlgorithm::OUTPUT_MODEL ) );
vtkMultiBlockDataSet* outputMetaDS = vtkMultiBlockDataSet::SafeDownCast( pcas->GetOutputDataObject( vtkStatisticsAlgorithm::OUTPUT_MODEL ) );
// Synchronize and stop clock
com->Barrier();
......@@ -674,6 +711,13 @@ void RandomSampleStatistics( vtkMultiProcessController* controller, void* arg )
// Clean up
pcas->Delete();
} // if ( ! args->skipPPCA )
else if ( com->GetLocalProcessId() == args->ioRank )
{
cout << "\n## Skipped calculation of parallel PCA statistics.\n";
}
// Clean up
inputData->Delete();
timer->Delete();
}
......@@ -754,7 +798,11 @@ int main( int argc, char** argv )
// **************************** Parse command line ***************************
// Set default argument values
int nVals = 100000;
bool descOnly = false;
bool skipDescriptive = false;
bool skipPDescriptive = false;
bool skipPCorrelative = false;
bool skipPMultiCorrelative = false;
bool skipPPCA = false;
// Initialize command line argument parser
vtksys::CommandLineArguments clArgs;
......@@ -766,10 +814,30 @@ int main( int argc, char** argv )
vtksys::CommandLineArguments::SPACE_ARGUMENT,
&nVals, "Per-process cardinality of each pseudo-random sample");
// Parse whether only descriptive statistics should be tested (for faster testing)
clArgs.AddArgument("--descriptive-only",
// Parse whether serial descriptive statistics should be skipped (for faster testing)
clArgs.AddArgument("--skip-Descriptive",
vtksys::CommandLineArguments::NO_ARGUMENT,
&skipDescriptive, "Skip serial descriptive statistics");
// Parse whether parallel descriptive statistics should be skipped (for faster testing)
clArgs.AddArgument("--skip-PDescriptive",
vtksys::CommandLineArguments::NO_ARGUMENT,
&skipPDescriptive, "Skip parallel descriptive statistics");
// Parse whether parallel correlative statistics should be skipped (for faster testing)
clArgs.AddArgument("--skip-PCorrelative",
vtksys::CommandLineArguments::NO_ARGUMENT,
&skipPCorrelative, "Skip parallel correlative statistics");
// Parse whether parallel multi-correlative statistics should be skipped (for faster testing)
clArgs.AddArgument("--skip-PMultiCorrelative",
vtksys::CommandLineArguments::NO_ARGUMENT,
&skipPMultiCorrelative, "Skip parallel multi-correlative statistics");
// Parse whether parallel PCA statistics should be skipped (for faster testing)
clArgs.AddArgument("--skip-PPCA",
vtksys::CommandLineArguments::NO_ARGUMENT,
&descOnly, "Test only descriptive statistics");
&skipPPCA, "Skip parallel PCA statistics");
// If incorrect arguments were provided, terminate in error.
if ( ! clArgs.Parse() )
......@@ -783,7 +851,11 @@ int main( int argc, char** argv )
int testValue = 0;
RandomSampleStatisticsArgs args;
args.nVals = nVals;
args.descOnly = descOnly;
args.skipDescriptive = skipDescriptive;
args.skipPDescriptive = skipPDescriptive;
args.skipPCorrelative = skipPCorrelative;
args.skipPMultiCorrelative = skipPMultiCorrelative;
args.skipPPCA = skipPPCA;
args.retVal = &testValue;
args.ioRank = ioRank;
......
......@@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011)
SET(KWSYS_DATE_STAMP_MONTH 06)
# KWSys version date day component. Format is DD.
SET(KWSYS_DATE_STAMP_DAY 16)
SET(KWSYS_DATE_STAMP_DAY 17)
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