Commit ae0bf6b1 authored by Kirill Terekhov's avatar Kirill Terekhov

Fixes and updates

Including issue #15
parent 5cbb6419
......@@ -149,6 +149,7 @@ int main(int argc,char ** argv)
{
Automatizator aut(m);
Automatizator::MakeCurrent(&aut);
INMOST_DATA_ENUM_TYPE iphi = aut.RegisterDynamicTag(phi,CELL);
aut.EnumerateDynamicTags();
......@@ -164,7 +165,7 @@ int main(int argc,char ** argv)
#pragma omp parallel
#endif
{
enhanced_variable flux(aut); //should be more efficient to define here to avoid multiple memory allocations if storage for variations should be expanded
variable flux; //should be more efficient to define here to avoid multiple memory allocations if storage for variations should be expanded
#if defined(USE_OMP)
#pragma omp for
#endif
......
......@@ -454,9 +454,10 @@ int main(int argc,char ** argv)
{ //Main loop for problem solution
Automatizator aut(m); // declare class to help manage unknowns
Automatizator::MakeCurrent(&aut);
Sparse::RowMerger & merger = aut.GetMerger(); //get structure that helps matrix assembly
dynamic_variable P(aut,aut.RegisterDynamicTag(tag_P,CELL|FACE)); //register pressure as primary unknown
enhanced_variable calc(aut); //declare variable that helps calculating the value with variations
variable calc; //declare variable that helps calculating the value with variations
aut.EnumerateDynamicTags(); //enumerate all primary variables
......
......@@ -13,9 +13,40 @@
namespace INMOST
{
Automatizator * Automatizator::CurrentAutomatizator = NULL;
bool print_ad_ctor = false;
bool GetAutodiffPrint() {return print_ad_ctor;}
void SetAutodiffPrint(bool set) {print_ad_ctor = set;}
bool CheckCurrentAutomatizator() {return Automatizator::HaveCurrent();}
void multivar_expression::FromBasicExpression(const basic_expression & expr)
{
Sparse::RowMerger & merger = Automatizator::GetCurrent()->GetMerger();
expr.GetDerivative(1.0,merger);
merger.RetriveRow(entries);
merger.Clear();
}
void multivar_expression::AddBasicExpression(INMOST_DATA_REAL_TYPE multme, INMOST_DATA_REAL_TYPE multit, const basic_expression & expr)
{
Sparse::RowMerger & merger = Automatizator::GetCurrent()->GetMerger();
merger.PushRow(multme,entries);
expr.GetDerivative(multit,merger);
merger.RetriveRow(entries);
merger.Clear();
}
void multivar_expression::FromGetDerivative(INMOST_DATA_REAL_TYPE mult, Sparse::Row & r) const
{
Sparse::RowMerger & merger = Automatizator::GetCurrent()->GetMerger();
GetDerivative(mult,merger);
merger.AddRow(1.0,r);
merger.RetriveRow(r);
merger.Clear();
}
#if defined(NEW_VERSION)
//! returns offset from the end of precomputed z
//! returns offset from the end of precomputed z
void Automatizator::DerivativeFill(expr & var, INMOST_DATA_ENUM_TYPE element, INMOST_DATA_ENUM_TYPE parent, Sparse::RowMerger & entries, INMOST_DATA_REAL_TYPE multval, void * user_data)
{
INMOST_DATA_ENUM_TYPE voffset = var.values_offset(element), doffset = var.derivatives_offset(element);
......
......@@ -400,6 +400,8 @@ namespace INMOST
{
if( !tag.isSparse(mask) )
{
//this was already done in Mesh::DeleteTag()
//ReallocateData(tag,ElementNum(mask),0); //this should clean up the structures
dense_data[tpos].clear(); //here all data should be deleted
empty_dense_data.push_back(tpos);
}
......@@ -517,6 +519,17 @@ namespace INMOST
}
}
}
#if defined(USE_AUTODIFF)
else if( data_type == DATA_VARIABLE ) //Have to perform in-memory deallocation to correctly remove class inheritance
{
for(INMOST_DATA_ENUM_TYPE it = new_size; it < old_size; ++it)
{
variable * p = static_cast<variable *>(static_cast<void *>(&arr[it]));
for(INMOST_DATA_ENUM_TYPE jt = 0; jt < data_size; ++jt)
p[jt].~variable();
}
}
#endif
#if defined(USE_OMP)
#pragma omp critical
#endif
......@@ -538,6 +551,17 @@ namespace INMOST
#endif
}
}
#if defined(USE_AUTODIFF)
else if( data_type == DATA_VARIABLE ) //Have to perform in-memory allocation to correctly setup class inheritance
{
for(INMOST_DATA_ENUM_TYPE it = old_size; it < new_size; ++it)
{
variable * p = static_cast<variable *>(static_cast<void *>(&arr[it]));
for(INMOST_DATA_ENUM_TYPE jt = 0; jt < data_size; ++jt)
new (p+jt) variable();
}
}
#endif
}
}
......
......@@ -18,18 +18,19 @@
//TODO
// 1. change to uniform size_type instead of size_t, make it INMOST_DATA_ENUM_TYPE
/*
template<class element, class T1> struct isInputRandomIterators
{
static void constraints(T1 a, T1 b) { /*element x = static_cast<element>(*a); (void)x;*/ ++a; (void)a++; a==a; a!=a; a-b; }
static void constraints(T1 a, T1 b) { ++a; (void)a++; a==a; a!=a; a-b; }
isInputRandomIterators() { void(*p)(T1,T1) = constraints; (void)p; }
};
template<class element, class T1> struct isInputForwardIterators
{
static void constraints(T1 a) { /*element x = static_cast<element>(*a); (void)x;*/ ++a; (void)a++; }
static void constraints(T1 a) {++a; (void)a++; }
isInputForwardIterators() { void(*p)(T1) = constraints; (void)p; }
};
*/
namespace INMOST
{
......
......@@ -92,6 +92,7 @@ namespace INMOST
typedef dynarray<stencil_pair, 64> stencil_pairs;
typedef void(*stencil_callback)(const Storage & current_element, stencil_pairs & out_stencil, void * user_data);
private:
static Automatizator * CurrentAutomatizator;
#if defined(USE_OMP)
std::vector<Sparse::RowMerger> merger;
#else
......@@ -187,6 +188,14 @@ namespace INMOST
return merger;
#endif
}
/// Remove global current automatizator.
static void RemoveCurrent() {CurrentAutomatizator = NULL;}
/// Set current global automatizator, so that variable will be optimized with row merger.
static void MakeCurrent(Automatizator * aut) {CurrentAutomatizator = aut;}
/// Check that there is an automatizator.
static bool HaveCurrent() {return CurrentAutomatizator != NULL;}
/// Retrive the automatizator.
static Automatizator * GetCurrent() {return CurrentAutomatizator;}
};
#if defined(NEW_VERSION)
......
......@@ -240,24 +240,38 @@ namespace INMOST
typedef tag_array_type::iterator iteratorTag;
public:
virtual ~TagManager();
/// Check existance of a data tag by it's name.
bool HaveTag(std::string name) const;
/// Retrive a data tag by it's name.
Tag GetTag(std::string name) const;
/// Retrive names for all the tags present on the mesh.
void ListTagNames(std::vector<std::string> & list) const;
/// Create tag with prescribed attributes.
Tag CreateTag(Mesh * m, std::string name, DataType dtype, ElementType etype, ElementType sparse, INMOST_DATA_ENUM_TYPE size = ENUMUNDEF);
/// Delete tag from certain elements.
virtual Tag DeleteTag(Tag tag, ElementType mask);
/// Check that the tag was defined on certain elements.
bool ElementDefined(Tag const & tag, ElementType etype) const;
protected:
/// Shrink or enlarge arrays for a dense data.
void ReallocateData(const Tag & t, INMOST_DATA_INTEGER_TYPE etypenum,INMOST_DATA_ENUM_TYPE new_size);
/// Reallocate all the data for all the tags.
void ReallocateData(INMOST_DATA_INTEGER_TYPE etypenum, INMOST_DATA_ENUM_TYPE new_size);
///Retrive substructure for representation of the sparse data without permission for modification.
__INLINE sparse_sub_type const & GetSparseData(int etypenum, int local_id) const {return sparse_data[etypenum][local_id];}
///Retrive substructure for representation of the sparse data.
__INLINE sparse_sub_type & GetSparseData(int etypenum, int local_id) {return sparse_data[etypenum][local_id];}
///Retrive substructure for representation of the dense data without permission for modification.
__INLINE dense_sub_type const & GetDenseData(int pos) const {return dense_data[pos];}
///Retrive substructure for representation of the dense data.
__INLINE dense_sub_type & GetDenseData(int pos) {return dense_data[pos];}
///Copy data from one element to another.
static void CopyData(const Tag & t, void * adata, const void * bdata);
///Destroy data that represents array of variable size.
static void DestroyVariableData(const Tag & t, void * adata);
protected:
typedef tag_array_type::iterator tag_iterator;
typedef tag_array_type::const_iterator tag_const_iterator;
typedef tag_array_type::iterator tag_iterator; //< Use this type to iterate over tags of the mesh.
typedef tag_array_type::const_iterator tag_const_iterator; //< Use this type to iterate over tags of the mesh without right for modification.
protected:
tag_array_type tags;
empty_data empty_dense_data;
......@@ -432,16 +446,16 @@ namespace INMOST
/// If there is a link to handle provided (automatically by ElementArray and reference_array),
/// then remote handle value will be modified
Storage & operator = (Storage const & other);
__INLINE bool operator < (const Storage & other) const;
__INLINE bool operator > (const Storage & other) const;
__INLINE bool operator <= (const Storage & other) const;
__INLINE bool operator >= (const Storage & other) const;
__INLINE bool operator == (const Storage & other) const;
__INLINE bool operator != (const Storage & other) const;
__INLINE Storage * operator-> ();
__INLINE const Storage * operator-> () const;
__INLINE Storage & self ();
__INLINE const Storage & self () const;
__INLINE bool operator < (const Storage & other) const {return handle < other.handle;}
__INLINE bool operator > (const Storage & other) const {return handle > other.handle;}
__INLINE bool operator <= (const Storage & other) const {return handle <= other.handle;}
__INLINE bool operator >= (const Storage & other) const {return handle >= other.handle;}
__INLINE bool operator == (const Storage & other) const {return handle == other.handle;}
__INLINE bool operator != (const Storage & other) const {return handle != other.handle;}
__INLINE Storage * operator-> () {return this;}
__INLINE const Storage * operator-> () const {return this;}
__INLINE Storage & self () {return *this;}
__INLINE const Storage & self () const {return *this;}
virtual ~Storage() {}
public:
/// Retrieve real value associated with Tag. Implemented in inmost_mesh.h.
......
This diff is collapsed.
This diff is collapsed.
......@@ -1987,12 +1987,15 @@ namespace INMOST
/// @param tag tag that represents the data
/// @see Tag::GetSize
INMOST_DATA_ENUM_TYPE GetDataSize (HandleType h,const Tag & tag) const; //For DATA_BULK return number of bytes, otherwise return the length of array
/// Return the size of the structure required to represent the data on current element.
/// Return the size of the structure in bytes required to represent the data on current element.
/// This is equal to GetDataSize times Tag::GetBytesSize for all the data types,
/// except for DATA_VARIABLE, that requires a larger structure to accomodate derivatives.
/// @param h handle of element
/// @param tag tag that represents the data
INMOST_DATA_ENUM_TYPE GetDataCapacity (HandleType h,const Tag & tag) const;
/// Returns the number of bytes in data used for given type of tag.
/// Trivial for all the types except DATA_VARIABLE.
INMOST_DATA_ENUM_TYPE GetDataCapacity (const INMOST_DATA_BULK_TYPE * data, INMOST_DATA_ENUM_TYPE size, const Tag & tag) const;
/// Sets the size of the array for data of variable size.
/// If you try to change size of data of constant size then if size is
/// different from current then in debug mode (NDEBUG not set) assertion will fail,
......@@ -3199,46 +3202,6 @@ namespace INMOST
//////////////////////////////////////////////////////////////////////
/// Inline functions for class Storage //
//////////////////////////////////////////////////////////////////////
__INLINE bool Storage::operator <(const Storage & other) const
{
return handle < other.handle;
}
__INLINE bool Storage::operator >(const Storage & other) const
{
return handle > other.handle;
}
__INLINE bool Storage::operator <=(const Storage & other) const
{
return handle <= other.handle;
}
__INLINE bool Storage::operator >=(const Storage & other) const
{
return handle >= other.handle;
}
__INLINE bool Storage::operator ==(const Storage & other) const
{
return handle == other.handle;
}
__INLINE bool Storage::operator !=(const Storage & other) const
{
return handle != other.handle;
}
__INLINE Storage * Storage::operator ->()
{
return this;
}
__INLINE const Storage * Storage::operator->() const
{
return this;
}
__INLINE Storage & Storage::self()
{
return *this;
}
__INLINE const Storage & Storage::self() const
{
return *this;
}
__INLINE Storage::real & Storage::Real(const Tag & tag) const
{
return GetMeshLink()->Real(GetHandle(),tag);
......
This diff is collapsed.
......@@ -96,9 +96,6 @@ namespace INMOST
!t->isSparse(etype) &&
t->GetTagName().substr(0,9) != "PROTECTED" &&
t->GetDataType() != DATA_REFERENCE &&
#if defined(USE_AUTODIFF)
t->GetDataType() != DATA_VARIABLE &&
#endif
t->GetDataType() != DATA_REMOTE_REFERENCE)
{
sprintf(keyword,"%s",t->GetTagName().substr(0,8).c_str());
......@@ -119,6 +116,9 @@ namespace INMOST
case DATA_INTEGER: keyval = static_cast<Storage::real>(e->Integer(*t)); break;
case DATA_REAL: keyval = e->Real(*t); break;
case DATA_BULK: keyval = static_cast<Storage::real>(e->Bulk(*t)); break;
#if defined(USE_AUTODIFF)
case DATA_VARIABLE: keyval = e->Variable(*t).GetValue(); break;
#endif
default: throw NotImplemented;
}
fwrite(&keyval,sizeof(Storage::real),1,file);
......@@ -136,9 +136,6 @@ namespace INMOST
t->GetSize() == 1 &&
t->isSparse(etype) &&
t->GetDataType() != DATA_REFERENCE &&
#if defined(USE_AUTODIFF)
t->GetDataType() != DATA_VARIABLE &&
#endif
t->GetDataType() != DATA_REMOTE_REFERENCE)
{
Storage::integer temp;
......@@ -173,6 +170,9 @@ namespace INMOST
case DATA_INTEGER: keyval = static_cast<Storage::real>(e->Integer(*t)); break;
case DATA_REAL: keyval = e->Real(*t); break;
case DATA_BULK: keyval = static_cast<Storage::real>(e->Bulk(*t)); break;
#if defined(USE_AUTODIFF)
case DATA_VARIABLE: keyval = e->Variable(*t).GetValue(); break;
#endif
default: throw NotImplemented;
}
fwrite(&keyval,sizeof(Storage::real),1,file);
......@@ -230,10 +230,8 @@ namespace INMOST
t->GetSize() != 1 &&
t->GetSize() != ENUMUNDEF &&
!t->isSparse(etype) &&
t->GetTagName().substr(0,9) != "PROTECTED" &&
t->GetDataType() != DATA_REFERENCE &&
#if defined(USE_AUTODIFF)
t->GetDataType() != DATA_VARIABLE &&
#endif
t->GetDataType() != DATA_REMOTE_REFERENCE
)
{
......@@ -261,6 +259,9 @@ namespace INMOST
case DATA_INTEGER: keyval = static_cast<Storage::real>(e->IntegerArray(*t)[q]); break;
case DATA_REAL: keyval = e->RealArray(*t)[q]; break;
case DATA_BULK: keyval = static_cast<Storage::real>(e->BulkArray(*t)[q]); break;
#if defined(USE_AUTODIFF)
case DATA_VARIABLE: keyval = e->VariableArray(*t)[q].GetValue(); break;
#endif
default: throw NotImplemented;
}
fwrite(&keyval,sizeof(Storage::real),1,file);
......
......@@ -331,7 +331,7 @@ namespace INMOST
{
if( arr[k].isValid() )
{
uconv.write_iValue(out,arr[k].GetMeshLink()->GetMeshName().size());
uconv.write_iValue(out,static_cast<INMOST_DATA_ENUM_TYPE>(arr[k].GetMeshLink()->GetMeshName().size()));
out.write(arr[k].GetMeshLink()->GetMeshName().c_str(),arr[k].GetMeshLink()->GetMeshName().size());
wetype = arr[k].GetElementType();
out.put(wetype);
......
......@@ -236,9 +236,6 @@ safe_output:
t.GetDataType() != DATA_BULK &&
t.GetDataType() != DATA_REFERENCE &&
t.GetDataType() != DATA_REMOTE_REFERENCE &&
#if defined(USE_AUTODIFF)
t.GetDataType() != DATA_VARIABLE &&
#endif
t != CoordsTag() &&
t != SharedTag() &&
t != SendtoTag() &&
......@@ -261,7 +258,13 @@ safe_output:
else
{
{
fprintf(f,"SCALARS %s %s %d\n",tags[i].GetTagName().c_str(),(tags[i].GetDataType() == DATA_REAL ? "double" : "int"),comps);
std::string type_str = "int";
if( tags[i].GetDataType() == DATA_REAL
#if defined(USE_AUTODIFF)
|| tags[i].GetDataType() == DATA_VARIABLE
#endif
) type_str = "double";
fprintf(f,"SCALARS %s %s %d\n",tags[i].GetTagName().c_str(),type_str.c_str(),comps);
fprintf(f,"LOOKUP_TABLE default\n");
for(Mesh::iteratorCell it = BeginCell(); it != EndCell(); it++)
{
......@@ -281,6 +284,15 @@ safe_output:
fprintf(f,"\n");
}
break;
#if defined(USE_AUTODIFF)
case DATA_VARIABLE:
{
Storage::var_array arr = it->VariableArray(tags[i]);
for(unsigned int m = 0; m < comps; m++) fprintf(f,"%14e ",arr[m].GetValue());
fprintf(f,"\n");
}
break;
#endif
default: continue;
}
}
......@@ -300,9 +312,6 @@ safe_output:
t.GetDataType() != DATA_BULK &&
t.GetDataType() != DATA_REFERENCE &&
t.GetDataType() != DATA_REMOTE_REFERENCE &&
#if defined(USE_AUTODIFF)
t.GetDataType() != DATA_VARIABLE &&
#endif
t != CoordsTag() &&
t != SharedTag() &&
t != SendtoTag() &&
......@@ -322,7 +331,13 @@ safe_output:
else
{
{
fprintf(f,"SCALARS %s %s %d\n",tags[i].GetTagName().c_str(),(tags[i].GetDataType() == DATA_REAL ? "double" : "int"),comps);
std::string type_str = "int";
if( tags[i].GetDataType() == DATA_REAL
#if defined(USE_AUTODIFF)
|| tags[i].GetDataType() == DATA_VARIABLE
#endif
) type_str = "double";
fprintf(f,"SCALARS %s %s %d\n",tags[i].GetTagName().c_str(),type_str.c_str(),comps);
fprintf(f,"LOOKUP_TABLE default\n");
for(Mesh::iteratorNode it = BeginNode(); it != EndNode(); it++)
{
......@@ -342,6 +357,15 @@ safe_output:
fprintf(f,"\n");
}
break;
#if defined(USE_AUTODIFF)
case DATA_VARIABLE:
{
Storage::var_array arr = it->VariableArray(tags[i]);
for(unsigned int m = 0; m < comps; m++) fprintf(f,"%14e ",arr[m].GetValue());
fprintf(f,"\n");
}
break;
#endif
default: continue;
}
}
......
......@@ -257,7 +257,7 @@ namespace INMOST
{
ret += t->GetRecordSize(); //all utilized data for fixed data, size of support structure for variable data
if( t->GetSize() == ENUMUNDEF )
ret += GetDataSize(h,*t)*t->GetBytesSize(); //actually occupied size for sparse data
ret += GetDataCapacity(h,*t); //actually occupied size for sparse data
}
}
if( !sparse_data[etypenum].empty() ) ret += sizeof(sparse_sub_type); //size needed to support sparse data
......@@ -2042,6 +2042,24 @@ namespace INMOST
}
return tag.GetSize();
}
INMOST_DATA_ENUM_TYPE Mesh::GetDataCapacity(const INMOST_DATA_BULK_TYPE * adata, INMOST_DATA_ENUM_TYPE size, const Tag & tag) const
{
assert( tag.GetMeshLink() == this );
if( tag.GetDataType() != DATA_VARIABLE )
return size*tag.GetBytesSize();
#if defined(USE_AUTODIFF)
else
{
INMOST_DATA_ENUM_TYPE ret = 0;
const Sparse::Row::entry * arr = static_cast<const Sparse::Row::entry *>(static_cast<const void *>(adata));
for(INMOST_DATA_ENUM_TYPE k = 0; k < size; ++k)
ret += variable::RetriveSize(arr+ret);
return ret*sizeof(Sparse::Row::entry);
}
#endif
assert(false);
return 0;
}
INMOST_DATA_ENUM_TYPE Mesh::GetDataCapacity(HandleType h,const Tag & tag) const
{
assert( tag.GetMeshLink() == this );
......@@ -2062,9 +2080,8 @@ namespace INMOST
{
INMOST_DATA_ENUM_TYPE ret = 0;
const inner_variable_array * arr = static_cast<const inner_variable_array *>(adata);
ret += arr->size();
for(inner_variable_array::size_type k = 0; k < arr->size(); ++k)
ret += (*arr)[k].GetRow().Size();
ret += (*arr)[k].RecordSize();//(*arr)[k].GetRow().Size();
return ret*sizeof(Sparse::Row::entry_s);
}
#endif
......@@ -2073,11 +2090,7 @@ namespace INMOST
}
#if defined(USE_AUTODIFF)
if( tag.GetDataType() == DATA_VARIABLE )
{
INMOST_DATA_ENUM_TYPE ret = 0;
const var * v = static_cast<const var *>(MGetLink(h,tag));
return (1+v->GetRow().Size())*sizeof(Sparse::Row::entry_s);
}
return static_cast<const var *>(MGetLink(h,tag))->RecordSize()*sizeof(Sparse::Row::entry_s);
#endif
return tag.GetSize()*tag.GetBytesSize();
}
......@@ -2130,18 +2143,7 @@ namespace INMOST
Sparse::Row::entry_s * data = static_cast<Sparse::Row::entry_s *>(data_out);
int k = 0;
for(INMOST_DATA_ENUM_TYPE r = 0; r < size; ++r)
{
const Sparse::Row & row = (*arr)[r+shift].GetRow();
data[k].first = row.Size();
data[k].second = (*arr)[r+shift].GetValue();
++k;
for(INMOST_DATA_ENUM_TYPE q = 0; q < row.Size(); ++q)
{
data[k].first = row.GetIndex(q);
data[k].second = row.GetValue(q);
++k;
}
}
k += (*arr)[r+shift].Record(data+k);
}
break;
#endif
......@@ -2154,18 +2156,7 @@ namespace INMOST
const var * v = static_cast<const var *>(MGetLink(h,tag));
int k = 0;
for(INMOST_DATA_ENUM_TYPE r = 0; r < size; ++r)
{
const Sparse::Row & row = v[shift+r].GetRow();
data[k].first = row.Size();
data[k].second = v[shift+r].GetValue();
++k;
for(INMOST_DATA_ENUM_TYPE r = 0; r < row.Size(); ++r)
{
data[k].first = row.GetIndex(r);
data[k].second = row.GetValue(r);
++k;
}
}
k += v[r+shift].Record(data+k);
}
#endif
else memcpy(data_out,static_cast<const INMOST_DATA_BULK_TYPE *>(adata)+shift*bytes,size*bytes);
......@@ -2195,18 +2186,7 @@ namespace INMOST
const Sparse::Row::entry_s * data = static_cast<const Sparse::Row::entry_s *>(data_in);
int k = 0;
for(INMOST_DATA_ENUM_TYPE r = 0; r < size; ++r)
{
Sparse::Row & row = (*arr)[r+shift].GetRow();
row.Resize(data[k].first);
(*arr)[r+shift].SetValue(data[k].second);
++k;
for(INMOST_DATA_ENUM_TYPE q = 0; q < row.Size(); ++q)
{
row.GetIndex(q) = data[k].first;
row.GetValue(q) = data[k].second;
++k;
}
}
k += (*arr)[r+shift].Retrive(data+k);
}
break;
#endif
......@@ -2219,18 +2199,7 @@ namespace INMOST
var * v = static_cast<var *>(MGetLink(h,tag));
int k = 0;
for(INMOST_DATA_ENUM_TYPE r = 0; r < size; ++r)
{
Sparse::Row & row = v[shift+r].GetRow();
row.Resize(data[k].first);
v[shift+r].SetValue(data[k].second);
++k;
for(INMOST_DATA_ENUM_TYPE r = 0; r < row.Size(); ++r)
{
row.GetIndex(r) = data[k].first;
row.GetValue(r) = data[k].second;
++k;
}
}
k += v[r+shift].Retrive(data+k);
}
#endif
else memcpy(static_cast<INMOST_DATA_BULK_TYPE *>(adata)+shift*bytes,data_in,size*bytes);
......@@ -2246,6 +2215,13 @@ namespace INMOST
{
if( tag.GetSize() == ENUMUNDEF )
TagManager::DestroyVariableData(tag,data);
#if defined(USE_AUTODIFF)
else if( tag.GetDataType() == DATA_VARIABLE ) //Have to deallocate the structure to remove inheritance
{
for(INMOST_DATA_ENUM_TYPE k = 0; k < tag.GetSize(); ++k)
(static_cast<variable *>(data)[k]).~variable();
}
#endif
//else if( tag.GetDataType() == DATA_REFERENCE )
// memset(data,0xff,tag.GetRecordSize());
else memset(data,0,tag.GetRecordSize());
......@@ -2261,6 +2237,13 @@ namespace INMOST
{
if( tag.GetSize() == ENUMUNDEF )
TagManager::DestroyVariableData(tag,s[i].rec);
#if defined(USE_AUTODIFF)
else if( tag.GetDataType() == DATA_VARIABLE ) //Have to deallocate the structure to remove inheritance
{
for(INMOST_DATA_ENUM_TYPE k = 0; k < tag.GetSize(); ++k)
(static_cast<variable *>(s[i].rec)[k]).~variable();
}
#endif
free(s[i].rec);
s.erase(s.begin()+i);
break;
......
......@@ -154,7 +154,11 @@ namespace INMOST
{
adj_type const & lc = m->LowConn(GetHandle());
for(adj_type::size_type it = 0; it < lc.size(); ++it)
if( invert ^ m->GetMarker(lc[it],mask) ) aret.push_back(lc[it]);
{
bool mrk = m->GetMarker(lc[it],mask);
bool test = invert ^ mrk;
if( test ) aret.push_back(lc[it]);
}
}
else
{
......
......@@ -2216,7 +2216,8 @@ namespace INMOST
// REPORT_VAL("value " << qq, (*(Storage::integer *)&array_data_recv[pos+qq*tag.GetBytesSize()]));
//}
op(tag,Element(this,*eit),&array_data_recv[pos],array_size_recv[k]);
pos += GetDataCapacity(*eit,tag);// array_size_recv[k]*tag.GetBytesSize();
pos += GetDataCapacity(&array_data_recv[pos],array_size_recv[k],tag);
//pos += array_size_recv[k]*tag.GetBytesSize();
++k;
++total_unpacked;
}
......@@ -2228,7 +2229,8 @@ namespace INMOST
eit = elements[i].begin() + array_size_recv[k++];
assert( !select || GetMarker(*eit,select) ); //if fires then very likely that marker was not synchronized
op(tag,Element(this,*eit),&array_data_recv[pos],size);
pos += GetDataCapacity(*eit,tag);//size*tag.GetBytesSize();
pos += GetDataCapacity(&array_data_recv[pos],size,tag);
//pos += size*tag.GetBytesSize();
++total_unpacked;
}
}
......@@ -2240,7 +2242,8 @@ namespace INMOST
for(eit = elements[i].begin(); eit != elements[i].end(); eit++) if( !select || GetMarker(*eit,select) )
{
op(tag,Element(this,*eit),&array_data_recv[pos],array_size_recv[k]);
pos += GetDataCapacity(*eit,tag);//array_size_recv[k]*tag.GetBytesSize();
pos += GetDataCapacity(&array_data_recv[pos],array_size_recv[k],tag);
//pos += array_size_recv[k]*tag.GetBytesSize();
++k;
++total_unpacked;
}
......@@ -2250,7 +2253,8 @@ namespace INMOST
for(eit = elements[i].begin(); eit != elements[i].end(); eit++) if( !select || GetMarker(*eit,select) )
{
op(tag,Element(this,*eit),&array_data_recv[pos],size);
pos += GetDataCapacity(*eit,tag);//size*tag.GetBytesSize();
pos += GetDataCapacity(&array_data_recv[pos],size,tag);
//pos += size*tag.GetBytesSize();
++total_unpacked;
}
}
......
......@@ -46,8 +46,8 @@
//#define USE_OMP
//#define KSOLVER BCGSL_solver
#define KSOLVER BCGS_solver
#define KSOLVER BCGSL_solver
//#define KSOLVER BCGS_solver
//#define ACCELERATED_CONDEST
//#define PRINT_CONDEST
......@@ -64,7 +64,7 @@ namespace INMOST
#define GUARD_MPI(x) {ierr = x; if( ierr != MPI_SUCCESS ) {std::cout << #x << " not successfull " << std::endl; MPI_Abort(comm,-1000);}}
#define GUARD_MPI(x) {ierr = x; if( ierr != MPI_SUCCESS ) {char str[4096]; int len; MPI_Error_string(ierr,str,&len); std::cout << #x << " not successfull: " << str << std::endl; MPI_Abort(comm,-1000);}}
#define HASH_TABLE_SIZE 2048
bool Solver::is_initialized = false;
......
This diff is collapsed.
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