mfsMan.c 6.76 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8
/**CFile****************************************************************

  FileName    [mfsMan.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [The good old minimization with complete don't-cares.]

Alan Mishchenko committed
9
  Synopsis    [Procedures working with the manager.]
Alan Mishchenko committed
10 11 12 13 14 15 16 17 18 19 20 21 22

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - June 20, 2005.]

  Revision    [$Id: mfsMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]

***********************************************************************/

#include "mfsInt.h"

23 24 25
ABC_NAMESPACE_IMPL_START


Alan Mishchenko committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
45
Mfs_Man_t * Mfs_ManAlloc( Mfs_Par_t * pPars )
Alan Mishchenko committed
46 47 48
{
    Mfs_Man_t * p;
    // start the manager
Alan Mishchenko committed
49
    p = ABC_ALLOC( Mfs_Man_t, 1 );
Alan Mishchenko committed
50
    memset( p, 0, sizeof(Mfs_Man_t) );
Alan Mishchenko committed
51
    p->pPars     = pPars;
52 53
    p->vProjVarsCnf = Vec_IntAlloc( 100 );
    p->vProjVarsSat = Vec_IntAlloc( 100 );
Alan Mishchenko committed
54
    p->vDivLits  = Vec_IntAlloc( 100 );
55 56
    p->nDivWords = Abc_BitWordNum(p->pPars->nWinMax + MFS_FANIN_MAX);
    p->vDivCexes = Vec_PtrAllocSimInfo( p->pPars->nWinMax + MFS_FANIN_MAX + 1, p->nDivWords );
Alan Mishchenko committed
57 58 59
    p->pMan      = Int_ManAlloc();
    p->vMem      = Vec_IntAlloc( 0 );
    p->vLevels   = Vec_VecStart( 32 );
60
    p->vMfsFanins= Vec_PtrAlloc( 32 );
Alan Mishchenko committed
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
    return p;
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Mfs_ManClean( Mfs_Man_t * p )
{
    if ( p->pAigWin )
        Aig_ManStop( p->pAigWin );
    if ( p->pCnf )
        Cnf_DataFree( p->pCnf );
    if ( p->pSat )
        sat_solver_delete( p->pSat );
    if ( p->vRoots )
        Vec_PtrFree( p->vRoots );
    if ( p->vSupp )
        Vec_PtrFree( p->vSupp );
    if ( p->vNodes )
        Vec_PtrFree( p->vNodes );
Alan Mishchenko committed
89 90
    if ( p->vDivs )
        Vec_PtrFree( p->vDivs );
Alan Mishchenko committed
91
    p->pAigWin = NULL;
Alan Mishchenko committed
92 93 94 95 96 97
    p->pCnf    = NULL;
    p->pSat    = NULL;
    p->vRoots  = NULL;
    p->vSupp   = NULL;
    p->vNodes  = NULL;
    p->vDivs   = NULL;
Alan Mishchenko committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Mfs_ManPrint( Mfs_Man_t * p )
{
Alan Mishchenko committed
113 114
    if ( p->pPars->fResub )
    {
115 116
        printf( "Nodes = %d. Try = %d. Resub = %d. Div = %d. SAT calls = %d. Timeouts = %d. MaxDivs = %d.\n",
            p->nTotalNodesBeg, p->nNodesTried, p->nNodesResub, p->nTotalDivs, p->nSatCalls, p->nTimeOuts, p->nMaxDivs );
Alan Mishchenko committed
117 118 119 120 121 122 123

        printf( "Attempts :   " );
        printf( "Remove %6d out of %6d (%6.2f %%)   ", p->nRemoves, p->nTryRemoves, 100.0*p->nRemoves/Abc_MaxInt(1, p->nTryRemoves) );
        printf( "Resub  %6d out of %6d (%6.2f %%)   ", p->nResubs,  p->nTryResubs,  100.0*p->nResubs /Abc_MaxInt(1, p->nTryResubs)  );
        printf( "\n" );

        printf( "Reduction:   " );
Alan Mishchenko committed
124 125
        printf( "Nodes  %6d out of %6d (%6.2f %%)   ", p->nTotalNodesBeg-p->nTotalNodesEnd, p->nTotalNodesBeg, 100.0*(p->nTotalNodesBeg-p->nTotalNodesEnd)/Abc_MaxInt(1, p->nTotalNodesBeg) );
        printf( "Edges  %6d out of %6d (%6.2f %%)   ", p->nTotalEdgesBeg-p->nTotalEdgesEnd, p->nTotalEdgesBeg, 100.0*(p->nTotalEdgesBeg-p->nTotalEdgesEnd)/Abc_MaxInt(1, p->nTotalEdgesBeg) );
Alan Mishchenko committed
126 127
        printf( "\n" );

Alan Mishchenko committed
128
        if (p->pPars->fPower)
Alan Mishchenko committed
129
            printf( "Power( %5.2f, %4.2f%%) \n",
Alan Mishchenko committed
130 131 132 133 134 135
                 p->TotalSwitchingBeg - p->TotalSwitchingEnd,
                 100.0*(p->TotalSwitchingBeg-p->TotalSwitchingEnd)/p->TotalSwitchingBeg );
        if ( p->pPars->fSwapEdge )
            printf( "Swappable edges = %d. Total edges = %d. Ratio = %5.2f.\n",
                p->nNodesResub, Abc_NtkGetTotalFanins(p->pNtk), 1.00 * p->nNodesResub / Abc_NtkGetTotalFanins(p->pNtk) );
//        printf( "Average ratio of DCs in the resubed nodes = %.2f.\n", 1.0*p->nDcMints/(64 * p->nNodesResub) );
Alan Mishchenko committed
136 137 138
    }
    else
    {
Alan Mishchenko committed
139
        printf( "Nodes = %d. Try = %d. Total mints = %d. Local DC mints = %d. Ratio = %5.2f.\n", 
Alan Mishchenko committed
140
            p->nTotalNodesBeg, p->nNodesTried, p->nMintsTotal, p->nMintsTotal-p->nMintsCare, 
Alan Mishchenko committed
141 142 143
            1.0 * (p->nMintsTotal-p->nMintsCare) / p->nMintsTotal );
//        printf( "Average ratio of sequential DCs in the global space = %5.2f.\n", 
//            1.0-(p->dTotalRatios/p->nNodesTried) );
Alan Mishchenko committed
144 145
        printf( "Nodes resyn = %d. Ratio = %5.2f.  Total AIG node gain = %d. Timeouts = %d.\n", 
            p->nNodesDec, 1.0 * p->nNodesDec / p->nNodesTried, p->nNodesGained, p->nTimeOuts );
Alan Mishchenko committed
146
    }
Alan Mishchenko committed
147

Alan Mishchenko committed
148 149 150
    ABC_PRTP( "Win", p->timeWin            ,  p->timeTotal );
    ABC_PRTP( "Div", p->timeDiv            ,  p->timeTotal );
    ABC_PRTP( "Aig", p->timeAig            ,  p->timeTotal );
Alan Mishchenko committed
151
    ABC_PRTP( "Gia", p->timeGia            ,  p->timeTotal );
Alan Mishchenko committed
152 153 154 155
    ABC_PRTP( "Cnf", p->timeCnf            ,  p->timeTotal );
    ABC_PRTP( "Sat", p->timeSat-p->timeInt ,  p->timeTotal );
    ABC_PRTP( "Int", p->timeInt            ,  p->timeTotal );
    ABC_PRTP( "ALL", p->timeTotal          ,  p->timeTotal );
Alan Mishchenko committed
156

Alan Mishchenko committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
}

/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Mfs_ManStop( Mfs_Man_t * p )
{
Alan Mishchenko committed
172 173
    if ( p->pPars->fVerbose )
        Mfs_ManPrint( p );
Alan Mishchenko committed
174 175 176 177
    if ( p->vTruth )
        Vec_IntFree( p->vTruth );
    if ( p->pManDec )
        Bdc_ManFree( p->pManDec );
Alan Mishchenko committed
178 179
    if ( p->pCare )
        Aig_ManStop( p->pCare );
Alan Mishchenko committed
180 181
    if ( p->vSuppsInv )
        Vec_VecFree( (Vec_Vec_t *)p->vSuppsInv );
Alan Mishchenko committed
182 183
    if ( p->vProbs )
        Vec_IntFree( p->vProbs );
Alan Mishchenko committed
184
    Mfs_ManClean( p );
Alan Mishchenko committed
185 186 187
    Int_ManFree( p->pMan );
    Vec_IntFree( p->vMem );
    Vec_VecFree( p->vLevels );
188 189 190
    Vec_PtrFree( p->vMfsFanins );
    Vec_IntFree( p->vProjVarsCnf );
    Vec_IntFree( p->vProjVarsSat );
Alan Mishchenko committed
191 192
    Vec_IntFree( p->vDivLits );
    Vec_PtrFree( p->vDivCexes );
Alan Mishchenko committed
193
    ABC_FREE( p );
Alan Mishchenko committed
194 195 196 197 198 199 200
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


201 202
ABC_NAMESPACE_IMPL_END