diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-03-23 16:52:40 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-03-23 16:52:40 -0700 |
commit | 6f17c44e9167f810d6f7f03582f2f132464115d5 (patch) | |
tree | dd3205f236474b69407e1e7b0118f4ef4567c9ac /src/map/mapper/mapperRefs.c | |
parent | f6eb5262a3176a97f4063f1c49a7d56545fcd53e (diff) | |
download | abc-6f17c44e9167f810d6f7f03582f2f132464115d5.tar.gz abc-6f17c44e9167f810d6f7f03582f2f132464115d5.tar.bz2 abc-6f17c44e9167f810d6f7f03582f2f132464115d5.zip |
Integrating barrier buffers into the mapper.
Diffstat (limited to 'src/map/mapper/mapperRefs.c')
-rw-r--r-- | src/map/mapper/mapperRefs.c | 247 |
1 files changed, 102 insertions, 145 deletions
diff --git a/src/map/mapper/mapperRefs.c b/src/map/mapper/mapperRefs.c index 9b0be068..6d6ff121 100644 --- a/src/map/mapper/mapperRefs.c +++ b/src/map/mapper/mapperRefs.c @@ -25,11 +25,6 @@ ABC_NAMESPACE_IMPL_START /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -static int Map_NodeIncRefPhaseAct( Map_Node_t * pNode, int fPhase ); -static int Map_NodeDecRefPhaseAct( Map_Node_t * pNode, int fPhase ); -static float Map_CutRefDeref( Map_Cut_t * pCut, int fPhase, int fReference ); -static void Map_MappingSetRefs_rec( Map_Man_t * pMan, Map_Node_t * pNode, Map_Node_t ** ppStore ); - //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -132,9 +127,9 @@ void Map_MappingEstimateRefsInit( Map_Man_t * p ) { Map_Node_t * pNode; int i; - for ( i = 0; i < p->vAnds->nSize; i++ ) + for ( i = 0; i < p->vMapObjs->nSize; i++ ) { - pNode = p->vAnds->pArray[i]; + pNode = p->vMapObjs->pArray[i]; // pNode->nRefEst[0] = pNode->nRefEst[1] = ((float)pNode->nRefs)*(float)2.0; pNode->nRefEst[0] = pNode->nRefEst[1] = pNode->nRefEst[2] = ((float)pNode->nRefs); } @@ -157,9 +152,9 @@ void Map_MappingEstimateRefs( Map_Man_t * p ) { Map_Node_t * pNode; int i; - for ( i = 0; i < p->vAnds->nSize; i++ ) + for ( i = 0; i < p->vMapObjs->nSize; i++ ) { - pNode = p->vAnds->pArray[i]; + pNode = p->vMapObjs->pArray[i]; // pNode->nRefEst[0] = (float)((2.0 * pNode->nRefEst[0] + 1.0 * pNode->nRefAct[0]) / 3.0); // pNode->nRefEst[1] = (float)((2.0 * pNode->nRefEst[1] + 1.0 * pNode->nRefAct[1]) / 3.0); // pNode->nRefEst[2] = (float)((2.0 * pNode->nRefEst[2] + 1.0 * pNode->nRefAct[2]) / 3.0); @@ -169,10 +164,6 @@ void Map_MappingEstimateRefs( Map_Man_t * p ) } } - - - - /**function************************************************************* synopsis [Computes the area flow of the cut.] @@ -223,79 +214,6 @@ float Map_CutGetAreaFlow( Map_Cut_t * pCut, int fPhase ) } - -/**function************************************************************* - - synopsis [Computes the exact area associated with the cut.] - - description [Assumes that the cut is referenced.] - - sideeffects [] - - seealso [] - -***********************************************************************/ -float Map_CutGetAreaRefed( Map_Cut_t * pCut, int fPhase ) -{ - float aResult, aResult2; - aResult2 = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference - aResult = Map_CutRefDeref( pCut, fPhase, 1 ); // reference -// assert( aResult == aResult2 ); - return aResult; -} - -/**function************************************************************* - - synopsis [Computes the exact area associated with the cut.] - - description [] - - sideeffects [] - - seealso [] - -***********************************************************************/ -float Map_CutGetAreaDerefed( Map_Cut_t * pCut, int fPhase ) -{ - float aResult, aResult2; - aResult2 = Map_CutRefDeref( pCut, fPhase, 1 ); // reference - aResult = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference -// assert( aResult == aResult2 ); - return aResult; -} - -/**function************************************************************* - - synopsis [References the cut.] - - description [] - - sideeffects [] - - seealso [] - -***********************************************************************/ -float Map_CutRef( Map_Cut_t * pCut, int fPhase ) -{ - return Map_CutRefDeref( pCut, fPhase, 1 ); // reference -} - -/**function************************************************************* - - synopsis [Dereferences the cut.] - - description [] - - sideeffects [] - - seealso [] - -***********************************************************************/ -float Map_CutDeref( Map_Cut_t * pCut, int fPhase ) -{ - return Map_CutRefDeref( pCut, fPhase, 0 ); // dereference -} - /**function************************************************************* synopsis [References or dereferences the cut.] @@ -396,98 +314,115 @@ float Map_CutRefDeref( Map_Cut_t * pCut, int fPhase, int fReference ) return aArea; } +/**function************************************************************* + synopsis [Computes the exact area associated with the cut.] + description [Assumes that the cut is referenced.] + + sideeffects [] -/**Function************************************************************* + seealso [] - Synopsis [Computes actual reference counters.] +***********************************************************************/ +float Map_CutGetAreaRefed( Map_Cut_t * pCut, int fPhase ) +{ + float aResult, aResult2; + aResult2 = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference + aResult = Map_CutRefDeref( pCut, fPhase, 1 ); // reference +// assert( aResult == aResult2 ); + return aResult; +} - Description [Collects the nodes used in the mapping in array pMan->vMapping. - Nodes are collected in reverse topological order to facilitate the - computation of required times.] +/**function************************************************************* + + synopsis [Computes the exact area associated with the cut.] + + description [] - SideEffects [] + sideeffects [] - SeeAlso [] + seealso [] ***********************************************************************/ -void Map_MappingSetRefs( Map_Man_t * pMan ) +float Map_CutGetAreaDerefed( Map_Cut_t * pCut, int fPhase ) { - Map_Node_t * pNode, ** ppStore; - int i, fPhase, LevelMax; + float aResult, aResult2; + aResult2 = Map_CutRefDeref( pCut, fPhase, 1 ); // reference + aResult = Map_CutRefDeref( pCut, fPhase, 0 ); // dereference +// assert( aResult == aResult2 ); + return aResult; +} - // clean all references - for ( i = 0; i < pMan->vNodesAll->nSize; i++ ) - { - pNode = pMan->vNodesAll->pArray[i]; - pNode->nRefAct[0] = 0; - pNode->nRefAct[1] = 0; - pNode->nRefAct[2] = 0; - } +/**function************************************************************* - // find the largest level of a node - LevelMax = 0; - for ( i = 0; i < pMan->nOutputs; i++ ) - if ( LevelMax < (int)Map_Regular(pMan->pOutputs[i])->Level ) - LevelMax = Map_Regular(pMan->pOutputs[i])->Level; + synopsis [References the cut.] - // allocate place to store the nodes - ppStore = ABC_ALLOC( Map_Node_t *, LevelMax + 1 ); - memset( ppStore, 0, sizeof(Map_Node_t *) * (LevelMax + 1) ); + description [] + + sideeffects [] - // visit nodes reachable from POs in the DFS order through the best cuts - for ( i = 0; i < pMan->nOutputs; i++ ) - { - pNode = pMan->pOutputs[i]; - fPhase = !Map_IsComplement(pNode); - if ( !Map_NodeIsConst(pNode) ) - Map_MappingSetRefs_rec( pMan, pNode, ppStore ); - } + seealso [] - // reconnect the nodes in reverse topological order - pMan->vMapping->nSize = 0; - for ( i = LevelMax; i >= 0; i-- ) - for ( pNode = ppStore[i]; pNode; pNode = (Map_Node_t *)pNode->pData0 ) - Map_NodeVecPush( pMan->vMapping, pNode ); - ABC_FREE( ppStore ); +***********************************************************************/ +float Map_CutRef( Map_Cut_t * pCut, int fPhase ) +{ + return Map_CutRefDeref( pCut, fPhase, 1 ); // reference } +/**function************************************************************* + + synopsis [Dereferences the cut.] + + description [] + + sideeffects [] + + seealso [] + +***********************************************************************/ +float Map_CutDeref( Map_Cut_t * pCut, int fPhase ) +{ + return Map_CutRefDeref( pCut, fPhase, 0 ); // dereference +} + + /**Function************************************************************* - Synopsis [Recursively computes the DFS ordering of the nodes.] + Synopsis [Computes actual reference counters.] - Description [] + Description [Collects the nodes used in the mapping in array pMan->vMapping. + Nodes are collected in reverse topological order to facilitate the + computation of required times.] SideEffects [] SeeAlso [] ***********************************************************************/ -void Map_MappingSetRefs_rec( Map_Man_t * pMan, Map_Node_t * pNode, Map_Node_t ** ppStore ) +void Map_MappingSetRefs_rec( Map_Man_t * pMan, Map_Node_t * pNode ) { Map_Cut_t * pCut; Map_Node_t * pNodeR; unsigned uPhase; int i, fPhase, fInvPin; - // get the regular node and its phase pNodeR = Map_Regular(pNode); fPhase = !Map_IsComplement(pNode); - - // add the node to the list of all visited nodes - if ( pNodeR->nRefAct[2]++ == 0 ) -// Map_NodeVecPush( pMan->vMapping, pNodeR ); - pNodeR->pData0 = (char *)ppStore[pNodeR->Level], ppStore[pNodeR->Level] = pNodeR; - + pNodeR->nRefAct[2]++; // quit if the node was already visited in this phase if ( pNodeR->nRefAct[fPhase]++ ) return; - // quit if this is a PI node if ( Map_NodeIsVar(pNodeR) ) return; - + // propagate through buffer + if ( Map_NodeIsBuf(pNodeR) ) + { + Map_MappingSetRefs_rec( pMan, Map_NotCond(pNodeR->p1, Map_IsComplement(pNode)) ); + return; + } + assert( Map_NodeIsAnd(pNode) ); // get the cut implementing this or opposite polarity pCut = pNodeR->pCutBest[fPhase]; if ( pCut == NULL ) @@ -495,13 +430,32 @@ void Map_MappingSetRefs_rec( Map_Man_t * pMan, Map_Node_t * pNode, Map_Node_t ** fPhase = !fPhase; pCut = pNodeR->pCutBest[fPhase]; } - // visit the transitive fanin uPhase = pCut->M[fPhase].uPhaseBest; for ( i = 0; i < pCut->nLeaves; i++ ) { fInvPin = ((uPhase & (1 << i)) > 0); - Map_MappingSetRefs_rec( pMan, Map_NotCond(pCut->ppLeaves[i], fInvPin), ppStore ); + Map_MappingSetRefs_rec( pMan, Map_NotCond(pCut->ppLeaves[i], fInvPin) ); + } +} +void Map_MappingSetRefs( Map_Man_t * pMan ) +{ + Map_Node_t * pNode; + int i; + // clean all references + for ( i = 0; i < pMan->vMapObjs->nSize; i++ ) + { + pNode = pMan->vMapObjs->pArray[i]; + pNode->nRefAct[0] = 0; + pNode->nRefAct[1] = 0; + pNode->nRefAct[2] = 0; + } + // visit nodes reachable from POs in the DFS order through the best cuts + for ( i = 0; i < pMan->nOutputs; i++ ) + { + pNode = pMan->pOutputs[i]; + if ( !Map_NodeIsConst(pNode) ) + Map_MappingSetRefs_rec( pMan, pNode ); } } @@ -517,15 +471,18 @@ void Map_MappingSetRefs_rec( Map_Man_t * pMan, Map_Node_t * pNode, Map_Node_t ** SeeAlso [] ***********************************************************************/ -float Map_MappingGetArea( Map_Man_t * pMan, Map_NodeVec_t * vMapping ) +float Map_MappingGetArea( Map_Man_t * pMan ) { Map_Node_t * pNode; - float Area; + float Area = 0.0; int i; - Area = 0.0; - for ( i = 0; i < vMapping->nSize; i++ ) + for ( i = 0; i < pMan->vMapObjs->nSize; i++ ) { - pNode = vMapping->pArray[i]; + pNode = pMan->vMapObjs->pArray[i]; + if ( pNode->nRefAct[2] == 0 ) + continue; + if ( Map_NodeIsBuf(pNode) ) + continue; // at least one phase has the best cut assigned assert( pNode->pCutBest[0] != NULL || pNode->pCutBest[1] != NULL ); // at least one phase is used in the mapping |