Commit cbb08446 authored by hrchilds's avatar hrchilds
Browse files

Separate the sequence tracking communication pattern from the avtIntegralCurve base class.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@11598 18c085ea-50e0-402c-830e-de6fd14e8384
parent da71df69
...@@ -92,6 +92,9 @@ class avtICAlgorithm; ...@@ -92,6 +92,9 @@ class avtICAlgorithm;
// Rename all methods and data members to reflect integral curves, not // Rename all methods and data members to reflect integral curves, not
// streamlines. // streamlines.
// //
// Hank Childs, Tue Jun 8 09:11:36 CDT 2010
// Added communication pattern enum and virtual method.
//
// **************************************************************************** // ****************************************************************************
class AVTFILTERS_API avtPICSFilter : class AVTFILTERS_API avtPICSFilter :
...@@ -99,6 +102,13 @@ class AVTFILTERS_API avtPICSFilter : ...@@ -99,6 +102,13 @@ class AVTFILTERS_API avtPICSFilter :
virtual public avtDatasetToDatasetFilter virtual public avtDatasetToDatasetFilter
{ {
public: public:
typedef enum
{
RestoreSequence = 0,
ReturnToOriginatingProcessor,
LeaveOnCurrentProcessor,
UndefinedCommunicationPattern
} CommunicationPattern;
avtPICSFilter(); avtPICSFilter();
virtual ~avtPICSFilter(); virtual ~avtPICSFilter();
...@@ -112,6 +122,7 @@ class AVTFILTERS_API avtPICSFilter : ...@@ -112,6 +122,7 @@ class AVTFILTERS_API avtPICSFilter :
const double& t_start, const double& t_start,
const avtVector &p_start, int ID) = 0; const avtVector &p_start, int ID) = 0;
virtual std::vector<avtVector> GetInitialLocations() = 0; virtual std::vector<avtVector> GetInitialLocations() = 0;
virtual CommunicationPattern GetCommunicationPattern() = 0;
// Methods to set the filter's attributes. // Methods to set the filter's attributes.
void SetMaxStepLength(double len); void SetMaxStepLength(double len);
......
...@@ -41,7 +41,11 @@ ...@@ -41,7 +41,11 @@
// ************************************************************************* // // ************************************************************************* //
#include "avtParICAlgorithm.h" #include "avtParICAlgorithm.h"
#include <avtStateRecorderIntegralCurve.h>
#include <TimingsManager.h> #include <TimingsManager.h>
#include <VisItException.h>
using namespace std; using namespace std;
...@@ -137,17 +141,45 @@ avtParICAlgorithm::InitializeBuffers(vector<avtIntegralCurve *> &seedPts, ...@@ -137,17 +141,45 @@ avtParICAlgorithm::InitializeBuffers(vector<avtIntegralCurve *> &seedPts,
// Method: avtParICAlgorithm::PostRunAlgorithm // Method: avtParICAlgorithm::PostRunAlgorithm
// //
// Purpose: // Purpose:
// Cleanup. // Carry out whatever communication pattern is necessary to get the
// integral curves in their intended location.
// //
// Programmer: Dave Pugmire // Programmer: Dave Pugmire
// Creation: September 24, 2009 // Creation: September 24, 2009
// //
// Modifications:
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Add infrastructure to support new communication patterns.
//
// **************************************************************************** // ****************************************************************************
void void
avtParICAlgorithm::PostRunAlgorithm() avtParICAlgorithm::PostRunAlgorithm()
{ {
ExchangeICSteps(); // We are enumerating the possible communication styles and then just
// calling the correct one. This is an okay solution if there are a small
// number of styles (which there are right now). That said, it would be
// perfectly fine if someone wanted to make this more extensible to handle
// a wide array of communication patterns ... it just didn't seem worth
// the effort when this was implemented.
avtPICSFilter::CommunicationPattern pattern =
picsFilter->GetCommunicationPattern();
if (pattern == avtPICSFilter::RestoreSequence)
RestoreIntegralCurveSequence();
else if (pattern == avtPICSFilter::LeaveOnCurrentProcessor)
;
else if (pattern == avtPICSFilter::ReturnToOriginatingProcessor)
{
EXCEPTION1(VisItException,
"This communication pattern has not been implemented.");
}
else
{
EXCEPTION1(VisItException, "Undefined communication pattern");
}
} }
// **************************************************************************** // ****************************************************************************
...@@ -213,7 +245,7 @@ CountIDs(list<avtIntegralCurve *> &l, int id) ...@@ -213,7 +245,7 @@ CountIDs(list<avtIntegralCurve *> &l, int id)
} }
// **************************************************************************** // ****************************************************************************
// Method: avtParICAlgorithm::ExchangeICSteps // Method: avtParICAlgorithm::RestoreIntegralCurveSequence
// //
// Purpose: // Purpose:
// Communicate streamlines pieces to destinations. // Communicate streamlines pieces to destinations.
...@@ -230,13 +262,17 @@ CountIDs(list<avtIntegralCurve *> &l, int id) ...@@ -230,13 +262,17 @@ CountIDs(list<avtIntegralCurve *> &l, int id)
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010 // Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Use avtStreamlines, not avtStreamlineWrappers. // Use avtStreamlines, not avtStreamlineWrappers.
// //
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Rename method, as we plan to add more communication methods.
//
// **************************************************************************** // ****************************************************************************
void void
avtParICAlgorithm::ExchangeICSteps() avtParICAlgorithm::RestoreIntegralCurveSequence()
{ {
debug5<<"ExchangeICSteps: communicatedICs: "<<communicatedICs.size(); debug5<<"RestoreIntegralCurveSequence: communicatedICs: "
debug5<<" terminatedICs: "<<terminatedICs.size()<<endl; <<communicatedICs.size()
<<" terminatedICs: "<<terminatedICs.size()<<endl;
//Communicate to everyone where the terminators are located. //Communicate to everyone where the terminators are located.
//Do this "N" streamlines at a time, so we don't have a super big buffer. //Do this "N" streamlines at a time, so we don't have a super big buffer.
...@@ -249,8 +285,8 @@ avtParICAlgorithm::ExchangeICSteps() ...@@ -249,8 +285,8 @@ avtParICAlgorithm::ExchangeICSteps()
long *idBuffer = new long[2*N], *myIDs = new long[2*N]; long *idBuffer = new long[2*N], *myIDs = new long[2*N];
//Sort the terminated/communicated ICs by id. //Sort the terminated/communicated ICs by id.
terminatedICs.sort(avtIntegralCurve::IdSeqCompare); terminatedICs.sort(avtStateRecorderIntegralCurve::IdSeqCompare);
communicatedICs.sort(avtIntegralCurve::IdSeqCompare); communicatedICs.sort(avtStateRecorderIntegralCurve::IdSeqCompare);
vector<vector<avtIntegralCurve *> >sendICs(N); vector<vector<avtIntegralCurve *> >sendICs(N);
vector<int> owners(N); vector<int> owners(N);
...@@ -283,7 +319,7 @@ avtParICAlgorithm::ExchangeICSteps() ...@@ -283,7 +319,7 @@ avtParICAlgorithm::ExchangeICSteps()
int idx = (*t)->id % N; int idx = (*t)->id % N;
myIDs[idx] = rank; myIDs[idx] = rank;
myIDs[idx+N] += 1; myIDs[idx+N] += 1;
debug5<<"I own id= "<<(*t)->id<<" "<<(*t)->sequenceCnt<<" idx= "<<idx<<endl; debug5<<"I own id= "<<(*t)->id<<" "<<(((avtStateRecorderIntegralCurve *)*t))->sequenceCnt<<" idx= "<<idx<<endl;
} }
t++; t++;
...@@ -296,7 +332,7 @@ avtParICAlgorithm::ExchangeICSteps() ...@@ -296,7 +332,7 @@ avtParICAlgorithm::ExchangeICSteps()
{ {
int idx = (*c)->id % N; int idx = (*c)->id % N;
myIDs[idx+N] += 1; myIDs[idx+N] += 1;
debug5<<"I have "<<(*c)->id<<" "<<(*c)->sequenceCnt<<" idx= "<<idx<<endl; debug5<<"I have "<<(*c)->id<<" "<<(((avtStateRecorderIntegralCurve *)*c))->sequenceCnt<<" idx= "<<idx<<endl;
} }
c++; c++;
} }
...@@ -324,7 +360,7 @@ avtParICAlgorithm::ExchangeICSteps() ...@@ -324,7 +360,7 @@ avtParICAlgorithm::ExchangeICSteps()
terminatedICs.push_back(s); terminatedICs.push_back(s);
else else
{ {
s->serializeFlags = avtIntegralCurve::SERIALIZE_STEPS; //Write IC steps. ((avtStateRecorderIntegralCurve *)s)->serializeFlags = avtIntegralCurve::SERIALIZE_STEPS; //Write IC steps.
sendICs[idx].push_back(s); sendICs[idx].push_back(s);
owners[idx] = owner; owners[idx] = owner;
} }
...@@ -353,7 +389,7 @@ avtParICAlgorithm::ExchangeICSteps() ...@@ -353,7 +389,7 @@ avtParICAlgorithm::ExchangeICSteps()
RecvICs(terminatedICs); RecvICs(terminatedICs);
//See if we have all the sequences we need. //See if we have all the sequences we need.
terminatedICs.sort(avtIntegralCurve::IdSeqCompare); terminatedICs.sort(avtStateRecorderIntegralCurve::IdSeqCompare);
bool needMore = false; bool needMore = false;
for (int i = 0; i < N && !needMore; i++) for (int i = 0; i < N && !needMore; i++)
if (idBuffer[i] == rank) if (idBuffer[i] == rank)
...@@ -389,13 +425,16 @@ avtParICAlgorithm::ExchangeICSteps() ...@@ -389,13 +425,16 @@ avtParICAlgorithm::ExchangeICSteps()
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010 // Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Use avtStreamlines, not avtStreamlineWrappers. // Use avtStreamlines, not avtStreamlineWrappers.
// //
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Reflect movement of some routines to state recorder IC class.
//
// **************************************************************************** // ****************************************************************************
void void
avtParICAlgorithm::MergeTerminatedICSequences() avtParICAlgorithm::MergeTerminatedICSequences()
{ {
//Sort them by id and sequence so we can process them one at a time. //Sort them by id and sequence so we can process them one at a time.
terminatedICs.sort(avtIntegralCurve::IdSeqCompare); terminatedICs.sort(avtStateRecorderIntegralCurve::IdSeqCompare);
//Split them up into sequences. //Split them up into sequences.
vector<vector<avtIntegralCurve *> > seqs; vector<vector<avtIntegralCurve *> > seqs;
...@@ -422,7 +461,8 @@ avtParICAlgorithm::MergeTerminatedICSequences() ...@@ -422,7 +461,8 @@ avtParICAlgorithm::MergeTerminatedICSequences()
//Merge the sequences together, put them into terminated list. //Merge the sequences together, put them into terminated list.
for (int i = 0; i < seqs.size(); i++) for (int i = 0; i < seqs.size(); i++)
{ {
avtIntegralCurve *s = seqs[i][0]->MergeIntegralCurveSequence(seqs[i]); avtIntegralCurve *s =
avtStateRecorderIntegralCurve::MergeIntegralCurveSequence(seqs[i]);
terminatedICs.push_back(s); terminatedICs.push_back(s);
} }
} }
...@@ -855,17 +895,20 @@ avtParICAlgorithm::RecvMsgs(std::vector<std::vector<int> > &msgs) ...@@ -855,17 +895,20 @@ avtParICAlgorithm::RecvMsgs(std::vector<std::vector<int> > &msgs)
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010 // Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Use avtStreamlines, not avtStreamlineWrappers. // Use avtStreamlines, not avtStreamlineWrappers.
// //
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Use virtual methods to reduce dependence on a specific communication
// pattern.
//
// **************************************************************************** // ****************************************************************************
void void
avtParICAlgorithm::SendICs(int dst, avtParICAlgorithm::SendICs(int dst, vector<avtIntegralCurve*> &ics)
vector<avtIntegralCurve*> &ics)
{ {
for (int i = 0; i < ics.size(); i++) for (int i = 0; i < ics.size(); i++)
{ {
avtIntegralCurve *ic = ics[i]; avtIntegralCurve *ic = ics[i];
ic->serializeFlags |= avtIntegralCurve::SERIALIZE_INC_SEQ; ic->PrepareForSend();
} }
if (DoSendICs(dst, ics)) if (DoSendICs(dst, ics))
...@@ -878,7 +921,7 @@ avtParICAlgorithm::SendICs(int dst, ...@@ -878,7 +921,7 @@ avtParICAlgorithm::SendICs(int dst,
list<avtIntegralCurve*>::const_iterator si = communicatedICs.begin(); list<avtIntegralCurve*>::const_iterator si = communicatedICs.begin();
bool found = false; bool found = false;
for (si = communicatedICs.begin(); !found && si != communicatedICs.end(); si++) for (si = communicatedICs.begin(); !found && si != communicatedICs.end(); si++)
found = ((*si)->id == ic->id && (*si)->sequenceCnt == ic->sequenceCnt); found = (*si)->SameCurve(ic);
if (!found) if (!found)
communicatedICs.push_back(ic); communicatedICs.push_back(ic);
......
...@@ -86,6 +86,9 @@ ...@@ -86,6 +86,9 @@
// Hank Childs, Mon Jun 7 14:57:13 CDT 2010 // Hank Childs, Mon Jun 7 14:57:13 CDT 2010
// Rename Initialize method to be InitializeBuffers to prevent name collision. // Rename Initialize method to be InitializeBuffers to prevent name collision.
// //
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Rename method to make its communication pattern more clear.
//
// **************************************************************************** // ****************************************************************************
class avtParICAlgorithm : public avtICAlgorithm class avtParICAlgorithm : public avtICAlgorithm
...@@ -103,7 +106,7 @@ class avtParICAlgorithm : public avtICAlgorithm ...@@ -103,7 +106,7 @@ class avtParICAlgorithm : public avtICAlgorithm
void InitRequests(); void InitRequests();
void CheckPendingSendRequests(); void CheckPendingSendRequests();
void CleanupAsynchronous(); void CleanupAsynchronous();
void ExchangeICSteps(); void RestoreIntegralCurveSequence();
void PostRecvStatusReq(int idx); void PostRecvStatusReq(int idx);
void PostRecvICReq(int idx); void PostRecvICReq(int idx);
void SendMsg(int dest, std::vector<int> &msg); void SendMsg(int dest, std::vector<int> &msg);
......
...@@ -201,6 +201,9 @@ class vtkAppendPolyData; ...@@ -201,6 +201,9 @@ class vtkAppendPolyData;
// Hank Childs, Sat Jun 5 15:02:43 PDT 2010 // Hank Childs, Sat Jun 5 15:02:43 PDT 2010
// Separated out much of the base infrastructure into the avtPICSFilter. // Separated out much of the base infrastructure into the avtPICSFilter.
// //
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Add method GetCommunicationPattern.
//
// **************************************************************************** // ****************************************************************************
class AVTFILTERS_API avtStreamlineFilter : virtual public avtPICSFilter class AVTFILTERS_API avtStreamlineFilter : virtual public avtPICSFilter
...@@ -268,6 +271,8 @@ class AVTFILTERS_API avtStreamlineFilter : virtual public avtPICSFilter ...@@ -268,6 +271,8 @@ class AVTFILTERS_API avtStreamlineFilter : virtual public avtPICSFilter
void GenerateSeedPointsFromPointList(std::vector<avtVector> &pts); void GenerateSeedPointsFromPointList(std::vector<avtVector> &pts);
virtual std::vector<avtVector> GetInitialLocations(void); virtual std::vector<avtVector> GetInitialLocations(void);
virtual CommunicationPattern GetCommunicationPattern(void)
{ return RestoreSequence; };
}; };
......
...@@ -101,6 +101,7 @@ avtIntegralCurve::avtIntegralCurve(const avtIVPSolver* model, ...@@ -101,6 +101,7 @@ avtIntegralCurve::avtIntegralCurve(const avtIVPSolver* model,
status = STATUS_UNSET; status = STATUS_UNSET;
domain = -1; domain = -1;
sortKey = 0;
terminated = false; terminated = false;
id = ID; id = ID;
...@@ -108,10 +109,6 @@ avtIntegralCurve::avtIntegralCurve(const avtIVPSolver* model, ...@@ -108,10 +109,6 @@ avtIntegralCurve::avtIntegralCurve(const avtIVPSolver* model,
terminationType = avtIVPSolver::TIME; terminationType = avtIVPSolver::TIME;
lastStepValid = false; lastStepValid = false;
sequenceCnt = 0;
sortKey = 0;
serializeFlags = 0;
} }
...@@ -147,6 +144,7 @@ avtIntegralCurve::avtIntegralCurve() ...@@ -147,6 +144,7 @@ avtIntegralCurve::avtIntegralCurve()
status = STATUS_UNSET; status = STATUS_UNSET;
domain = -1; domain = -1;
sortKey = 0;
terminated = false; terminated = false;
id = -1; id = -1;
...@@ -154,11 +152,6 @@ avtIntegralCurve::avtIntegralCurve() ...@@ -154,11 +152,6 @@ avtIntegralCurve::avtIntegralCurve()
terminationType = avtIVPSolver::TIME; terminationType = avtIVPSolver::TIME;
lastStepValid = false; lastStepValid = false;
sequenceCnt = 0;
sortKey = 0;
serializeFlags = 0;
} }
...@@ -593,6 +586,10 @@ avtIntegralCurve::CurrentLocation(avtVector &end) ...@@ -593,6 +586,10 @@ avtIntegralCurve::CurrentLocation(avtVector &end)
// Separate out portions related to Streamline and Poincare into // Separate out portions related to Streamline and Poincare into
// avtStateRecorderIntegralCurve. // avtStateRecorderIntegralCurve.
// //
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Separate out portions related to sequence tracking into
// avtStateRecorderIntegralCurve.
//
// **************************************************************************** // ****************************************************************************
void void
...@@ -633,68 +630,10 @@ avtIntegralCurve::Serialize(MemStream::Mode mode, MemStream &buff, ...@@ -633,68 +630,10 @@ avtIntegralCurve::Serialize(MemStream::Mode mode, MemStream &buff,
_ivpSolver->PutState(solverState); _ivpSolver->PutState(solverState);
} }
if ((serializeFlags & SERIALIZE_INC_SEQ) && mode == MemStream::WRITE)
{
long seqCnt = sequenceCnt+1;
buff.io(mode, seqCnt);
}
else
buff.io(mode, sequenceCnt);
if (DebugStream::Level5()) if (DebugStream::Level5())
debug5 << "DONE: avtIntegralCurve::Serialize. sz= "<<buff.buffLen() << endl; debug5 << "DONE: avtIntegralCurve::Serialize. sz= "<<buff.buffLen() << endl;
} }
// ****************************************************************************
// Method: avtIntegralCurve::IdSeqCompare
//
// Purpose:
// Sort streamlines by id, then sequence number.
//
// Programmer: Dave Pugmire
// Creation: September 24, 2009
//
// Modifications:
//
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Move this method from avtStreamlineWrapper.
//
// ****************************************************************************
bool
avtIntegralCurve::IdSeqCompare(const avtIntegralCurve *icA,
const avtIntegralCurve *icB)
{
if (icA->id == icB->id)
return icA->sequenceCnt < icB->sequenceCnt;
return icA->id < icB->id;
}
// ****************************************************************************
// Method: avtIntegralCurve::IdRevSeqCompare
//
// Purpose:
// Sort streamlines by id, then reverse sequence number.
//
// Programmer: Dave Pugmire
// Creation: September 24, 2009
//
// Modifications:
//
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Move this method from avtStreamlineWrapper.
//
// ****************************************************************************
bool
avtIntegralCurve::IdRevSeqCompare(const avtIntegralCurve *icA,
const avtIntegralCurve *icB)
{
if (icA->id == icB->id)
return icA->sequenceCnt > icB->sequenceCnt;
return icA->id < icB->id;
}
bool bool
avtIntegralCurve::DomainCompare(const avtIntegralCurve *icA, avtIntegralCurve::DomainCompare(const avtIntegralCurve *icA,
const avtIntegralCurve *icB) const avtIntegralCurve *icB)
......
...@@ -171,6 +171,9 @@ class IVP_API DomainType ...@@ -171,6 +171,9 @@ class IVP_API DomainType
// Separate out portions specific to Poincare and Streamline into // Separate out portions specific to Poincare and Streamline into
// avtStateRecorderIntegralCurve. // avtStateRecorderIntegralCurve.
// //
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Put sequence tracking code into avtStateRecorderIntegralCurve.
//
// **************************************************************************** // ****************************************************************************
class IVP_API avtIntegralCurve class IVP_API avtIntegralCurve
...@@ -212,17 +215,11 @@ class IVP_API avtIntegralCurve ...@@ -212,17 +215,11 @@ class IVP_API avtIntegralCurve
void Debug() const; void Debug() const;
virtual void Serialize(MemStream::Mode mode, MemStream &buff, virtual void Serialize(MemStream::Mode mode, MemStream &buff,
avtIVPSolver *solver); avtIVPSolver *solver);
virtual void PrepareForSend(void) { ; };
// Could be static ... only virtual to get to the right method. virtual bool SameCurve(avtIntegralCurve *ic)
// (Temporary solution until we build a communicator class.) { return id == ic->id; };
virtual avtIntegralCurve*
MergeIntegralCurveSequence(
std::vector<avtIntegralCurve *> &v) {;};
static bool IdSeqCompare(const avtIntegralCurve *slA,
const avtIntegralCurve *slB);
static bool IdRevSeqCompare(const avtIntegralCurve *slA,
const avtIntegralCurve *slB);
static bool DomainCompare(const avtIntegralCurve *slA, static bool DomainCompare(const avtIntegralCurve *slA,
const avtIntegralCurve *slB); const avtIntegralCurve *slB);
...@@ -253,13 +250,10 @@ class IVP_API avtIntegralCurve ...@@ -253,13 +250,10 @@ class IVP_API avtIntegralCurve
// Helpers needed for figuring out which domain to use next // Helpers needed for figuring out which domain to use next
std::vector<DomainType> seedPtDomainList; std::vector<DomainType> seedPtDomainList;
DomainType domain; DomainType domain;
Status status;
unsigned long serializeFlags;
long sequenceCnt;
long long sortKey; long long sortKey;
Status status;
long id; long id;
protected: protected:
......
...@@ -66,6 +66,9 @@ avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve(const avtIVPSolver* ...@@ -66,6 +66,9 @@ avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve(const avtIVPSolver*
{ {
intersectionsSet = false; intersectionsSet = false;
numIntersections = 0; numIntersections = 0;
sequenceCnt = 0;
serializeFlags = 0;
} }
...@@ -82,6 +85,8 @@ avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve() : ...@@ -82,6 +85,8 @@ avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve() :
{ {
intersectionsSet = false; intersectionsSet = false;
numIntersections = 0; numIntersections = 0;
sequenceCnt = 0;
serializeFlags = 0;
} }
...@@ -345,6 +350,12 @@ avtStateRecorderIntegralCurve::IntersectPlane(const avtVector &p0, const avtVect ...@@ -345,6 +350,12 @@ avtStateRecorderIntegralCurve::IntersectPlane(const avtVector &p0, const avtVect
// Programmer: Hank Childs // Programmer: Hank Childs
// Creation: June 4, 2010 // Creation: June 4, 2010
//