More non-deterministics behavior corrections.

* Bug: In Hurricane::Cell_SubCells collection, order the set<> of Cell
    with Entity::CompareById instead of pointer values.
* Bug: In Hurricane::Component_ConnexComponents::Locator, sort the
    set<> of Components with Entity::CompareById instead of pointers.
* Bug: In Hurricane::Occurrence::operator<(), uses Ids to compare
    both _entity and _sharedPath. Check for NULL pointers.
* Change: In Hurricane::IntrusiveMap, add a debug output in _resize()
    like for IntrusiveSet.
      Note to myself : despite their names, InstrusiveMap are hash
    tables and not map<> in the STL sense.
* Bug: In CRL Core, Vst parser, sort the CellVectorMap on Ids.
* Bug: In CRL::NamingScheme::toVhdl(), sort the set<Cell*> models on Ids.
* Bug: In CRL::toVhdlName(), sort the set<Cell*> models on Ids.
* Bug: In CRL::getInstancesCount(), sort the map<Cell*,size_t>
    gatesByMaster on Ids.
This commit is contained in:
Jean-Paul Chaput 2018-04-08 16:58:55 +02:00
parent 2465d12c87
commit 6b4baad8b9
11 changed files with 100 additions and 66 deletions

View File

@ -120,9 +120,9 @@ namespace Vst {
} }
typedef vector<Net*> PinVector; typedef vector<Net*> PinVector;
typedef map<Name,PinVector> VectorMap; typedef map<Name,PinVector> VectorMap;
typedef map<Cell*,VectorMap> CellVectorMap; typedef map<Cell*,VectorMap,Entity::CompareById> CellVectorMap;
class YaccState { class YaccState {

View File

@ -23,6 +23,7 @@ namespace CRL {
using namespace std; using namespace std;
using Hurricane::ForEachIterator; using Hurricane::ForEachIterator;
using Hurricane::Entity;
using Hurricane::Net; using Hurricane::Net;
using Hurricane::Cell; using Hurricane::Cell;
using Hurricane::Instance; using Hurricane::Instance;
@ -109,16 +110,14 @@ namespace CRL {
topCell->setName( converter(topCell->getName()) ); topCell->setName( converter(topCell->getName()) );
vector<Net*> nets; vector<Net*> nets;
forEach ( Net*, inet, topCell->getNets() ) nets.push_back( *inet ); for ( Net* net : topCell->getNets() ) nets.push_back( net );
for ( auto net : nets ) { for ( auto net : nets ) net->setName( converter( net->getName() ) );
net->setName( converter( net->getName() ) );
}
vector<Instance*> instances; vector<Instance*> instances;
set<Cell*> models; set<Cell*,Entity::CompareById> models;
forEach ( Instance*, iinst, topCell->getInstances() ) { for ( Instance* inst : topCell->getInstances() ) {
instances.push_back( *iinst ); instances.push_back( inst );
models.insert( iinst->getMasterCell() ); models.insert( inst->getMasterCell() );
} }
for ( auto inst : instances ) inst->setName( converter( inst->getName() ) ); for ( auto inst : instances ) inst->setName( converter( inst->getName() ) );

View File

@ -62,14 +62,14 @@ namespace CRL {
if (not topCell) return; if (not topCell) return;
vector<Net*> nets; vector<Net*> nets;
forEach ( Net*, inet, topCell->getNets() ) nets.push_back( *inet ); for ( Net* net : topCell->getNets() ) nets.push_back( net );
for ( auto net : nets ) net->setName( vlogToVhdl( inet->getName() ) ); for ( auto net : nets ) net->setName( vlogToVhdl( net->getName() ) );
vector<Instance*> instances; vector<Instance*> instances;
set<Cell*> models; set<Cell*,Entity::CompareById> models;
forEach ( Instance*, iinst, topCell->getInstances() ) { for ( Instance* inst : topCell->getInstances() ) {
instances.push_back( *iinst ); instances.push_back( inst );
models.insert( iinst->getMasterCell() ); models.insert( inst->getMasterCell() );
} }
for ( auto inst : instances ) inst->setName( vlogToVhdl( inst->getName() ) ); for ( auto inst : instances ) inst->setName( vlogToVhdl( inst->getName() ) );

View File

@ -533,9 +533,9 @@ void ConnectPlugHooks(Cell* cell)
} }
size_t _getInstancesCount ( const Cell* cell, map<const Cell*,size_t>& gatesByMaster ) size_t _getInstancesCount ( const Cell* cell, map<const Cell*,size_t,Entity::CompareById>& gatesByMaster )
{ {
map<const Cell*,size_t>::iterator imaster = gatesByMaster.find ( cell ); map<const Cell*,size_t,Entity::CompareById>::iterator imaster = gatesByMaster.find ( cell );
if ( imaster != gatesByMaster.end() ) if ( imaster != gatesByMaster.end() )
return imaster->second; return imaster->second;
@ -556,7 +556,7 @@ void ConnectPlugHooks(Cell* cell)
size_t getInstancesCount ( const Cell* cell ) size_t getInstancesCount ( const Cell* cell )
{ {
map<const Cell*,size_t> gatesByMaster; map<const Cell*,size_t,Entity::CompareById> gatesByMaster;
return _getInstancesCount ( cell, gatesByMaster ); return _getInstancesCount ( cell, gatesByMaster );
} }

View File

@ -996,8 +996,8 @@ Cell* Cell::getClone()
} }
bool isPlaced = true; bool isPlaced = true;
for ( Instance* iinstance : getInstances() ) { for ( Instance* instance : getInstances() ) {
if (iinstance->getClone(clone)->getPlacementStatus() == Instance::PlacementStatus::UNPLACED) if (instance->getClone(clone)->getPlacementStatus() == Instance::PlacementStatus::UNPLACED)
isPlaced = false; isPlaced = false;
} }
if (isPlaced) clone->setFlags( Flags::Placed ); if (isPlaced) clone->setFlags( Flags::Placed );

View File

@ -1653,7 +1653,7 @@ class Cell_SubCells : public Collection<Cell*> {
public: typedef Hurricane::Locator<Cell*> Inherit; public: typedef Hurricane::Locator<Cell*> Inherit;
private: set <Cell*> _cellSet; private: set<Cell*,Entity::CompareById> _cellSet;
private: InstanceLocator _instanceLocator; private: InstanceLocator _instanceLocator;
public: Locator(); public: Locator();

View File

@ -164,7 +164,7 @@ class Component_ConnexComponents : public Collection<Component*> {
public: typedef Hurricane::Locator<Component*> Inherit; public: typedef Hurricane::Locator<Component*> Inherit;
private: const Component* _component; private: const Component* _component;
private: set<Component*> _componentSet; private: set<Component*,Entity::CompareById> _componentSet;
private: stack<Component*> _componentStack; private: stack<Component*> _componentStack;
public: Locator(const Component* component = NULL); public: Locator(const Component* component = NULL);
@ -232,7 +232,7 @@ class Component_SlaveComponents : public Collection<Component*> {
public: typedef Hurricane::Locator<Component*> Inherit; public: typedef Hurricane::Locator<Component*> Inherit;
private: const Component* _component; private: const Component* _component;
private: set<Component*> _componentSet; private: set<Component*,Entity::CompareById> _componentSet;
private: stack<Component*> _componentStack; private: stack<Component*> _componentStack;
public: Locator(const Component* component = NULL); public: Locator(const Component* component = NULL);

View File

@ -88,8 +88,21 @@ bool Occurrence::operator!=(const Occurrence& occurrence) const
bool Occurrence::operator<(const Occurrence& occurrence) const bool Occurrence::operator<(const Occurrence& occurrence) const
// ******************************************************** // ********************************************************
{ {
return ((_entity < occurrence._entity) || if (not _entity and not occurrence._entity) return false;
((_entity == occurrence._entity) && (_sharedPath < occurrence._sharedPath))); if (not _entity) return true;
if (not occurrence._entity) return false;
if (_entity->getId() < occurrence._entity->getId()) return true;
if (_entity->getId() > occurrence._entity->getId()) return false;
if (not _sharedPath and not occurrence._sharedPath) return false;
if (not _sharedPath) return true;
if (not occurrence._sharedPath) return false;
return _sharedPath->getId() < occurrence._sharedPath->getId();
//return ((_entity < occurrence._entity) or
// ((_entity == occurrence._entity) and (_sharedPath < occurrence._sharedPath)));
} }
Cell* Occurrence::getOwnerCell() const Cell* Occurrence::getOwnerCell() const

View File

@ -69,7 +69,7 @@ void SharedName::release()
string SharedName::_getString() const string SharedName::_getString() const
// ********************************** // **********************************
{ {
return "<" + _TName("SharedName") + " " + getString(_count) + " " + _string + ">"; return "<" + _TName("SharedName") + " " + getString(_count) + " id:" + getString(_id) + " " + _string + ">";
} }
Record* SharedName::_getRecord() const Record* SharedName::_getRecord() const

View File

@ -132,17 +132,29 @@ template<class Key, class Element> class IntrusiveMap {
public: virtual void progress() public: virtual void progress()
// **************************** // ****************************
{ {
if (_element) { if (_element) {
_element = _map->_getNextElement(_element); cdebug_log(0,0) << "IntrusiveMap::progress() from:"
if (!_element) { << " -> " << tsetw(4) << _index
unsigned length = _map->_getLength(); << " + " << _map->_getHashValue(_map->_getKey(_element))
if (_index < length) { << "/" << _map->_getKey(_element) << ":" << _element << endl;
do {
_element = _map->_getArray()[_index++]; _element = _map->_getNextElement(_element);
} while (!_element && (_index < length)); if (!_element) {
} unsigned length = _map->_getLength();
} if (_index < length) {
do {
cdebug_log(0,0) << "next bucket: " << _index+1 << endl;
_element = _map->_getArray()[_index++];
} while (!_element && (_index < length));
}
if (_element)
cdebug_log(0,0) << "IntrusiveMap::progress() to:"
<< " -> " << tsetw(4) << _index
<< " + " << _map->_getHashValue(_map->_getKey(_element))
<< "/" << _map->_getKey(_element) << ":" << _element << endl;
} }
}
}; };
// Others // Others
@ -393,7 +405,7 @@ template<class Key, class Element> class IntrusiveMap {
public: void _remove(Element* element) public: void _remove(Element* element)
// *********************************** // ***********************************
{ {
if (_contains(element)) { if (_contains(element)) {
unsigned index = (_getHashValue(_getKey(element)) / 8) % _length; unsigned index = (_getHashValue(_getKey(element)) / 8) % _length;
Element* currentElement = _array[index]; Element* currentElement = _array[index];
if (currentElement) { if (currentElement) {
@ -418,32 +430,41 @@ template<class Key, class Element> class IntrusiveMap {
public: void _resize() public: void _resize()
// ******************* // *******************
{ {
unsigned newLength = _length; unsigned newLength = _length;
double ratio = (double)_size / (double)_length; double ratio = (double)_size / (double)_length;
if (ratio < 3) if (ratio < 3.0) newLength = max(_size / 8, (unsigned)1);
newLength = max(_size / 8, (unsigned)1); else if (ratio > 10.0) newLength = min(_size / 5, (unsigned)512);
else if (10 < ratio)
newLength = min(_size / 5, (unsigned)512);
if (newLength != _length) { if (newLength != _length) {
// cerr << "Resizing: " << this << " " << _length << " " << newLength << endl; cdebug_log(0,0) << "IntrusiveMap::_resize() " << _length << " -> " << newLength << endl;
unsigned oldLength = _length;
Element** oldArray = _array; unsigned oldLength = _length;
_length = newLength; Element** oldArray = _array;
_array = new Element*[_length]; _length = newLength;
memset(_array, 0, _length * sizeof(Element*)); _array = new Element* [_length];
for (unsigned index = 0; index < oldLength; index++) { memset( _array, 0, _length * sizeof(Element*) );
Element* element = oldArray[index];
while (element) { for ( unsigned index = 0; index < oldLength; ++index ) {
Element* nextElement = _getNextElement(element); Element* element = oldArray[index];
unsigned newIndex = (_getHashValue(_getKey(element)) / 8) % _length; if (not element)
_setNextElement(element, _array[newIndex]); cdebug_log(0,0) << "| entry:" << tsetw(4) << index << " empty" << endl;
_array[newIndex] = element;
element = nextElement; while ( element ) {
} Element* nextElement = _getNextElement(element);
} unsigned newIndex = (_getHashValue(_getKey(element)) / 8) % _length;
delete[] oldArray; _setNextElement(element, _array[newIndex]);
_array[ newIndex ] = element;
cdebug_log(0,0) << "| entry:" << tsetw(4) << index
<< " -> " << tsetw(4) << newIndex
<< " + " << _getHashValue(_getKey(element))
<< "/" << _getKey(element) << ":" << element << endl;
element = nextElement;
}
} }
delete [] oldArray;
}
}; };
}; };

View File

@ -444,11 +444,12 @@ template<class Element> class IntrusiveSet {
unsigned newIndex = (_getHashValue(element) / 8) % _length; unsigned newIndex = (_getHashValue(element) / 8) % _length;
_setNextElement(element, _array[newIndex]); _setNextElement(element, _array[newIndex]);
_array[newIndex] = element; _array[newIndex] = element;
element = nextElement;
cdebug_log(0,0) << "| bucket:" << tsetw(4) << index cdebug_log(0,0) << "| bucket:" << tsetw(4) << index
<< " -> " << tsetw(4) << newIndex << " -> " << tsetw(4) << newIndex
<< " + " << element << endl; << " + " << element << endl;
element = nextElement;
} }
} }
delete[] oldArray; delete[] oldArray;