Commit cc1f5639 authored by Kirill Terekhov's avatar Kirill Terekhov

remove memory pool and pool_array container, as it seems to fail with some compilers

parent 1d18064d
......@@ -18,19 +18,19 @@ namespace INMOST
template<> Demote<variable>::type AbstractEntry::Access<variable> (const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Unknown(e,pos);}
template<> Demote<hessian_variable>::type AbstractEntry::Access<hessian_variable> (const Storage& e, INMOST_DATA_ENUM_TYPE pos) const {return Unknown(e,pos);}
template<>
Matrix<Demote<INMOST_DATA_REAL_TYPE>::type, pool_array_t<Demote<INMOST_DATA_REAL_TYPE>::type> >
Matrix<Demote<INMOST_DATA_REAL_TYPE>::type>
AbstractEntry::Access<INMOST_DATA_REAL_TYPE> (const Storage& e) const {return Value(e);}
template<>
Matrix<Demote<INMOST_DATA_INTEGER_TYPE>::type, pool_array_t<Demote<INMOST_DATA_INTEGER_TYPE>::type> >
Matrix<Demote<INMOST_DATA_INTEGER_TYPE>::type>
AbstractEntry::Access<INMOST_DATA_INTEGER_TYPE>(const Storage& e) const {return Index(e);}
template<>
Matrix<Demote<unknown>::type, pool_array_t<Demote<unknown>::type> >
Matrix<Demote<unknown>::type>
AbstractEntry::Access<unknown>(const Storage& e) const {return Unknown(e);}
template<>
Matrix<Demote<variable>::type, pool_array_t<Demote<variable>::type> >
Matrix<Demote<variable>::type>
AbstractEntry::Access<variable>(const Storage& e) const {return Unknown(e);}
template<>
Matrix<Demote<hessian_variable>::type,pool_array_t<Demote<hessian_variable>::type> >
Matrix<Demote<hessian_variable>::type >
AbstractEntry::Access<hessian_variable>(const Storage& e) const {return Unknown(e);}
......@@ -423,9 +423,9 @@ namespace INMOST
throw Impossible;
}
rpMatrix MultiEntry::Value(const Storage & e) const
rMatrix MultiEntry::Value(const Storage & e) const
{
rpMatrix ret(MatrixSize(e),1);
rMatrix ret(MatrixSize(e),1);
unsigned l = 0, r, t;
for(unsigned k = 0; k < entries.size(); ++k) if( entries[k]->isValid(e) )
{
......@@ -436,9 +436,9 @@ namespace INMOST
return ret;
}
ipMatrix MultiEntry::Index(const Storage & e) const
iMatrix MultiEntry::Index(const Storage & e) const
{
ipMatrix ret(MatrixSize(e),1);
iMatrix ret(MatrixSize(e),1);
unsigned l = 0, r, t;
for(unsigned k = 0; k < entries.size(); ++k) if( entries[k]->isValid(e) )
{
......@@ -449,9 +449,9 @@ namespace INMOST
return ret;
}
upMatrix MultiEntry::operator [](const Storage & e) const
uMatrix MultiEntry::operator [](const Storage & e) const
{
upMatrix ret(MatrixSize(e),1);
uMatrix ret(MatrixSize(e),1);
unsigned l = 0, r, t;
for(unsigned k = 0; k < entries.size(); ++k) if( entries[k]->isValid(e) )
{
......
......@@ -329,7 +329,7 @@ namespace INMOST
Element e;
for(Mesh::iteratorElement jt = m->BeginElement(etype); jt != m->EndElement(); ++jt) if( jt->GetStatus() != Element::Ghost )
{
rpMatrix err = R.Value(it->second->Index(jt->self()));
rMatrix err = R.Value(it->second->Index(jt->self()));
double block_err = err.FrobeniusNorm();
if( block_err > max_err )
{
......
......@@ -110,9 +110,9 @@ namespace INMOST
return ret;
}
rpMatrix Residual::Value(const AbstractMatrix<INMOST_DATA_INTEGER_TYPE> & rows) const
rMatrix Residual::Value(const AbstractMatrix<INMOST_DATA_INTEGER_TYPE> & rows) const
{
rpMatrix ret(rows.Rows(),rows.Cols());
rMatrix ret(rows.Rows(),rows.Cols());
for(INMOST_DATA_ENUM_TYPE i = 0; i < rows.Rows(); ++i)
for(INMOST_DATA_ENUM_TYPE j = 0; j < rows.Cols(); ++j)
ret(i,j) = residual[rows(i,j)];
......
This diff is collapsed.
......@@ -66,15 +66,15 @@ namespace INMOST
/// @param pos Position for which to extract the unknown, should be no larger then MatrixSize.
virtual unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const = 0;
/// Return vector filled with values of unknowns of the block.
virtual rpMatrix Value(const Storage & e) const = 0;
virtual rMatrix Value(const Storage & e) const = 0;
/// Return vector filled with indices of unknowns of the block.
virtual ipMatrix Index(const Storage & e) const = 0;
virtual iMatrix Index(const Storage & e) const = 0;
/// Return vector filled with unknowns of the block with their derivatives.
virtual upMatrix Unknown(const Storage & e) const = 0;
virtual uMatrix Unknown(const Storage & e) const = 0;
/// Return vector filled with either values or indices or unknowns of the block,
/// depending on the template parameter.
template<typename T>
Matrix<typename Demote<T>::type, pool_array_t<typename Demote<T>::type> >
Matrix<typename Demote<T>::type>
Access(const Storage &e) const;
/// Return either value or index or unknown at specified position of the block,
/// depending on the template parameter.
......@@ -83,7 +83,7 @@ namespace INMOST
typename Demote<T>::type
Access(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const;
/// Return vector filled with unknowns of the block with their derivatives.
virtual upMatrix operator [](const Storage & e) const = 0;
virtual uMatrix operator [](const Storage & e) const = 0;
/// The intended size of the matrix for this entry.
virtual INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const = 0;
/// Number of tags in block.
......@@ -138,13 +138,13 @@ namespace INMOST
/// Return unknown in vector of variables of the block at certain position.
unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {return unknown(Value(e,pos),Index(e,pos));}
/// Return vector filled with values of unknowns of the block.
rpMatrix Value(const Storage & e) const {rpMatrix ret(MatrixSize(e),1); for(unsigned k = 0; k < Size(); ++k) ret(k,0) = Value(e,k); return ret; }
rMatrix Value(const Storage & e) const {rMatrix ret(MatrixSize(e),1); for(unsigned k = 0; k < Size(); ++k) ret(k,0) = Value(e,k); return ret; }
/// Return vector filled with indices of unknowns of the block.
ipMatrix Index(const Storage & e) const {ipMatrix ret(MatrixSize(e),1); for(unsigned k = 0; k < Size(); ++k) ret(k,0) = Index(e,k); return ret; }
iMatrix Index(const Storage & e) const {iMatrix ret(MatrixSize(e),1); for(unsigned k = 0; k < Size(); ++k) ret(k,0) = Index(e,k); return ret; }
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix Unknown(const Storage & e) const {return BlockEntry::operator [](e);}
uMatrix Unknown(const Storage & e) const {return BlockEntry::operator [](e);}
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix operator [](const Storage & e) const {upMatrix ret(MatrixSize(e),1); for(unsigned k = 0; k < Size(); ++k) ret(k,0) = Unknown(e,k); return ret; }
uMatrix operator [](const Storage & e) const {uMatrix ret(MatrixSize(e),1); for(unsigned k = 0; k < Size(); ++k) ret(k,0) = Unknown(e,k); return ret; }
/// The intended size of the matrix for this entry.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const {(void)e; return Size();}
/// Number of tags in block.
......@@ -187,13 +187,13 @@ namespace INMOST
/// Return unknown in vector of variables of the block at certain position.
unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {assert(pos==0); return unknown(Value(e,pos),Index(e,pos));}
/// Return vector filled with values of unknowns of the block.
rpMatrix Value(const Storage & e) const { rpMatrix ret(1,1); ret(0,0) = Value(e,0); return ret; }
rMatrix Value(const Storage & e) const { rMatrix ret(1,1); ret(0,0) = Value(e,0); return ret; }
/// Return vector filled with indices of unknowns of the block.
ipMatrix Index(const Storage & e) const { ipMatrix ret(1,1); ret(0,0) = Index(e,0); return ret; }
iMatrix Index(const Storage & e) const { iMatrix ret(1,1); ret(0,0) = Index(e,0); return ret; }
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix Unknown(const Storage & e) const {return SingleEntry::operator [](e);}
uMatrix Unknown(const Storage & e) const {return SingleEntry::operator [](e);}
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix operator [](const Storage & e) const { upMatrix ret(1,1); ret(0,0) = Unknown(e,0); return ret; }
uMatrix operator [](const Storage & e) const { uMatrix ret(1,1); ret(0,0) = Unknown(e,0); return ret; }
/// The intended size of the matrix for this entry.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const {(void)e; return 1;}
/// Number of tags in block.
......@@ -229,13 +229,13 @@ namespace INMOST
/// Return unknown in vector of variables of the block at certain position.
unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {assert(pos<unknown_tag[e].size()); return unknown(Value(e,pos),Index(e,pos));}
/// Return vector filled with values of unknowns of the block.
rpMatrix Value(const Storage & e) const { rpMatrix ret(MatrixSize(e),1); for(int k = 0; k < (int)unknown_tag[e].size(); ++k) ret(k,0) = Value(e,k); return ret; }
rMatrix Value(const Storage & e) const { rMatrix ret(MatrixSize(e),1); for(int k = 0; k < (int)unknown_tag[e].size(); ++k) ret(k,0) = Value(e,k); return ret; }
/// Return vector filled with indices of unknowns of the block.
ipMatrix Index(const Storage & e) const { ipMatrix ret(MatrixSize(e),1); for(int k = 0; k < (int)unknown_tag[e].size(); ++k) ret(k,0) = Index(e,k); return ret; }
iMatrix Index(const Storage & e) const { iMatrix ret(MatrixSize(e),1); for(int k = 0; k < (int)unknown_tag[e].size(); ++k) ret(k,0) = Index(e,k); return ret; }
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix Unknown(const Storage & e) const {return VectorEntry::operator [](e);}
uMatrix Unknown(const Storage & e) const {return VectorEntry::operator [](e);}
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix operator [](const Storage & e) const { upMatrix ret(MatrixSize(e),1); for(int k = 0; k < (int)unknown_tag[e].size(); ++k) ret(k,0) = Unknown(e,k); return ret; }
uMatrix operator [](const Storage & e) const { uMatrix ret(MatrixSize(e),1); for(int k = 0; k < (int)unknown_tag[e].size(); ++k) ret(k,0) = Unknown(e,k); return ret; }
/// The intended size of the matrix for this entry.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const {return (INMOST_DATA_ENUM_TYPE)unknown_tag[e].size();}
/// Number of tags in block.
......@@ -285,13 +285,13 @@ namespace INMOST
/// Return unknown in vector of variables of the block at certain position.
unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const {return unknown(Value(e,pos),Index(e,pos));}
/// Return vector filled with values of unknowns of the block.
rpMatrix Value(const Storage & e) const {rpMatrix ret(MatrixSize(e),1); for(INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) ret(k,0) = Value(e,k); return ret; }
rMatrix Value(const Storage & e) const {rMatrix ret(MatrixSize(e),1); for(INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) ret(k,0) = Value(e,k); return ret; }
/// Return vector filled with indices of unknowns of the block.
ipMatrix Index(const Storage & e) const {ipMatrix ret(MatrixSize(e),1); for(INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) ret(k,0) = Index(e,k); return ret; }
iMatrix Index(const Storage & e) const {iMatrix ret(MatrixSize(e),1); for(INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) ret(k,0) = Index(e,k); return ret; }
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix Unknown(const Storage & e) const {return StatusBlockEntry::operator [](e);}
uMatrix Unknown(const Storage & e) const {return StatusBlockEntry::operator [](e);}
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix operator [](const Storage & e) const {upMatrix ret(MatrixSize(e),1); for(INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) ret(k,0) = Unknown(e,k); return ret; }
uMatrix operator [](const Storage & e) const {uMatrix ret(MatrixSize(e),1); for(INMOST_DATA_ENUM_TYPE k = 0; k < Size(); ++k) ret(k,0) = Unknown(e,k); return ret; }
/// The intended size of the matrix for this entry.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const {(void)e; return Size();}
/// Number of tags in block.
......@@ -338,13 +338,13 @@ namespace INMOST
/// Return unknown in vector of variables of the block at certain position.
unknown Unknown(const Storage & e, INMOST_DATA_ENUM_TYPE pos) const;
/// Return vector filled with values of unknowns of the block.
rpMatrix Value(const Storage & e) const;
rMatrix Value(const Storage & e) const;
/// Return vector filled with indices of unknowns of the block.
ipMatrix Index(const Storage & e) const;
iMatrix Index(const Storage & e) const;
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix Unknown(const Storage & e) const {return MultiEntry::operator [](e);}
uMatrix Unknown(const Storage & e) const {return MultiEntry::operator [](e);}
/// Return vector filled with unknowns of the block with their derivatives.
upMatrix operator [](const Storage & e) const;
uMatrix operator [](const Storage & e) const;
/// The intended size of the matrix for this entry.
INMOST_DATA_ENUM_TYPE MatrixSize(const Storage & e) const;
/// Number of tags in block.
......
This diff is collapsed.
......@@ -61,7 +61,7 @@ namespace INMOST
/// Retrive a vector of entries in residual, corresponding to a set of equations.
/// @param rows A row-vector of equation numbers.
/// @param A structure that can be used in or assigned an automatic differentiation matrix expression.
rpMatrix Value(const AbstractMatrix<INMOST_DATA_INTEGER_TYPE> & rows) const;
rMatrix Value(const AbstractMatrix<INMOST_DATA_INTEGER_TYPE> & rows) const;
/// Retrive hessian matrix. Use in nonlinear solver.
Sparse::HessianMatrix & GetHessian() {return hessian;}
/// Retrive hessian matrix without right of modificaiton.
......
......@@ -4,7 +4,6 @@ set(SOURCE
${CMAKE_CURRENT_SOURCE_DIR}/xml.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/base64.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pool.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mem.cpp
PARENT_SCOPE
)
......@@ -14,4 +13,4 @@ set(HEADER
${CMAKE_CURRENT_SOURCE_DIR}/utils.h
${CMAKE_CURRENT_SOURCE_DIR}/base64.h
PARENT_SCOPE
)
\ No newline at end of file
)
#ifdef _MSC_VER //kill some warnings
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "inmost.h"
namespace INMOST
{
static thread_private<memory_pool> _pool;
memory_pool & get_pool()
{
//std::cout << "get pool " << (void *)&(*_pool) << std::endl;
return *_pool;
}
}
......@@ -11,6 +11,7 @@ int main(int argc,char ** argv)
if( test == 0 ) //check order of deallocation does not cause problem
{
/*
std::cout << "allocs: " << get_pool().allocations() << " byte " << get_pool().last_byte() << std::endl;
pool_array<double> * a = new pool_array<double>(2);
std::cout << "allocs: " << get_pool().allocations() << " byte " << get_pool().last_byte() << std::endl;
......@@ -24,6 +25,7 @@ int main(int argc,char ** argv)
std::cout << "allocs: " << get_pool().allocations() << " byte " << get_pool().last_byte() << std::endl;
delete c;
std::cout << "allocs: " << get_pool().allocations() << " byte " << get_pool().last_byte() << std::endl;
*/
}
return 0;
}
......@@ -411,7 +411,7 @@ int main(int argc,char ** argv)
else if( test == 22 ) //check memory_pool with large matrix (was shown to fail in hydr_frac problem)
{
#if defined(USE_OMP)
//#pragma omp parallel
#pragma omp parallel
#endif
{
rMatrix A(224,12), B(224,1);
......@@ -421,17 +421,10 @@ int main(int argc,char ** argv)
A(k,l) = 2.0*(rand()/(1.*RAND_MAX))-1.0;
B(k,0) = 2.0*(rand()/(1.*RAND_MAX))-1.0;
}
(A.PseudoSolve(B)).Transpose().Print();
int thread = 0;
#if defined(USE_OMP)
thread = omp_get_thread_num();
#pragma omp barrier
#endif
std::cout << "allocations on " << thread << " " << get_pool().allocations() << std::endl;
#if defined(USE_OMP)
#pragma omp barrier
#pragma omp critical
#endif
assert(get_pool().allocations() == 0);
(A.PseudoSolve(B)).Transpose().Print();
}
}
#if defined(USE_FP64)
......
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