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:
parent
2465d12c87
commit
6b4baad8b9
|
@ -120,9 +120,9 @@ namespace Vst {
|
|||
}
|
||||
|
||||
|
||||
typedef vector<Net*> PinVector;
|
||||
typedef map<Name,PinVector> VectorMap;
|
||||
typedef map<Cell*,VectorMap> CellVectorMap;
|
||||
typedef vector<Net*> PinVector;
|
||||
typedef map<Name,PinVector> VectorMap;
|
||||
typedef map<Cell*,VectorMap,Entity::CompareById> CellVectorMap;
|
||||
|
||||
|
||||
class YaccState {
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace CRL {
|
|||
|
||||
using namespace std;
|
||||
using Hurricane::ForEachIterator;
|
||||
using Hurricane::Entity;
|
||||
using Hurricane::Net;
|
||||
using Hurricane::Cell;
|
||||
using Hurricane::Instance;
|
||||
|
@ -109,16 +110,14 @@ namespace CRL {
|
|||
topCell->setName( converter(topCell->getName()) );
|
||||
|
||||
vector<Net*> nets;
|
||||
forEach ( Net*, inet, topCell->getNets() ) nets.push_back( *inet );
|
||||
for ( auto net : nets ) {
|
||||
net->setName( converter( net->getName() ) );
|
||||
}
|
||||
for ( Net* net : topCell->getNets() ) nets.push_back( net );
|
||||
for ( auto net : nets ) net->setName( converter( net->getName() ) );
|
||||
|
||||
vector<Instance*> instances;
|
||||
set<Cell*> models;
|
||||
forEach ( Instance*, iinst, topCell->getInstances() ) {
|
||||
instances.push_back( *iinst );
|
||||
models.insert( iinst->getMasterCell() );
|
||||
vector<Instance*> instances;
|
||||
set<Cell*,Entity::CompareById> models;
|
||||
for ( Instance* inst : topCell->getInstances() ) {
|
||||
instances.push_back( inst );
|
||||
models.insert( inst->getMasterCell() );
|
||||
}
|
||||
for ( auto inst : instances ) inst->setName( converter( inst->getName() ) );
|
||||
|
||||
|
|
|
@ -62,14 +62,14 @@ namespace CRL {
|
|||
if (not topCell) return;
|
||||
|
||||
vector<Net*> nets;
|
||||
forEach ( Net*, inet, topCell->getNets() ) nets.push_back( *inet );
|
||||
for ( auto net : nets ) net->setName( vlogToVhdl( inet->getName() ) );
|
||||
for ( Net* net : topCell->getNets() ) nets.push_back( net );
|
||||
for ( auto net : nets ) net->setName( vlogToVhdl( net->getName() ) );
|
||||
|
||||
vector<Instance*> instances;
|
||||
set<Cell*> models;
|
||||
forEach ( Instance*, iinst, topCell->getInstances() ) {
|
||||
instances.push_back( *iinst );
|
||||
models.insert( iinst->getMasterCell() );
|
||||
vector<Instance*> instances;
|
||||
set<Cell*,Entity::CompareById> models;
|
||||
for ( Instance* inst : topCell->getInstances() ) {
|
||||
instances.push_back( inst );
|
||||
models.insert( inst->getMasterCell() );
|
||||
}
|
||||
for ( auto inst : instances ) inst->setName( vlogToVhdl( inst->getName() ) );
|
||||
|
||||
|
|
|
@ -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() )
|
||||
return imaster->second;
|
||||
|
||||
|
@ -556,7 +556,7 @@ void ConnectPlugHooks(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 );
|
||||
}
|
||||
|
|
|
@ -996,8 +996,8 @@ Cell* Cell::getClone()
|
|||
}
|
||||
|
||||
bool isPlaced = true;
|
||||
for ( Instance* iinstance : getInstances() ) {
|
||||
if (iinstance->getClone(clone)->getPlacementStatus() == Instance::PlacementStatus::UNPLACED)
|
||||
for ( Instance* instance : getInstances() ) {
|
||||
if (instance->getClone(clone)->getPlacementStatus() == Instance::PlacementStatus::UNPLACED)
|
||||
isPlaced = false;
|
||||
}
|
||||
if (isPlaced) clone->setFlags( Flags::Placed );
|
||||
|
|
|
@ -1653,7 +1653,7 @@ class Cell_SubCells : public Collection<Cell*> {
|
|||
|
||||
public: typedef Hurricane::Locator<Cell*> Inherit;
|
||||
|
||||
private: set <Cell*> _cellSet;
|
||||
private: set<Cell*,Entity::CompareById> _cellSet;
|
||||
private: InstanceLocator _instanceLocator;
|
||||
|
||||
public: Locator();
|
||||
|
|
|
@ -164,7 +164,7 @@ class Component_ConnexComponents : public Collection<Component*> {
|
|||
public: typedef Hurricane::Locator<Component*> Inherit;
|
||||
|
||||
private: const Component* _component;
|
||||
private: set<Component*> _componentSet;
|
||||
private: set<Component*,Entity::CompareById> _componentSet;
|
||||
private: stack<Component*> _componentStack;
|
||||
|
||||
public: Locator(const Component* component = NULL);
|
||||
|
@ -232,7 +232,7 @@ class Component_SlaveComponents : public Collection<Component*> {
|
|||
public: typedef Hurricane::Locator<Component*> Inherit;
|
||||
|
||||
private: const Component* _component;
|
||||
private: set<Component*> _componentSet;
|
||||
private: set<Component*,Entity::CompareById> _componentSet;
|
||||
private: stack<Component*> _componentStack;
|
||||
|
||||
public: Locator(const Component* component = NULL);
|
||||
|
|
|
@ -88,8 +88,21 @@ bool Occurrence::operator!=(const Occurrence& occurrence) const
|
|||
bool Occurrence::operator<(const Occurrence& occurrence) const
|
||||
// ********************************************************
|
||||
{
|
||||
return ((_entity < occurrence._entity) ||
|
||||
((_entity == occurrence._entity) && (_sharedPath < occurrence._sharedPath)));
|
||||
if (not _entity and not occurrence._entity) return false;
|
||||
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
|
||||
|
|
|
@ -69,7 +69,7 @@ void SharedName::release()
|
|||
string SharedName::_getString() const
|
||||
// **********************************
|
||||
{
|
||||
return "<" + _TName("SharedName") + " " + getString(_count) + " " + _string + ">";
|
||||
return "<" + _TName("SharedName") + " " + getString(_count) + " id:" + getString(_id) + " " + _string + ">";
|
||||
}
|
||||
|
||||
Record* SharedName::_getRecord() const
|
||||
|
|
|
@ -132,17 +132,29 @@ template<class Key, class Element> class IntrusiveMap {
|
|||
public: virtual void progress()
|
||||
// ****************************
|
||||
{
|
||||
if (_element) {
|
||||
_element = _map->_getNextElement(_element);
|
||||
if (!_element) {
|
||||
unsigned length = _map->_getLength();
|
||||
if (_index < length) {
|
||||
do {
|
||||
_element = _map->_getArray()[_index++];
|
||||
} while (!_element && (_index < length));
|
||||
}
|
||||
}
|
||||
if (_element) {
|
||||
cdebug_log(0,0) << "IntrusiveMap::progress() from:"
|
||||
<< " -> " << tsetw(4) << _index
|
||||
<< " + " << _map->_getHashValue(_map->_getKey(_element))
|
||||
<< "/" << _map->_getKey(_element) << ":" << _element << endl;
|
||||
|
||||
_element = _map->_getNextElement(_element);
|
||||
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
|
||||
|
@ -393,7 +405,7 @@ template<class Key, class Element> class IntrusiveMap {
|
|||
public: void _remove(Element* element)
|
||||
// ***********************************
|
||||
{
|
||||
if (_contains(element)) {
|
||||
if (_contains(element)) {
|
||||
unsigned index = (_getHashValue(_getKey(element)) / 8) % _length;
|
||||
Element* currentElement = _array[index];
|
||||
if (currentElement) {
|
||||
|
@ -418,32 +430,41 @@ template<class Key, class Element> class IntrusiveMap {
|
|||
public: void _resize()
|
||||
// *******************
|
||||
{
|
||||
unsigned newLength = _length;
|
||||
double ratio = (double)_size / (double)_length;
|
||||
if (ratio < 3)
|
||||
newLength = max(_size / 8, (unsigned)1);
|
||||
else if (10 < ratio)
|
||||
newLength = min(_size / 5, (unsigned)512);
|
||||
unsigned newLength = _length;
|
||||
double ratio = (double)_size / (double)_length;
|
||||
if (ratio < 3.0) newLength = max(_size / 8, (unsigned)1);
|
||||
else if (ratio > 10.0) newLength = min(_size / 5, (unsigned)512);
|
||||
|
||||
if (newLength != _length) {
|
||||
// cerr << "Resizing: " << this << " " << _length << " " << newLength << endl;
|
||||
unsigned oldLength = _length;
|
||||
Element** oldArray = _array;
|
||||
_length = newLength;
|
||||
_array = new Element*[_length];
|
||||
memset(_array, 0, _length * sizeof(Element*));
|
||||
for (unsigned index = 0; index < oldLength; index++) {
|
||||
Element* element = oldArray[index];
|
||||
while (element) {
|
||||
Element* nextElement = _getNextElement(element);
|
||||
unsigned newIndex = (_getHashValue(_getKey(element)) / 8) % _length;
|
||||
_setNextElement(element, _array[newIndex]);
|
||||
_array[newIndex] = element;
|
||||
element = nextElement;
|
||||
}
|
||||
}
|
||||
delete[] oldArray;
|
||||
if (newLength != _length) {
|
||||
cdebug_log(0,0) << "IntrusiveMap::_resize() " << _length << " -> " << newLength << endl;
|
||||
|
||||
unsigned oldLength = _length;
|
||||
Element** oldArray = _array;
|
||||
_length = newLength;
|
||||
_array = new Element* [_length];
|
||||
memset( _array, 0, _length * sizeof(Element*) );
|
||||
|
||||
for ( unsigned index = 0; index < oldLength; ++index ) {
|
||||
Element* element = oldArray[index];
|
||||
if (not element)
|
||||
cdebug_log(0,0) << "| entry:" << tsetw(4) << index << " empty" << endl;
|
||||
|
||||
while ( element ) {
|
||||
Element* nextElement = _getNextElement(element);
|
||||
unsigned newIndex = (_getHashValue(_getKey(element)) / 8) % _length;
|
||||
_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;
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
@ -444,11 +444,12 @@ template<class Element> class IntrusiveSet {
|
|||
unsigned newIndex = (_getHashValue(element) / 8) % _length;
|
||||
_setNextElement(element, _array[newIndex]);
|
||||
_array[newIndex] = element;
|
||||
element = nextElement;
|
||||
|
||||
cdebug_log(0,0) << "| bucket:" << tsetw(4) << index
|
||||
<< " -> " << tsetw(4) << newIndex
|
||||
<< " + " << element << endl;
|
||||
|
||||
element = nextElement;
|
||||
}
|
||||
}
|
||||
delete[] oldArray;
|
||||
|
|
Loading…
Reference in New Issue