Commit f531fdce authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

sync some fixes

Fix crush - not properly freeing communicators.
parent 406385c8
...@@ -66,7 +66,14 @@ namespace INMOST ...@@ -66,7 +66,14 @@ namespace INMOST
INMOST_DATA_ENUM_TYPE mbeg,mend; INMOST_DATA_ENUM_TYPE mbeg,mend;
int initial_rank; int initial_rank;
#if defined(USE_MPI) #if defined(USE_MPI)
MPI_Comm_dup(m.GetCommunicator(), &comm); if( comm != INMOST_MPI_COMM_WORLD )
{
MPI_Comm_free(&comm);
comm = INMOST_MPI_COMM_WORLD;
}
if( m.GetCommunicator() == INMOST_MPI_COMM_WORLD )
comm = INMOST_MPI_COMM_WORLD;
else MPI_Comm_dup(m.GetCommunicator(), &comm);
MPI_Comm_rank(comm,&rank); MPI_Comm_rank(comm,&rank);
MPI_Comm_size(comm,&size); MPI_Comm_size(comm,&size);
#else #else
...@@ -548,7 +555,9 @@ namespace INMOST ...@@ -548,7 +555,9 @@ namespace INMOST
extended_indexes(other.extended_indexes) extended_indexes(other.extended_indexes)
{ {
#if defined(USE_MPI) #if defined(USE_MPI)
MPI_Comm_dup(other.comm,&comm); if( other.comm == INMOST_MPI_COMM_WORLD )
comm = INMOST_MPI_COMM_WORLD;
else MPI_Comm_dup(other.comm,&comm);
#else #else
comm = other.comm; comm = other.comm;
#endif #endif
...@@ -570,7 +579,9 @@ namespace INMOST ...@@ -570,7 +579,9 @@ namespace INMOST
Solver::OrderInfo & Solver::OrderInfo::operator =(OrderInfo const & other) Solver::OrderInfo & Solver::OrderInfo::operator =(OrderInfo const & other)
{ {
#if defined(USE_MPI) #if defined(USE_MPI)
MPI_Comm_dup(other.comm,&comm); if( other.comm == INMOST_MPI_COMM_WORLD )
comm = INMOST_MPI_COMM_WORLD;
else MPI_Comm_dup(other.comm,&comm);
#else #else
comm = other.comm; comm = other.comm;
#endif #endif
......
...@@ -2042,7 +2042,7 @@ public: ...@@ -2042,7 +2042,7 @@ public:
while (Ui != EOL) while (Ui != EOL)
{ {
//drop values //drop values
if( fabs(temp[Ui])/Smax > std::min(tau2,std::min(tau/NuU,tau/NuL)) * Smax / Snorm) if( fabs(temp[Ui])/Smax > std::max(tau2,std::min(tau/NuU,tau/NuL)) * Smax / Snorm)
//if( fabs(temp[Ui]) > tau * Smax )// Snorm) //if( fabs(temp[Ui]) > tau * Smax )// Snorm)
S_Entries.push_back(Solver::Row::entry(Ui, temp[Ui])); S_Entries.push_back(Solver::Row::entry(Ui, temp[Ui]));
Ui = Ulist[Ui]; Ui = Ulist[Ui];
...@@ -2109,14 +2109,14 @@ public: ...@@ -2109,14 +2109,14 @@ public:
/////////// DENSE FACTORIZATION /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////// DENSE FACTORIZATION ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
tt = Timer(); tt = Timer();
/*
if ((1.0 * nzA / ((wend - wbeg)*(wend - wbeg))) > 0.75 && (1.0*(wend - wbeg)) / (1.0 *(moend - mobeg)) > 0.1) if ((1.0 * nzA / ((wend - wbeg)*(wend - wbeg))) > 0.75 && (1.0*(wend - wbeg)) / (1.0 *(moend - mobeg)) > 0.1)
{ {
std::cout << "Try to sparsify schur complement!!!" << std::endl; std::cout << "Try to sparsify schur complement!!!" << std::endl;
std::cout << "Sparsity: " << 1.0 * nzA / ((wend - wbeg)*(wend - wbeg)) << std::endl; std::cout << "Sparsity: " << 1.0 * nzA / ((wend - wbeg)*(wend - wbeg)) << std::endl;
std::cout << "Schur size: " << wend - wbeg << " total size: " << moend - mobeg << std::endl; std::cout << "Schur size: " << wend - wbeg << " total size: " << moend - mobeg << std::endl;
} }
*/
if ( (wend-wbeg > 0 && wend - wbeg < 64) || (1.0 * nzA / ((wend - wbeg)*(wend - wbeg))) > 0.75) if ( (wend-wbeg > 0 && wend - wbeg < 64) || (1.0 * nzA / ((wend - wbeg)*(wend - wbeg))) > 0.75)
//if ( wend-wbeg > 0 && wend - wbeg < 2 ) //if ( wend-wbeg > 0 && wend - wbeg < 2 )
{ {
...@@ -2133,6 +2133,13 @@ public: ...@@ -2133,6 +2133,13 @@ public:
//Allocate matrix //Allocate matrix
INMOST_DATA_ENUM_TYPE size = wend - wbeg; INMOST_DATA_ENUM_TYPE size = wend - wbeg;
INMOST_DATA_REAL_TYPE * entries = new INMOST_DATA_REAL_TYPE[size*size]; INMOST_DATA_REAL_TYPE * entries = new INMOST_DATA_REAL_TYPE[size*size];
if( entries == NULL )
{
std::cout << __FILE__ << ":" << __LINE__ << " array of size " << size*size << " was not allocated " << std::endl;
throw -1;
}
std::fill(entries, entries + size*size, 0.0); std::fill(entries, entries + size*size, 0.0);
//Fill the matrix //Fill the matrix
for (k = wbeg; k < wend; ++k) for (k = wbeg; k < wend; ++k)
......
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