parallel topology simplification

This commit is contained in:
Joachim Schoeberl 2011-07-14 21:36:19 +00:00
parent c369b13d23
commit 342983ee75
20 changed files with 907 additions and 2020 deletions

View File

@ -61,8 +61,7 @@ namespace netgen
int BASE_INDEX_HASHTABLE :: Position (int bnr, const INDEX & ind) const int BASE_INDEX_HASHTABLE :: Position (int bnr, const INDEX & ind) const
{ {
int i; for (int i = 1; i <= hash.EntrySize (bnr); i++)
for (i = 1; i <= hash.EntrySize (bnr); i++)
if (hash.Get(bnr, i) == ind) if (hash.Get(bnr, i) == ind)
return i; return i;
return 0; return 0;

View File

@ -18,7 +18,7 @@ class BASE_INDEX_HASHTABLE
{ {
protected: protected:
/// keys are stored in this table /// keys are stored in this table
TABLE<INDEX> hash; TABLE<INDEX,1> hash;
public: public:
/// ///
@ -41,7 +41,7 @@ template <class T>
class INDEX_HASHTABLE : private BASE_INDEX_HASHTABLE class INDEX_HASHTABLE : private BASE_INDEX_HASHTABLE
{ {
/// ///
TABLE<T> cont; TABLE<T,1> cont;
public: public:
/// ///
@ -483,7 +483,7 @@ public:
/// ///
int HashValue (const INDEX & ind) const int HashValue (const INDEX & ind) const
{ {
return ind % hash.Size() + 1; return (3*ind) % hash.Size() + 1;
} }
@ -499,6 +499,22 @@ public:
} }
} }
int CalcPositionCosts (const INDEX & ind) const
{
int i = HashValue(ind);
int costs = 1;
while (1)
{
if (hash.Get(i) == ind) return costs;
if (hash.Get(i) == invalid) return costs;
i++;
if (i > hash.Size()) i = 1;
costs++;
}
}
// returns 1, if new postion is created // returns 1, if new postion is created
int PositionCreate (const INDEX & ind, int & apos) int PositionCreate (const INDEX & ind, int & apos)
{ {

View File

@ -37,8 +37,6 @@ namespace netgen
// damit gehen auch echte Konstante ohne Adresse
inline void MyMPI_Send (int i, int dest, int tag) inline void MyMPI_Send (int i, int dest, int tag)
{ {
int hi = i; int hi = i;
@ -114,7 +112,7 @@ namespace netgen
} }
/*
template <class T, int BASE> template <class T, int BASE>
inline void MyMPI_ISend (FlatArray<T, BASE> s, int dest, int tag, MPI_Request & request) inline void MyMPI_ISend (FlatArray<T, BASE> s, int dest, int tag, MPI_Request & request)
{ {
@ -127,44 +125,26 @@ namespace netgen
{ {
MPI_Irecv( &s.First(), s.Size(), MyGetMPIType<T>(), dest, tag, MPI_COMM_WORLD, & request); MPI_Irecv( &s.First(), s.Size(), MyGetMPIType<T>(), dest, tag, MPI_COMM_WORLD, & request);
} }
/*
template <class T, int BASE>
inline void MyMPI_ISendTag (FlatArray<T, BASE> s, int dest, int tag, MPI_Request & request)
{
MPI_Isend( &s.First(), s.Size(), MyGetMPIType<T>(), dest, tag, MPI_COMM_WORLD, & request);
}
template <class T, int BASE>
inline void MyMPI_IRecvTag (FlatArray<T, BASE> s, int dest, int tag, MPI_Request & request)
{
MPI_Irecv( &s.First(), s.Size(), MyGetMPIType<T>(), dest, tag, MPI_COMM_WORLD, & request);
}
*/ */
template <class T, int BASE>
inline MPI_Request MyMPI_ISend (FlatArray<T, BASE> s, int dest, int tag, MPI_Comm comm = MPI_COMM_WORLD)
{
MPI_Request request;
MPI_Isend( &s.First(), s.Size(), MyGetMPIType<T>(), dest, tag, comm, &request);
return request;
}
template <class T, int BASE>
inline MPI_Request MyMPI_IRecv (FlatArray<T, BASE> s, int dest, int tag, MPI_Comm comm = MPI_COMM_WORLD)
{
MPI_Request request;
MPI_Irecv( &s.First(), s.Size(), MyGetMPIType<T>(), dest, tag, comm, &request);
return request;
}
/* /*
template <class T, int BASE>
inline MPI_Request MyMPI_ISend (FlatArray<T, BASE> s, int dest)
{
MPI_Request request;
MPI_Isend( &s.First(), s.Size(), MyGetMPIType<T>(), dest, 1, MPI_COMM_WORLD, &request);
return request;
// MPI_Request_free (&request);
}
template <class T, int BASE>
inline MPI_Request MyMPI_IRecv (FlatArray<T, BASE> s, int dest)
{
MPI_Request request;
MPI_Irecv( &s.First(), s.Size(), MyGetMPIType<T>(), dest, 1, MPI_COMM_WORLD, &request);
return request;
// MPI_Request_free (&request);
}
*/
template <class T, int BASE> template <class T, int BASE>
inline void MyMPI_ISend (FlatArray<T, BASE> s, int dest, int tag) inline void MyMPI_ISend (FlatArray<T, BASE> s, int dest, int tag)
{ {
@ -181,9 +161,21 @@ namespace netgen
MPI_Irecv( &s.First(), s.Size(), MyGetMPIType<T>(), dest, tag, MPI_COMM_WORLD, &request); MPI_Irecv( &s.First(), s.Size(), MyGetMPIType<T>(), dest, tag, MPI_COMM_WORLD, &request);
MPI_Request_free (&request); MPI_Request_free (&request);
} }
*/
inline void MyMPI_SendCmd (const char * cmd)
{
char buf[100];
strcpy (buf, cmd);
MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD);
}
inline string MyMPI_RecvCmd ()
{
char buf[100];
MPI_Bcast (&buf, 100, MPI_CHAR, 0, MPI_COMM_WORLD);
return string(buf);
}
template <class T> template <class T>
inline void MyMPI_Bcast (T & s, MPI_Comm comm = MPI_COMM_WORLD) inline void MyMPI_Bcast (T & s, MPI_Comm comm = MPI_COMM_WORLD)
@ -204,7 +196,6 @@ namespace netgen
inline void MyMPI_Bcast (Array<T, 0> & s, int root, MPI_Comm comm = MPI_COMM_WORLD) inline void MyMPI_Bcast (Array<T, 0> & s, int root, MPI_Comm comm = MPI_COMM_WORLD)
{ {
int id; int id;
// MPI_Comm_rank(MPI_HIGHORDER_COMM, &id);
MPI_Comm_rank(comm, &id); MPI_Comm_rank(comm, &id);
int size = s.Size(); int size = s.Size();
@ -234,6 +225,7 @@ namespace netgen
/*
inline void MyMPI_Send ( int *& s, int len, int dest, int tag) inline void MyMPI_Send ( int *& s, int len, int dest, int tag)
{ {
int hlen = len; int hlen = len;
@ -270,6 +262,7 @@ namespace netgen
s = new double [len]; s = new double [len];
MPI_Recv( s, len, MPI_DOUBLE, src, tag, MPI_COMM_WORLD, &status); MPI_Recv( s, len, MPI_DOUBLE, src, tag, MPI_COMM_WORLD, &status);
} }
*/
#endif // PARALLEL #endif // PARALLEL

View File

@ -32,7 +32,9 @@ namespace netgen
NgProfiler :: ~NgProfiler() NgProfiler :: ~NgProfiler()
{ {
#ifndef PARALLEL
StopTimer (total_timer); StopTimer (total_timer);
#endif
//ofstream prof; //ofstream prof;
//prof.open("ng.prof"); //prof.open("ng.prof");
@ -50,7 +52,7 @@ namespace netgen
sprintf (filename, "netgen.prof"); sprintf (filename, "netgen.prof");
#endif #endif
printf ("write profile to file %s\n", filename); if (id == 0) printf ("write profile to file netgen.prof\n");
FILE *prof = fopen(filename,"w"); FILE *prof = fopen(filename,"w");
Print (prof); Print (prof);
fclose(prof); fclose(prof);

View File

@ -121,6 +121,27 @@ namespace netgen
void BASE_TABLE :: SetEntrySize2 (int i, int newsize, int elsize)
{
linestruct & line = data[i];
if (newsize > line.maxsize)
{
void * p = new char [newsize * elsize];
memcpy (p, line.col, min2 (newsize, line.size) * elsize);
delete [] (char*)line.col;
line.col = p;
}
line.size = newsize;
}
/* /*
void BASE_TABLE :: DecSize (int i) void BASE_TABLE :: DecSize (int i)
{ {

View File

@ -52,8 +52,18 @@ public:
else else
IncSize2 (i, elsize); IncSize2 (i, elsize);
} }
void SetEntrySize (int i, int newsize, int elsize)
{
if (newsize < data[i].maxsize)
data[i].size = newsize;
else
SetEntrySize2 (i, newsize, elsize);
}
/// ///
void IncSize2 (int i, int elsize); void IncSize2 (int i, int elsize);
void SetEntrySize2 (int i, int newsize, int elsize);
// void DecSize (int i); // void DecSize (int i);

View File

@ -27,7 +27,7 @@
static pthread_t meshingthread; static pthread_t meshingthread;
void RunParallel ( void * (*fun)(void *), void * in) void RunParallel ( void * (*fun)(void *), void * in)
{ {
if (netgen::mparam.parthread && (ntasks == 1) ) if (netgen::mparam.parthread) // && (ntasks == 1) )
{ {
pthread_attr_t attr; pthread_attr_t attr;
pthread_attr_init (&attr); pthread_attr_init (&attr);
@ -70,7 +70,12 @@
static pthread_t meshingthread; static pthread_t meshingthread;
void RunParallel ( void * (*fun)(void *), void * in) void RunParallel ( void * (*fun)(void *), void * in)
{ {
if (netgen::mparam.parthread && (netgen::ntasks == 1)) bool parthread = netgen::mparam.parthread;
if (netgen::id > 0) parthread = true;
// if (netgen::ntasks > 1) parthread = false;
if (parthread)
{ {
pthread_attr_t attr; pthread_attr_t attr;
pthread_attr_init (&attr); pthread_attr_init (&attr);
@ -926,45 +931,60 @@ void Ng_GetSurfaceElementNeighbouringDomains(const int selnr, int & in, int & ou
// Is Element ei an element of this processor ?? // Is Element ei an element of this processor ??
bool Ng_IsGhostEl (int ei) bool Ng_IsGhostEl (int ei)
{ {
return false;
/*
if ( mesh->GetDimension() == 3 ) if ( mesh->GetDimension() == 3 )
return mesh->VolumeElement(ei).IsGhost(); return mesh->VolumeElement(ei).IsGhost();
else else
return false; return false;
*/
} }
void Ng_SetGhostEl(const int ei, const bool aisghost ) void Ng_SetGhostEl(const int ei, const bool aisghost )
{ {
;
/*
if ( mesh -> GetDimension () == 3 ) if ( mesh -> GetDimension () == 3 )
mesh -> VolumeElement(ei).SetGhost (aisghost); mesh -> VolumeElement(ei).SetGhost (aisghost);
*/
} }
bool Ng_IsGhostSEl (int ei) bool Ng_IsGhostSEl (int ei)
{ {
return false;
/*
if ( mesh -> GetDimension () == 3 ) if ( mesh -> GetDimension () == 3 )
return mesh->SurfaceElement(ei).IsGhost(); return mesh->SurfaceElement(ei).IsGhost();
else else
return false; return false;
*/
} }
void Ng_SetGhostSEl(const int ei, const bool aisghost ) void Ng_SetGhostSEl(const int ei, const bool aisghost )
{ {
;
/*
if ( mesh -> GetDimension () == 3 ) if ( mesh -> GetDimension () == 3 )
mesh -> SurfaceElement(ei).SetGhost (aisghost); mesh -> SurfaceElement(ei).SetGhost (aisghost);
*/
} }
bool Ng_IsGhostVert ( int pnum ) bool Ng_IsGhostVert ( int pnum )
{ {
return mesh -> Point ( pnum ).IsGhost() ; return false;
// return mesh -> Point ( pnum ).IsGhost() ;
} }
bool Ng_IsGhostEdge ( int ednum ) bool Ng_IsGhostEdge ( int ednum )
{ {
return mesh -> GetParallelTopology() . IsGhostEdge ( ednum ); return false;
// return mesh -> GetParallelTopology() . IsGhostEdge ( ednum );
} }
bool Ng_IsGhostFace ( int fanum ) bool Ng_IsGhostFace ( int fanum )
{ {
return mesh -> GetParallelTopology() . IsGhostFace ( fanum ); return false;
// return mesh -> GetParallelTopology() . IsGhostFace ( fanum );
} }
// void Ng_SetGhostVert ( const int pnum, const bool aisghost ); // void Ng_SetGhostVert ( const int pnum, const bool aisghost );
@ -979,10 +999,15 @@ bool Ng_IsExchangeSEl ( int selnum )
{ return mesh -> GetParallelTopology() . IsExchangeSEl ( selnum ); } { return mesh -> GetParallelTopology() . IsExchangeSEl ( selnum ); }
void Ng_UpdateOverlap() void Ng_UpdateOverlap()
{ mesh->UpdateOverlap(); } {
; // mesh->UpdateOverlap();
}
int Ng_Overlap () int Ng_Overlap ()
{ return mesh->GetParallelTopology() . Overlap(); } {
return 0;
// return mesh->GetParallelTopology() . Overlap();
}
#endif #endif

View File

@ -27,7 +27,7 @@ namespace netgen
if (!hasedges || !hasfaces) return; if (!hasedges || !hasfaces) return;
if (id == 0)
PrintMessage (3, "Update Clusters"); PrintMessage (3, "Update Clusters");
nv = mesh.GetNV(); nv = mesh.GetNV();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
namespace netgen namespace netgen
{ {
extern int ntasks; // extern int ntasks;
class ParallelMeshTopology class ParallelMeshTopology
{ {
@ -27,15 +27,10 @@ namespace netgen
each row contains a list of pairs (procnr, dist_vnum) each row contains a list of pairs (procnr, dist_vnum)
*/ */
TABLE<int,PointIndex::BASE> loc2distvert; TABLE<int,PointIndex::BASE> loc2distvert;
TABLE<int,0> loc2distedge, loc2distface, loc2distel; TABLE<int,0> loc2distedge, loc2distface;
TABLE<int,0> loc2distsegm, loc2distsurfel; TABLE<int,0> loc2distel, loc2distsegm, loc2distsurfel;
BitArray * isexchangeface, * isexchangevert, * isexchangeedge, * isexchangeel;
BitArray isghostedge, isghostface;
bool coarseupdate; bool coarseupdate;
int overlap;
public: public:
@ -43,10 +38,17 @@ namespace netgen
~ParallelMeshTopology (); ~ParallelMeshTopology ();
/// set number of local vertices, reset sizes of loc2dist_vert, isexchangevert... /// set number of local vertices, reset sizes of loc2dist_vert, isexchangevert...
void SetNV ( int anv ); void SetNV (int anv);
void SetNE ( int ane ); void SetNE (int ane);
void SetNSE ( int anse ); void SetNSE (int anse);
void SetNSegm ( int anseg ); void SetNSegm (int anseg);
void SetNVGlob ( int anvglob ) { nvglob = anvglob; }
void SetNEGlob ( int aneglob ) { neglob = aneglob; }
int GetNVGlob () { return nvglob; }
int GetNEGlob () { return neglob; }
void Reset (); void Reset ();
@ -65,10 +67,17 @@ namespace netgen
int Glob2Loc_Segm ( int globnum ); int Glob2Loc_Segm ( int globnum );
int Glob2Loc_Vert ( int globnum ); int Glob2Loc_Vert ( int globnum );
int GetNDistantPNums ( int locpnum ) const { return loc2distvert[locpnum].Size() / 2 + 1; } int GetNDistantPNums ( int locpnum ) const
int GetNDistantFaceNums ( int locfacenum ) const { return loc2distface[locfacenum-1].Size() / 2 + 1; } { return loc2distvert[locpnum].Size() / 2 + 1; }
int GetNDistantEdgeNums ( int locedgenum ) const { return loc2distedge[locedgenum-1].Size() / 2 + 1; }
int GetNDistantElNums ( int locelnum ) const { return loc2distel[locelnum-1].Size() / 2 + 1; } int GetNDistantFaceNums ( int locfacenum ) const
{ return loc2distface[locfacenum-1].Size() / 2 + 1; }
int GetNDistantEdgeNums ( int locedgenum ) const
{ return loc2distedge[locedgenum-1].Size() / 2 + 1; }
int GetNDistantElNums ( int locelnum ) const
{ return loc2distel[locelnum-1].Size() / 2 + 1; }
int GetDistantPNum ( int proc, int locpnum ) const; int GetDistantPNum ( int proc, int locpnum ) const;
int GetDistantEdgeNum ( int proc, int locedgenum ) const; int GetDistantEdgeNum ( int proc, int locedgenum ) const;
@ -81,60 +90,23 @@ namespace netgen
int GetDistantElNums ( int locelnum, int * distfacenums ) const; int GetDistantElNums ( int locelnum, int * distfacenums ) const;
void Print() const; void Print() const;
void SetExchangeFace ( int fnr ) { isexchangeface->Set( (fnr-1)*(ntasks+1) ); }
void SetExchangeVert ( int vnum ) { isexchangevert->Set( (vnum-1)*(ntasks+1) ); }
void SetExchangeElement ( int elnum ) { isexchangeel->Set((elnum-1)*(ntasks+1) ); }
void SetExchangeEdge ( int ednum ) { isexchangeedge->Set ((ednum-1)*(ntasks+1)); }
// fuer diese Fkts kann man ja O(N) - bitarrays lassen
bool IsExchangeVert ( PointIndex vnum ) const
{
return loc2distvert[vnum].Size() > 1;
// return isexchangevert->Test((vnum-1)*(ntasks+1));
}
bool IsExchangeEdge ( int ednum ) const
{
/* /*
if ( isexchangeedge->Test( (ednum-1)*(ntasks+1) ) != void SetExchangeFace ( int fnr ) {}; // { isexchangeface->Set( (fnr-1)*(ntasks+1) ); }
( loc2distedge[ednum-1].Size() > 1) ) void SetExchangeVert ( int vnum ) {}; // { isexchangevert->Set( (vnum-1)*(ntasks+1) ); }
{ void SetExchangeElement ( int elnum ) {}; // { isexchangeel->Set((elnum-1)*(ntasks+1) ); }
cerr << "isexedge differs, id = " << id << ", ednum = " << ednum << endl; void SetExchangeEdge ( int ednum ) {}; // { isexchangeedge->Set ((ednum-1)*(ntasks+1)); }
}
*/ */
// return loc2distedge[ednum-1].Size() > 1;
int i = (ednum-1)*(ntasks+1);
return isexchangeedge->Test(i);
}
bool IsExchangeFace ( int fnum ) const bool IsExchangeVert ( PointIndex vnum ) const { return loc2distvert[vnum].Size() > 1; }
{ bool IsExchangeEdge ( int ednum ) const { return loc2distedge[ednum-1].Size() > 1; }
bool IsExchangeFace ( int fnum ) const { return loc2distface[fnum-1].Size() > 1; }
bool IsExchangeElement ( int elnum ) const { return false; }
bool IsExchangeSEl ( int selnum ) const { return loc2distsurfel[selnum-1].Size() > 1; }
/* /*
if ( isexchangeface->Test( (fnum-1)*(ntasks+1) ) !=
( loc2distface[fnum-1].Size() > 1) )
{
cerr << "it differs, id = " << id << ", fnum = " << fnum << endl;
}
*/
// nur hier funktioniert's so nicht ???? (JS)
// return loc2distface[fnum-1].Size() > 1;
return isexchangeface->Test( (fnum-1)*(ntasks+1) );
}
bool IsExchangeElement ( int elnum ) const
{
// return loc2distel[elnum-1].Size() > 1;
return isexchangeel->Test((elnum-1)*(ntasks+1));
}
bool IsExchangeSEl ( int selnum ) const
{
return loc2distsurfel[selnum-1].Size() > 1;
}
void SetExchangeFace (int dest, int fnr ) void SetExchangeFace (int dest, int fnr )
{ {
// isexchangeface->Set((fnr-1)*(ntasks+1) + (dest+1)); // isexchangeface->Set((fnr-1)*(ntasks+1) + (dest+1));
@ -147,13 +119,14 @@ namespace netgen
void SetExchangeElement (int dest, int vnum ) void SetExchangeElement (int dest, int vnum )
{ {
isexchangeel->Set( (vnum-1)*(ntasks+1) + (dest+1) ); ; // isexchangeel->Set( (vnum-1)*(ntasks+1) + (dest+1) );
} }
void SetExchangeEdge (int dest, int ednum ) void SetExchangeEdge (int dest, int ednum )
{ {
// isexchangeedge->Set ( (ednum-1)*(ntasks+1) + (dest+1) ); // isexchangeedge->Set ( (ednum-1)*(ntasks+1) + (dest+1) );
} }
*/
bool IsExchangeVert (int dest, int vnum ) const bool IsExchangeVert (int dest, int vnum ) const
@ -162,7 +135,6 @@ namespace netgen
for (int i = 1; i < exchange.Size(); i += 2) for (int i = 1; i < exchange.Size(); i += 2)
if (exchange[i] == dest) return true; if (exchange[i] == dest) return true;
return false; return false;
// return isexchangevert->Test((vnum-1)*(ntasks+1) + (dest+1) );
} }
bool IsExchangeEdge (int dest, int ednum ) const bool IsExchangeEdge (int dest, int ednum ) const
@ -171,8 +143,6 @@ namespace netgen
for (int i = 1; i < exchange.Size(); i += 2) for (int i = 1; i < exchange.Size(); i += 2)
if (exchange[i] == dest) return true; if (exchange[i] == dest) return true;
return false; return false;
// return isexchangeedge->Test((ednum-1)*(ntasks+1) + (dest+1));
} }
bool IsExchangeFace (int dest, int fnum ) const bool IsExchangeFace (int dest, int fnum ) const
@ -181,41 +151,20 @@ namespace netgen
for (int i = 1; i < exchange.Size(); i += 2) for (int i = 1; i < exchange.Size(); i += 2)
if (exchange[i] == dest) return true; if (exchange[i] == dest) return true;
return false; return false;
// return isexchangeface->Test((fnum-1)*(ntasks+1) + (dest+1) );
} }
bool IsExchangeElement (int dest, int elnum ) const bool IsExchangeElement (int dest, int elnum ) const { return false; }
{
// das geht auch nicht
/*
FlatArray<int> exchange = loc2distel[elnum-1];
for (int i = 1; i < exchange.Size(); i += 2)
if (exchange[i] == dest) return true;
return false;
*/
return isexchangeel->Test((elnum-1)*(ntasks+1) + (dest+1));
}
int Overlap() const
{ return overlap; }
int IncreaseOverlap ()
{ overlap++; return overlap; }
void Update(); void Update();
void UpdateCoarseGrid(); void UpdateCoarseGrid();
void UpdateCoarseGridOverlap();
void UpdateRefinement (); void UpdateRefinement ();
void UpdateTopology (); void UpdateTopology ();
void UpdateExchangeElements(); void UpdateExchangeElements();
void UpdateCoarseGridGlobal(); void UpdateCoarseGridGlobal();
bool DoCoarseUpdate() const bool DoCoarseUpdate() const { return !coarseupdate; }
{ return !coarseupdate; }
void SetDistantFaceNum ( int dest, int locnum, int distnum ); void SetDistantFaceNum ( int dest, int locnum, int distnum );
void SetDistantPNum ( int dest, int locnum, int distnum ); void SetDistantPNum ( int dest, int locnum, int distnum );
@ -225,40 +174,8 @@ namespace netgen
void SetDistantSegm ( int dest, int locnum, int distnum ); void SetDistantSegm ( int dest, int locnum, int distnum );
bool IsGhostEl ( int elnum ) const { return mesh.VolumeElement(elnum).IsGhost(); } bool IsGhostEl ( int elnum ) const { return mesh.VolumeElement(elnum).IsGhost(); }
bool IsGhostFace ( int fanum ) const { return isghostface.Test(fanum-1); }
bool IsGhostEdge ( int ednum ) const { return isghostedge.Test(ednum-1); }
bool IsGhostVert ( int pnum ) const { return mesh.Point(pnum).IsGhost(); }
// inline void SetGhostVert ( const int pnum )
// { isghostvert.Set(pnum-1); }
void SetGhostEdge ( int ednum )
{ isghostedge.Set(ednum-1); }
void ClearGhostEdge ( int ednum )
{ isghostedge.Clear(ednum-1); }
void SetGhostFace ( int fanum )
{ isghostface.Set(fanum-1); }
void ClearGhostFace ( int fanum )
{ isghostface.Clear(fanum-1); }
bool IsElementInPartition ( int elnum, int dest ) const
{
return IsExchangeElement ( dest, elnum);
}
void SetElementInPartition ( int elnum, int dest )
{
SetExchangeElement ( dest, elnum );
}
void SetNVGlob ( int anvglob ) { nvglob = anvglob; }
void SetNEGlob ( int aneglob ) { neglob = aneglob; }
int GetNVGlob () { return nvglob; }
int GetNEGlob () { return neglob; }
}; };

View File

@ -89,6 +89,7 @@ namespace netgen
int nfa = 0; int nfa = 0;
int ned = edge2vert.Size(); int ned = edge2vert.Size();
if (id == 0)
PrintMessage (3, "Update mesh topology"); PrintMessage (3, "Update mesh topology");
(*testout) << " UPDATE MESH TOPOLOGY " << endl; (*testout) << " UPDATE MESH TOPOLOGY " << endl;
@ -167,6 +168,7 @@ namespace netgen
static int timer1 = NgProfiler::CreateTimer ("topology::buildedges"); static int timer1 = NgProfiler::CreateTimer ("topology::buildedges");
NgProfiler::RegionTimer reg1 (timer1); NgProfiler::RegionTimer reg1 (timer1);
if (id == 0)
PrintMessage (5, "Update edges "); PrintMessage (5, "Update edges ");
edges.SetSize(ne); edges.SetSize(ne);
@ -499,6 +501,7 @@ namespace netgen
static int timer2 = NgProfiler::CreateTimer ("topology::buildfaces"); static int timer2 = NgProfiler::CreateTimer ("topology::buildfaces");
NgProfiler::RegionTimer reg2 (timer2); NgProfiler::RegionTimer reg2 (timer2);
if (id == 0)
PrintMessage (5, "Update faces "); PrintMessage (5, "Update faces ");
@ -1011,7 +1014,7 @@ namespace netgen
// *testout << "faces = " << face2vert << endl; // *testout << "faces = " << face2vert << endl;
if (pass == 1) if (pass == 1)
{ {
*testout << "sort from " << first_fa << " to " << nfa << endl; // *testout << "sort from " << first_fa << " to " << nfa << endl;
for (int i = first_fa; i < nfa; i++) for (int i = first_fa; i < nfa; i++)
for (int j = first_fa+1; j < nfa; j++) for (int j = first_fa+1; j < nfa; j++)
if (face2vert[j] < face2vert[j-1]) if (face2vert[j] < face2vert[j-1])
@ -1026,7 +1029,7 @@ namespace netgen
} }
*testout << "face2vert = " << endl << face2vert << endl; // *testout << "face2vert = " << endl << face2vert << endl;
@ -1125,6 +1128,8 @@ namespace netgen
// if ( !paralleltop.IsExchangeFace (i+1) ) // if ( !paralleltop.IsExchangeFace (i+1) )
// paralleltop.SetRefinementFace (i+1); // paralleltop.SetRefinementFace (i+1);
/*
paralleltop.SetExchangeFace (i+1); paralleltop.SetExchangeFace (i+1);
for (int j = 0; j < 4; j++) for (int j = 0; j < 4; j++)
@ -1141,6 +1146,7 @@ namespace netgen
int v1, v2; int v1, v2;
GetEdgeVertices(faceedges[j], v1, v2 ); GetEdgeVertices(faceedges[j], v1, v2 );
} }
*/
/* /*
(*testout) << "pos = "; (*testout) << "pos = ";

View File

@ -765,25 +765,15 @@ namespace netgen
cout << "extensionstring = " << glXQueryExtensionsString( dpy, 0 ) << endl; cout << "extensionstring = " << glXQueryExtensionsString( dpy, 0 ) << endl;
*/ */
MyMPI_SendCmd ("redraw");
MyMPI_SendCmd ("init");
Array<MPI_Request> request(ntasks);
MPI_Status status;
for (int dest = 1; dest < ntasks; dest++) for (int dest = 1; dest < ntasks; dest++)
{ {
cout << "Initparallelgl, send to " << dest << endl;
MyMPI_Send ("redraw", dest, MPI_TAG_CMD);
MyMPI_Send ("init", dest, MPI_TAG_VIS);
MyMPI_Send (displname, dest, MPI_TAG_VIS); MyMPI_Send (displname, dest, MPI_TAG_VIS);
MyMPI_Send (int (drawable), dest, MPI_TAG_VIS); MyMPI_Send (int (drawable), dest, MPI_TAG_VIS);
MyMPI_Send (int (xid), dest, MPI_TAG_VIS); MyMPI_Send (int (xid), dest, MPI_TAG_VIS);
int hi;
MPI_Irecv( &hi, 1, MPI_INT, dest, MPI_TAG_VIS, MPI_COMM_WORLD, &request[dest]);
// MyMPI_IRecv (hi, dest, request[dest]);
} }
for ( int dest = 1; dest < ntasks; dest++ )
MPI_Wait(&request[dest], &status);
} }
} }
} }
@ -795,11 +785,16 @@ namespace netgen
if (id == 0) if (id == 0)
{ {
/*
for (int dest = 1; dest < ntasks; dest++) for (int dest = 1; dest < ntasks; dest++)
{ {
MyMPI_Send ("redraw", dest, MPI_TAG_CMD); MyMPI_Send ("redraw", dest, MPI_TAG_CMD);
MyMPI_Send ("broadcast", dest, MPI_TAG_VIS); MyMPI_Send ("broadcast", dest, MPI_TAG_VIS);
} }
*/
MyMPI_SendCmd ("redraw");
MyMPI_SendCmd ("broadcast");
} }
MyMPI_Bcast (selface); MyMPI_Bcast (selface);

View File

@ -893,7 +893,7 @@ namespace netgen
NgProfiler::RegionTimer reg (timer); NgProfiler::RegionTimer reg (timer);
#ifdef PARALLELGL #ifdef PARALLELGL
cout << "buildfillelist, id = " << id << ", nse = " << mesh -> GetNSE() << endl; // cout << "buildfillelist, id = " << id << ", nse = " << mesh -> GetNSE() << endl;
if (id == 0 && ntasks > 1) if (id == 0 && ntasks > 1)
{ {
@ -901,11 +901,16 @@ namespace netgen
par_filledlists.SetSize (ntasks); par_filledlists.SetSize (ntasks);
/*
for ( int dest = 1; dest < ntasks; dest++ ) for ( int dest = 1; dest < ntasks; dest++ )
{ {
MyMPI_Send ("redraw", dest, MPI_TAG_CMD); MyMPI_Send ("redraw", dest, MPI_TAG_CMD);
MyMPI_Send ("filledlist", dest, MPI_TAG_VIS); // MyMPI_Send ("filledlist", dest, MPI_TAG_VIS);
} }
*/
MyMPI_SendCmd ("redraw");
MyMPI_SendCmd ("filledlist");
for ( int dest = 1; dest < ntasks; dest++ ) for ( int dest = 1; dest < ntasks; dest++ )
{ {
MyMPI_Recv (par_filledlists[dest], dest, MPI_TAG_VIS); MyMPI_Recv (par_filledlists[dest], dest, MPI_TAG_VIS);
@ -1344,11 +1349,16 @@ namespace netgen
par_linelists.SetSize (ntasks); par_linelists.SetSize (ntasks);
/*
for ( int dest = 1; dest < ntasks; dest++ ) for ( int dest = 1; dest < ntasks; dest++ )
{ {
MyMPI_Send ("redraw", dest, MPI_TAG_CMD); MyMPI_Send ("redraw", dest, MPI_TAG_CMD);
MyMPI_Send ("linelist", dest, MPI_TAG_VIS); MyMPI_Send ("linelist", dest, MPI_TAG_VIS);
} }
*/
MyMPI_SendCmd ("redraw");
MyMPI_SendCmd ("linelist");
for ( int dest = 1; dest < ntasks; dest++ ) for ( int dest = 1; dest < ntasks; dest++ )
MyMPI_Recv (par_linelists[dest], dest, MPI_TAG_VIS); MyMPI_Recv (par_linelists[dest], dest, MPI_TAG_VIS);

View File

@ -994,11 +994,16 @@ namespace netgen
par_surfellists.SetSize (ntasks); par_surfellists.SetSize (ntasks);
/*
for ( int dest = 1; dest < ntasks; dest++ ) for ( int dest = 1; dest < ntasks; dest++ )
{ {
MyMPI_Send ("redraw", dest, MPI_TAG_CMD); MyMPI_Send ("redraw", dest, MPI_TAG_CMD);
MyMPI_Send ("solsurfellist", dest, MPI_TAG_VIS); MyMPI_Send ("solsurfellist", dest, MPI_TAG_VIS);
} }
*/
MyMPI_SendCmd ("redraw");
MyMPI_SendCmd ("solsurfellist");
for ( int dest = 1; dest < ntasks; dest++ ) for ( int dest = 1; dest < ntasks; dest++ )
MyMPI_Recv (par_surfellists[dest], dest, MPI_TAG_VIS); MyMPI_Recv (par_surfellists[dest], dest, MPI_TAG_VIS);
@ -3706,11 +3711,16 @@ namespace netgen
Array<int> parlists (ntasks); Array<int> parlists (ntasks);
/*
for ( int dest = 1; dest < ntasks; dest++ ) for ( int dest = 1; dest < ntasks; dest++ )
{ {
MyMPI_Send ("redraw", dest, MPI_TAG_CMD); MyMPI_Send ("redraw", dest, MPI_TAG_CMD);
MyMPI_Send ("clipplanetrigs", dest, MPI_TAG_VIS); MyMPI_Send ("clipplanetrigs", dest, MPI_TAG_VIS);
} }
*/
MyMPI_SendCmd ("redraw");
MyMPI_SendCmd ("clipplanetrigs");
for ( int dest = 1; dest < ntasks; dest++ ) for ( int dest = 1; dest < ntasks; dest++ )
MyMPI_Recv (parlists[dest], dest, MPI_TAG_VIS); MyMPI_Recv (parlists[dest], dest, MPI_TAG_VIS);
@ -4086,6 +4096,47 @@ namespace netgen
void VisualSceneSolution :: Broadcast () void VisualSceneSolution :: Broadcast ()
{ {
MPI_Datatype type;
int blocklen[] =
{
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
4
};
MPI_Aint displ[] = { (char*)&usetexture - (char*)this,
(char*)&clipsolution - (char*)this,
(char*)&scalfunction - (char*)this,
(char*)&scalcomp - (char*)this,
(char*)&vecfunction - (char*)this,
(char*)&gridsize - (char*)this,
(char*)&autoscale - (char*)this,
(char*)&logscale - (char*)this,
(char*)&minval - (char*)this,
(char*)&maxval - (char*)this,
(char*)&numisolines - (char*)this,
(char*)&subdivisions - (char*)this,
(char*)&clipplane[0] - (char*)this };
MPI_Datatype types[] = {
MPI_INT, MPI_INT, MPI_INT, MPI_INT,
MPI_INT, MPI_INT, MPI_INT, MPI_INT,
MPI_DOUBLE, MPI_DOUBLE, MPI_INT, MPI_INT,
MPI_DOUBLE
};
MPI_Type_create_struct (13, blocklen, displ, types, &type);
MPI_Type_commit ( &type );
MPI_Bcast (this, 1, type, 0, MPI_COMM_WORLD);
MPI_Type_free (&type);
/*
MyMPI_Bcast (usetexture); MyMPI_Bcast (usetexture);
MyMPI_Bcast (clipsolution); MyMPI_Bcast (clipsolution);
MyMPI_Bcast (scalfunction); MyMPI_Bcast (scalfunction);
@ -4104,6 +4155,7 @@ namespace netgen
MyMPI_Bcast (clipplane[1]); MyMPI_Bcast (clipplane[1]);
MyMPI_Bcast (clipplane[2]); MyMPI_Bcast (clipplane[2]);
MyMPI_Bcast (clipplane[3]); MyMPI_Bcast (clipplane[3]);
*/
} }
#endif #endif

View File

@ -68,6 +68,7 @@ if { $batchmode != "defined" } {
source ${ngdir}/variables.tcl source ${ngdir}/variables.tcl
source ${ngdir}/parameters.tcl source ${ngdir}/parameters.tcl
if { $batchmode != "defined" } { if { $batchmode != "defined" } {
catch { catch {
source ${ngdir}/menustat.tcl source ${ngdir}/menustat.tcl
@ -83,7 +84,6 @@ catch {
} }
if { [catch { load libgeom2dvis[info sharedlibextension] Ng_Geom2d } result ] } { if { [catch { load libgeom2dvis[info sharedlibextension] Ng_Geom2d } result ] } {
puts "cannot load 2d meshing module" puts "cannot load 2d meshing module"
puts "error: $result" puts "error: $result"

View File

@ -63,12 +63,17 @@ int main(int argc, char ** argv)
{ {
#ifdef PARALLEL #ifdef PARALLEL
// MPI_Init(&argc, &argv);
int required = MPI_THREAD_MULTIPLE; int required = MPI_THREAD_MULTIPLE;
int provided; int provided;
MPI_Init_thread(&argc, &argv, required, &provided); MPI_Init_thread(&argc, &argv, required, &provided);
cout << "requ = " << required << ", provided = " << provided << endl;
MPI_Comm_size(MPI_COMM_WORLD, &netgen::ntasks); MPI_Comm_size(MPI_COMM_WORLD, &netgen::ntasks);
MPI_Comm_rank(MPI_COMM_WORLD, &netgen::id); MPI_Comm_rank(MPI_COMM_WORLD, &netgen::id);
if (netgen::id == 0 && provided == MPI_THREAD_MULTIPLE)
cout << "multithreaded mpi is supported" << endl;
#endif #endif

View File

@ -2997,8 +2997,7 @@ void PlayAnimFile(const char* name, int speed, int maxcnt)
#endif #endif
#ifdef PARALLEL #ifdef PARALLEL
for ( int dest = 1; dest < ntasks; dest++) MyMPI_SendCmd ("end");
MyMPI_Send ( "end", dest, MPI_TAG_CMD );
#endif #endif
mesh.Reset (NULL); mesh.Reset (NULL);

View File

@ -102,8 +102,8 @@ void ParallelRun()
bool test = true; bool test = true;
testout = new ostream(0); // testout = new ostream(0);
// new ofstream (string("testout_proc") + id ); testout = new ofstream (string("testout_proc") + id );
while ( test ) while ( test )
{ {
@ -111,7 +111,8 @@ void ParallelRun()
#pragma pomp inst begin (message) #pragma pomp inst begin (message)
#endif #endif
MyMPI_Recv ( message, 0, MPI_TAG_CMD ); // MyMPI_Recv ( message, 0, MPI_TAG_CMD );
message = MyMPI_RecvCmd();
#ifdef SCALASCA #ifdef SCALASCA
#pragma pomp inst end (message) #pragma pomp inst end (message)
@ -224,7 +225,8 @@ void ParallelRun()
// did not manage to get glXImportContextEXT working on Laptop (JS) // did not manage to get glXImportContextEXT working on Laptop (JS)
string redraw_cmd; string redraw_cmd;
MyMPI_Recv (redraw_cmd, 0, MPI_TAG_VIS); // MyMPI_Recv (redraw_cmd, 0, MPI_TAG_VIS);
redraw_cmd = MyMPI_RecvCmd();
// PrintMessage (1, "Redraw - ", redraw_cmd); // PrintMessage (1, "Redraw - ", redraw_cmd);
@ -351,8 +353,6 @@ void ParallelRun()
#endif #endif
// PrintMessage (1, "redraw - init complete"); // PrintMessage (1, "redraw - init complete");
int hi = id;
MyMPI_Send (hi, 0, MPI_TAG_VIS);
} }
if (redraw_cmd == "broadcast") if (redraw_cmd == "broadcast")

View File

@ -138,13 +138,14 @@ namespace netgen
mesh -> GetParallelTopology().Print (); mesh -> GetParallelTopology().Print ();
} }
/*
bool NgPar_IsElementInPartition ( const int elnum, const int dest ) bool NgPar_IsElementInPartition ( const int elnum, const int dest )
{ {
return mesh -> GetParallelTopology().IsElementInPartition ( elnum+1, dest ); return mesh -> GetParallelTopology().IsElementInPartition ( elnum+1, dest );
} }
bool NgPar_IsGhostFace ( const int facenum ) bool NgPar_IsGhostFace ( const int facenum )
{ {
return mesh -> GetParallelTopology().IsGhostFace ( facenum+1); return mesh -> GetParallelTopology().IsGhostFace ( facenum+1);
@ -154,7 +155,7 @@ namespace netgen
{ {
return mesh -> GetParallelTopology().IsGhostEdge ( edgenum+1); return mesh -> GetParallelTopology().IsGhostEdge ( edgenum+1);
} }
*/
#endif #endif