Commit 1f5532b6 authored by whitlocb's avatar whitlocb

Fix named selection errors and some CQ issues.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@15046 18c085ea-50e0-402c-830e-de6fd14e8384
parent d1f0928f
......@@ -734,6 +734,14 @@ avtDatasetExaminer::GetNumberOfNodes(avtDataset_p &ds, VISIT_LONG_LONG &nReal,
// Programmer: Hank Childs
// Creation: May 21, 2010
//
// Modifications:
// Brad Whitlock, Tue Jun 14 13:41:24 PST 2011
// Don't return early if any processors failed. Those processors will just
// not contribute to the results. We still return false in the event that
// any processors failed though so we can test for it. I made this change
// because I was calling this routine in a filter where some processors
// had no data and it caused me to have NO histogram information.
//
// ****************************************************************************
bool
......@@ -744,7 +752,7 @@ avtDatasetExaminer::CalculateHistogram(avtDataset_p &ds,
{
avtDataTree_p dataTree = ds->dataTree;
bool ranGood = true;
bool err = false;
CalculateHistogramArgs args;
int t1 = visitTimer->StartTimer();
if (*dataTree != NULL)
......@@ -753,22 +761,29 @@ avtDatasetExaminer::CalculateHistogram(avtDataset_p &ds,
args.max = max;
args.variable = var;
args.numVals.resize(numvals.size(), 0);
dataTree->Traverse(CCalculateHistogram, (void *) &args, ranGood);
dataTree->Traverse(CCalculateHistogram, (void *) &args, err);
}
visitTimer->StopTimer(t1, "Per-processor histogram calculation");
int t2 = visitTimer->StartTimer();
int iFailed = (ranGood ? 1 : 0);
int iFailed = (err ? 1 : 0);
int somebodyFailed = UnifyMaximumValue(iFailed);
if (somebodyFailed)
return false;
SumLongLongArrayAcrossAllProcessors(&(args.numVals[0]), &(numvals[0]),
// Create a vector that will serve as input to the global sum. We put
// zeroes if this processor has no data. Otherwise, we use the histogram.
std::vector<VISIT_LONG_LONG> input(numvals.size(), 0);
if(!err)
{
for(size_t i = 0; i < numvals.size(); ++i)
input[i] = args.numVals[i];
}
// Sum the vector element-wise, placing results in numvals.
SumLongLongArrayAcrossAllProcessors(&input[0], &(numvals[0]),
numvals.size());
visitTimer->StopTimer(t2, "Parallel processing of histogram");
return true;
return somebodyFailed;
}
......@@ -141,6 +141,10 @@ avtNamedSelectionManager::GetInstance(void)
// to the pipeline before we reexecute it. I also changed things so we pass
// in selection properties.
//
// Brad Whitlock, Tue Jun 14 16:58:15 PST 2011
// I fixed a memory corruption problem that caused bad selections to be
// generated in parallel.
//
// ****************************************************************************
void
......@@ -148,6 +152,7 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
const SelectionProperties &selProps, avtNamedSelectionExtension *ext)
{
int i;
const char *mName = "avtNamedSelectionManager::CreateNamedSelection: ";
if (strcmp(dob->GetType(), "avtDataset") != 0)
{
......@@ -189,7 +194,6 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
// save/restore session, etc.
//
SaveNamedSelection(selName, true);
return;
}
......@@ -200,9 +204,9 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
// Perform additional setup using the extension.
avtDataObject_p newdob = ext->GetSelectedData(dob, contract, selProps);
debug5 << "Must execute the pipeline to create the named selection" << endl;
debug5 << mName << "Must execute the pipeline to create the named selection" << endl;
newdob->Update(contract);
debug5 << "Done executing the pipeline to create the named selection" << endl;
debug5 << mName << "Done executing the pipeline to create the named selection" << endl;
CopyTo(ds, newdob);
}
......@@ -210,9 +214,9 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
{
if (needZoneNumbers)
{
debug1 << "Must re-execute pipeline to create named selection" << endl;
debug1 << mName << "Must re-execute pipeline to create named selection" << endl;
dob->Update(contract);
debug1 << "Done re-executing pipeline to create named selection" << endl;
debug1 << mName << "Done re-executing pipeline to create named selection" << endl;
}
CopyTo(ds, dob);
}
......@@ -231,24 +235,36 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
GetArray("avtOriginalCellNumbers");
if (ocn == NULL)
{
delete [] leaves;
EXCEPTION0(ImproperUseException);
}
unsigned int *ptr = (unsigned int *) ocn->GetVoidPointer(0);
if (ptr == NULL)
{
delete [] leaves;
EXCEPTION0(ImproperUseException);
// Write an error to the logs but don't fail out since we have
// a collective communication coming up.
debug5 << mName
<< "This dataset has no original cell numbers so it cannot "
"contribute to the selection." << endl;
}
int ncells = leaves[i]->GetNumberOfCells();
int curSize = doms.size();
doms.resize(curSize+ncells);
zones.resize(curSize+ncells);
for (int j = 0 ; j < ncells ; j++)
else
{
doms[curSize+j] = ptr[2*j];
zones[curSize+j] = ptr[2*j+1];
unsigned int *ptr = (unsigned int *) ocn->GetVoidPointer(0);
if (ptr == NULL)
{
// Write an error to the logs but don't fail out since we have
// a collective communication coming up.
debug5 << mName
<< "This dataset has no original cell numbers so it "
"cannot contribute to the selection." << endl;
}
else
{
// We have original cell numbers so add them to the selection.
int ncells = leaves[i]->GetNumberOfCells();
int curSize = doms.size();
doms.resize(curSize+ncells);
zones.resize(curSize+ncells);
for (int j = 0 ; j < ncells ; j++)
{
doms[curSize+j] = ptr[2*j];
zones[curSize+j] = ptr[2*j+1];
}
}
}
}
delete [] leaves;
......@@ -273,20 +289,22 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
EXCEPTION1(VisItException, "You have selected too many zones in your "
"named selection. Disallowing ... no selection created");
}
int myStart = 0;
for (i = 0 ; i < PAR_Rank()-1 ; i++)
myStart += numPerProc[i];
int *selForDomsIn = new int[numTotal];
int *selForDoms = new int[numTotal];
memset(selForDomsIn, 0, sizeof(int) * numTotal);
for (i = 0 ; i < doms.size() ; i++)
selForDomsIn[myStart+i] = doms[i];
int *selForDoms = new int[numTotal];
SumIntArrayAcrossAllProcessors(selForDomsIn, selForDoms, numTotal);
int *selForZonesIn = new int[numTotal];
int *selForZones = new int[numTotal];
memset(selForZonesIn, 0, sizeof(int) * numTotal);
for (i = 0 ; i < zones.size() ; i++)
selForZonesIn[myStart+i] = zones[i];
int *selForZones = new int[numTotal];
SumIntArrayAcrossAllProcessors(selForZonesIn, selForZones, numTotal);
//
......
......@@ -125,6 +125,8 @@ public:
CQHistogramCalculationFilter() : avtDataTreeIterator(), histograms()
{
cellCount = 0;
totalCellCount = 0;
totalNotSet = true;
}
virtual const char *GetType() { return "CQHistogramCalculationFilter"; }
......@@ -165,12 +167,17 @@ public:
return retval;
}
long GetCellCount() const
long GetTotalCellCount() const
{
return cellCount;
return totalCellCount;
}
protected:
virtual void PreExecute(void)
{
cellCount = 0;
}
virtual vtkDataSet *ExecuteData(vtkDataSet *ds, int dom, std::string)
{
cellCount += ds->GetNumberOfCells();
......@@ -180,6 +187,7 @@ protected:
virtual void PostExecute(void)
{
const char *mName = "CQHistogramCalculationFilter::PostExecute: ";
avtDataObject_p dob = GetInput();
avtDataset_p ds;
CopyTo(ds, dob);
......@@ -187,8 +195,7 @@ protected:
for(std::map<std::string,Histogram*>::iterator it = histograms.begin();
it != histograms.end(); ++it)
{
// Get the extents
double minmax[2] = {0.,0.};
double minmax[2] = {0.,1.};
#if 0
avtExtents *ext = dob->GetInfo().GetAttributes().
GetThisProcsOriginalDataExtents(it->first.c_str());
......@@ -196,17 +203,26 @@ protected:
ext->CopyTo(minmax);
else
#endif
avtDatasetExaminer::GetDataExtents(ds, minmax, it->first.c_str());
// If we have not created a histogram yet for this variable then do it now.
if(it->second == 0)
{
std::vector<VISIT_LONG_LONG> hist(256, 0);
avtDatasetExaminer::CalculateHistogram(ds, it->first, minmax[0], minmax[1], hist);
// Get the extents
avtDatasetExaminer::GetDataExtents(ds, minmax, it->first.c_str());
debug5 << mName << "Calculated data extents for " << it->first
<< " [" << minmax[0] << ", " << minmax[1] << "]" << endl;
std::vector<VISIT_LONG_LONG> hist(256, 0);
if(!avtDatasetExaminer::CalculateHistogram(ds, it->first, minmax[0], minmax[1], hist))
debug1 << "CalculateHistogram failed" << endl;
it->second = new Histogram;
for(int i = 0; i < 256; ++i)
it->second->frequency[i] = (double)hist[i];
// Print the histogram.
debug5 << mName << "Calculated histogram for " << it->first << endl;
for(int i = 0; i < 256; ++i)
debug5 << "\thist[" << i << "] = " << hist[i] << endl;
}
it->second->minimum = minmax[0];
it->second->maximum = minmax[1];
......@@ -214,10 +230,17 @@ protected:
// Sum the cells and send to all procs.
SumLongAcrossAllProcessors(cellCount);
if(totalNotSet)
{
totalCellCount += cellCount;
totalNotSet = false;
}
}
virtual avtContract_p ModifyContract(avtContract_p contract)
{
const char *mName = "CQHistogramCalculationFilter::ModifyContract: ";
avtContract_p newContract = new avtContract(contract);
std::string origvar(newContract->GetDataRequest()->GetOriginalVariable());
......@@ -225,7 +248,7 @@ protected:
it != histograms.end(); ++it)
{
// Request extents
newContract->SetCalculateVariableExtents(it->first, true);
// newContract->SetCalculateVariableExtents(it->first, true);
// Try and get a histogram. If we can't then request the data as a
// secondary variable.
......@@ -238,6 +261,11 @@ protected:
it->second->maximum = hist.GetBounds()[0][1];
for(int i = 0; i < 256; ++i)
it->second->frequency[i] = (double)(hist.GetCounts()[i]);
// Print the histogram.
debug5 << mName << "Obtained existing histogram for " << it->first << endl;
for(int i = 0; i < 256; ++i)
debug5 << "\thist[" << i << "] = " << hist.GetCounts()[i] << endl;
}
else if(origvar != it->first &&
!newContract->GetDataRequest()->HasSecondaryVariable(it->first.c_str()))
......@@ -251,6 +279,8 @@ protected:
std::map<std::string, Histogram *> histograms;
long cellCount;
long totalCellCount;
bool totalNotSet;
};
......@@ -377,6 +407,7 @@ void
CQFilter::CalculateFrequency(std::vector<avtDataTree_p> &timesteps,
CQCellIdentifierCQCellDataMap &cellFrequency, int *cellsPerTimestep)
{
const char *mName = "CQFilter::CalculateFrequency: ";
CQCellIdentifierCQCellDataMap::const_iterator it;
std::string histVar;
......@@ -411,14 +442,16 @@ CQFilter::CalculateFrequency(std::vector<avtDataTree_p> &timesteps,
GetArray("avtOriginalCellNumbers");
if (ocn == NULL)
{
delete [] leaves;
EXCEPTION0(ImproperUseException);
debug5 << mName << "Could not locate original cells. This "
"dataset will not contribute to the selection." << endl;
continue;
}
unsigned int *ptr = (unsigned int *) ocn->GetVoidPointer(0);
if (ptr == NULL)
{
delete [] leaves;
EXCEPTION0(ImproperUseException);
debug5 << mName << "Could not locate original cells. This "
"dataset will not contribute to the selection." << endl;
continue;
}
// If we need an extra variable, get it.
......@@ -1241,7 +1274,8 @@ CumulativeQueryNamedSelectionExtension::FreeUpResources()
// of time steps that were processed because the time loop filter causes our
// local histogram filter that counts the number of original cells to sum the
// total number of cells for all time steps. This gives us the per time step avg.
s.SetTotalCellCount((int)hist->GetCellCount() / nts);
debug5 << "CQnamedSelectionExtension: total cells = " << hist->GetTotalCellCount() << endl;
s.SetTotalCellCount((int)hist->GetTotalCellCount());
if(hist != NULL)
delete hist;
hist = NULL;
......
......@@ -455,6 +455,7 @@ NetworkManager::ClearAllNetworks(void)
//
// Mark C. Miller, Tue Jan 4 10:23:19 PST 2005
// Modified for viswinMap object
//
// ****************************************************************************
void
NetworkManager::ClearNetworksWithDatabase(const std::string &db)
......@@ -480,6 +481,7 @@ NetworkManager::ClearNetworksWithDatabase(const std::string &db)
}
}
// Remove the database from the cache and delete it.
for (size_t i = 0; i < databaseCache.size(); i++)
{
if (databaseCache[i] != NULL)
......@@ -3799,6 +3801,8 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
// stripped down hybrid of StartNetwork and EndNetwork.
TRY
{
debug1 << mName << "Try creating new db source for "
<< props.GetSource() << " named selection." << endl;
std::string leaf = ParsingExprList::GetRealVariable(var);
// Add an expression filter since we may need to do expressions.
......@@ -3833,7 +3837,7 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
}
else
{
debug1 << "Could not get database " << props.GetSource() << " from cache." << endl;
debug1 << mName << "Could not get database " << props.GetSource() << " from cache." << endl;
}
}
else
......@@ -3842,7 +3846,7 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
if (id >= networkCache.size())
{
debug1 << "Internal error: asked to use network ID (" << id
debug1 << mName << "Internal error: asked to use network ID (" << id
<< ") >= num saved networks ("
<< networkCache.size() << ")" << endl;
EXCEPTION0(ImproperUseException);
......@@ -3850,26 +3854,30 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
if (networkCache[id] == NULL)
{
debug1 << "Asked to construct a named selection from a network "
debug1 << mName << "Asked to construct a named selection from a network "
<< "that has already been cleared." << endl;
EXCEPTION0(ImproperUseException);
}
if (id != networkCache[id]->GetNetID())
{
debug1 << "Internal error: network at position[" << id << "] "
debug1 << mName << "Internal error: network at position[" << id << "] "
<< "does not have same id (" << networkCache[id]->GetNetID()
<< ")" << endl;
EXCEPTION0(ImproperUseException);
}
dob = networkCache[id]->GetPlot()->GetIntermediateDataObject();
debug1 << mName << "Cached network's plot id: "
<< networkCache[id]->GetPlotName()
<< ", selection plot: " << props.GetSource() << endl;
}
if (*dob == NULL)
{
debug1 << "Could not find a valid data set to create a named "
<< "selection from" << endl;
debug1 << mName << "Could not find a valid data set from which to create"
" a named selection." << endl;
EXCEPTION0(NoInputException);
}
......@@ -3883,7 +3891,7 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
if(props.GetVariables().size() != props.GetVariableMins().size() ||
props.GetVariableMins().size() != props.GetVariableMaxs().size())
{
debug1 << "The cumulative query is malformed. It must have the same "
debug1 << mName << "The cumulative query is malformed. It must have the same "
"number of elements for each of the variables, mins, maxs lists."
<< endl;
EXCEPTION0(ImproperUseException);
......@@ -3891,6 +3899,7 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
// For cumulative queries, we need to set up additional processing that
// we can't do within the pipeline library so we do it here.
debug1 << mName << "Creating CQ named selection." << endl;
nsm->CreateNamedSelection(dob, props, &CQ);
// Get the filled out summary from the CQ object.
......@@ -3898,6 +3907,7 @@ NetworkManager::CreateNamedSelection(int id, const SelectionProperties &props)
}
else
{
debug1 << mName << "Creating named selection." << endl;
nsm->CreateNamedSelection(dob, props, NULL);
}
......
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