Optimize Cell::getDeeNet() to fix the slow-down in PowerRails.

* New: In DeepNet, add an DeepNet::Uplink property on the HyperNet
    root net Occurrence so we have a direct two-way link between
    the top (flattened net) and the root of the HyperNet.
      Down link is ensured by the Occurrence, up link by the Uplink
    property.
* Change: In Cell::getDeepNet(), now use the DeepNet Uplink property
    instead of looping over *all* top nets. This was the cause of the
    terrific slow down in PowerRails, especially on flatteneds designs.
This commit is contained in:
Jean-Paul Chaput 2021-11-25 10:49:45 +01:00
parent ca499e024c
commit 966a25181f
3 changed files with 92 additions and 16 deletions

View File

@ -799,17 +799,10 @@ DeepNet* Cell::getDeepNet ( Path path, const Net* leafNet ) const
if (not (_flags.isset(Flags::FlattenedNets))) return NULL;
Occurrence rootNetOccurrence ( getHyperNetRootNetOccurrence(Occurrence(leafNet,path)) );
forEach ( Net*, inet, getNets() ) {
DeepNet* deepNet = dynamic_cast<DeepNet*>( *inet );
if (not deepNet) continue;
Occurrence deepNetOccurrence = deepNet->getRootNetOccurrence();
if ( (rootNetOccurrence.getEntity() == deepNetOccurrence.getEntity())
and (rootNetOccurrence.getPath () == deepNetOccurrence.getPath ()) )
return deepNet;
}
return NULL;
DeepNet::Uplink* uplink = static_cast<DeepNet::Uplink*>
( rootNetOccurrence.getProperty( DeepNet::Uplink::staticGetName() ));
if (not uplink) return NULL;
return uplink->getUplink();
}
void Cell::flattenNets (uint64_t flags )

View File

@ -57,6 +57,7 @@ namespace Hurricane {
, _netOccurrence(netOccurrence)
{
cdebug_log(18,0) << "DeepNet::DeepNet() " << getCell() << " " << this << endl;
_netOccurrence.put( Uplink::create(this) );
}
@ -83,6 +84,14 @@ namespace Hurricane {
}
void DeepNet::_preDestroy ()
{
_netOccurrence.removeProperty( Uplink::staticGetName() );
Inherit::_preDestroy();
}
size_t DeepNet::_createRoutingPads ( unsigned int flags )
{
cdebug_log(18,1) << "DeepNet::_createRoutingPads(): " << this << endl;
@ -207,4 +216,55 @@ namespace Hurricane {
}
// -------------------------------------------------------------------
// Class : "Uplink"
Name DeepNet::Uplink::_name = "DeepNet::Uplink";
DeepNet::Uplink* DeepNet::Uplink::create ( DeepNet* uplink )
{
Uplink *property = new Uplink( uplink );
property->_postCreate ();
return property;
}
void DeepNet::Uplink::onReleasedBy ( DBo* owner )
{ PrivateProperty::onReleasedBy( owner ); }
Name DeepNet::Uplink::getPropertyName ()
{ return _name; }
Name DeepNet::Uplink::getName () const
{ return getPropertyName(); }
string DeepNet::Uplink::_getTypeName () const
{ return _TName( "DeepNet::Uplink" ); }
string DeepNet::Uplink::_getString () const
{
string s = PrivateProperty::_getString ();
s.insert ( s.length() - 1 , " " + getString(_uplink) );
return s;
}
Record* DeepNet::Uplink::_getRecord () const
{
Record* record = PrivateProperty::_getRecord();
if (record) {
record->add( getSlot( "_name" , _name ) );
record->add( getSlot( "_uplink", _uplink ) );
}
return record;
}
} // End of Hurricane namespace.

View File

@ -29,9 +29,8 @@
// +-----------------------------------------------------------------+
#ifndef HURRICANE_DEEPNET_H
#define HURRICANE_DEEPNET_H
#pragma once
#include "hurricane/Property.h"
#include "hurricane/Net.h"
#include "hurricane/HyperNet.h"
#include "hurricane/Occurrence.h"
@ -45,6 +44,23 @@ namespace Hurricane {
class DeepNet : public Net {
public:
typedef Net Inherit;
public:
class Uplink : public Hurricane::PrivateProperty {
static Name _name;
public:
static Uplink* create ( DeepNet* uplink );
static Name getPropertyName ();
virtual Name getName () const;
inline DeepNet* getUplink ();
virtual void onReleasedBy ( DBo* owner );
virtual std::string _getTypeName () const;
virtual std::string _getString () const;
virtual Record* _getRecord () const;
protected:
DeepNet* _uplink;
protected:
inline Uplink ( DeepNet* uplink );
};
public:
static DeepNet* create ( HyperNet& hyperNet );
inline Occurrence getRootNetOccurrence () const;
@ -55,6 +71,7 @@ namespace Hurricane {
virtual void _toJson ( JsonWriter* ) const;
protected:
DeepNet ( Occurrence& netOccurrence );
virtual void _preDestroy ();
protected:
Occurrence _netOccurrence;
@ -66,6 +83,14 @@ namespace Hurricane {
Net* getDeepNet(HyperNet& hyperNet);
inline DeepNet::Uplink::Uplink ( DeepNet* uplink )
: PrivateProperty(), _uplink(uplink)
{ }
inline DeepNet* DeepNet::Uplink::getUplink () { return _uplink; }
// -------------------------------------------------------------------
// Class : "JsonDeepNet".
@ -83,5 +108,3 @@ namespace Hurricane {
} // Hurricane namespace.
INSPECTOR_P_SUPPORT(Hurricane::DeepNet);
#endif