yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #00562
[svn] r1460 - eudoxos
-
To:
yade-dev@xxxxxxxxxxxxxxxxxxx
-
From:
Janek Kozicki <janek_listy@xxxxx>
-
Date:
Wed, 20 Aug 2008 11:57:32 +0200
-
Face:
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAALVBMVEUBAQEtLS1KSkpRUVFXV1dYWFhjY2Nzc3N3d3eHh4eKioqdnZ24uLjLy8vc3NxVIagyAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH2AIVEzgS1fgQtQAAAjRJREFUOMtt1DFv00AUAOAzFQNbjigSyoQaRaBMhKgLUyKXpVNNeUpk9vyDqFJhQ1kiBuaqAwJCqvPtSLY7RlTn5+5IdnYkkt/AOyfxXVLe5vf53Z1875kd34tOEax8djmj6GyjhB5bxz50GdsVZr9fqRjZwAtKOJw5Wqs2MMZ16ALHsaDncF7xAHix1oEFHAB8f+pRjcO4gfZDykcYzbiucRolOLUJ6kjA0xtVt+A6TySlM0RajIpK6DzwKZ/nOYbF/gclHMo1ZOHYY/+Ha+AWuM+3oMS4eeqYzZ8FiCltgUqI8cd2wwAVpJk+8LWYjBtnJdQpHQqJMd4Oxt4bU9ESiFGc5hkqaH74asAX4iabP5I5gZ+qjgGlJCqZa3h3lxhoeVcSE1qLQC4sqKOK9MGW9E3izFqqHokoztLFEgXg31sbZEKnWi2T74A4NxfVQqlkjKtcAWD+zcArFEES01dR0E/nnV0IgugmDd/2L84sOAouRBBHEc7gtc8teDkRlE0iNQPo2w3Xhh/D4TCIQ4LRLoTvgwjj6RRgavdurxYGMaIuGOyAW/PpNlCcU9/93AHenAWYjPoAwa+G3e3to/MgFNTAEKvKDjzuCzHTnY3qqdXtx24VijzQfZ0yewZ5cwRFQaa+mIYr1uI0I76+3W4xhlvoVRwOA0Fdl64HlJnxP6T8YpX/Lga4Wv4A3ErrU5oTfN7Mu/llXMl8RXEPji/lQkN3H7qXqgC2By47EXeU/7PJ/wPxRKMnuZwIeAAAAABJRU5ErkJggg==
------------------------------------------------------------------------
r1460 | eudoxos | 2008-08-11 14:02:07 +0200 (pon, 11 sie 2008) | 4 lines
Changed paths:
M /trunk/SConstruct
M /trunk/lib/serialization/FundamentalHandler.tpp
1. Permit non-zero integeres as bool - sometimes the serializaer confuses bool with int; give warning to console about that.
2. the -opt profile (and optimize=1) generates instruction set for the current machine (gcc: -march=native) which means that the code may not run on different processor (e.g. core2 code will not run on Pentium IV). Please let me know if this is problem for someone.
------------------------------------------------------------------------
Index: lib/serialization/FundamentalHandler.tpp
===================================================================
--- lib/serialization/FundamentalHandler.tpp (revision 1459)
+++ lib/serialization/FundamentalHandler.tpp (revision 1460)
@@ -99,8 +99,7 @@
try{
*tmp = lexical_cast<Type>(*tmpStr);
} catch(boost::bad_lexical_cast& e){
- if(a.type()==typeid(bool*) && atoi(tmpStr->c_str())!=0) { *tmp=lexical_cast<Type>("true"); cerr<<"Offensive bool value `"<<*tmpStr<<"' encountered.!!"<<endl; }
- else throw e;
+ if(typeid(tmp)==typeid(bool*) && atoi(tmpStr->c_str())!=0) { cerr<<"warning: offensive bool value `"<<*tmpStr<<"' encountered (interpreted as true)."<<endl; *tmp=lexical_cast<Type>("1"); /* cerr<<"New value: "<<lexical_cast<string>(*tmp)<<endl; cerr<<"Atoi returns "<<atoi(tmpStr->c_str())<<", bool !=0 is "<<(atoi(tmpStr->c_str())!=0)<<endl;*/ }
}
}
else if (a.type()==typeid(string*)) // serialization - writing to string from some Type
@@ -112,33 +111,6 @@
else
cerr<<"lexical_cast(XML): (de)serialization format mismatch"<<endl;
}
- else if(FormatChecker::format==FormatChecker::BIN){
- // Binary serialization
- if (a.type()==typeid(const vector<unsigned char>*)) // from binary stream to Type
- {
- const vector<unsigned char>* tmpBin = any_cast< const vector<unsigned char>* >(a);
- Type * tmp = any_cast<Type*>(ac.getAddress());
- BOOST_STATIC_ASSERT((boost::is_POD<Type>::value));
- std::vector<unsigned char>::const_iterator ptr = (*tmpBin).begin();
- std::vector<unsigned char>::const_iterator end = (*tmpBin).end();
- if(sizeof(Type) != (*tmpBin).size())
- throw HandlerError(SerializationExceptions::LexicalCopyBinError);
- unsigned char *ptr2 = reinterpret_cast<unsigned char *>(tmp);
- std::copy(ptr,end,ptr2);
- }
- else if (a.type()==typeid(vector<unsigned char>*)) // from Type to binary stream
- { CHK_BIN();
- vector<unsigned char>* tmpBin = any_cast< vector<unsigned char>* >(a);
- Type * tmp = any_cast<Type*>(ac.getAddress());
- (*tmpBin).clear();
- const unsigned char* ptr = reinterpret_cast<const unsigned char*>(tmp);
- const unsigned char* end = ptr + sizeof(Type);
- (*tmpBin).resize(sizeof(Type));
- std::copy(ptr, end, (*tmpBin).begin() );
- }
- else
- cerr<<"lexical_cast(BIN): (de)serialization format mismatch"<<endl;
- }
else // never reached
throw HandlerError(SerializationExceptions::LexicalCopyError);
}
Index: SConstruct
===================================================================
--- SConstruct (revision 1459)
+++ SConstruct (revision 1460)
@@ -383,7 +383,7 @@
else: env.Append(CXXFLAGS='-O2')
if env['openmp']: env.Append(CXXFLAGS='-fopenmp',LIBS='gomp')
if env['optimize']:
- env.Append(CXXFLAGS=Split('-O3 -ffast-math'),
+ env.Append(CXXFLAGS=Split('-O3 -ffast-math -march=native'),
CPPDEFINES=[('YADE_CAST','static_cast'),('YADE_PTR_CAST','static_pointer_cast'),'NDEBUG'])
# NDEBUG is used in /usr/include/assert.h: when defined, asserts() are no-ops