darMan.c 5.07 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**CFile****************************************************************

  FileName    [darMan.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [DAG-aware AIG rewriting.]

  Synopsis    [AIG manager.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - April 28, 2007.]

  Revision    [$Id: darMan.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]

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

Alan Mishchenko committed
21
#include "darInt.h"
Alan Mishchenko committed
22

23 24
ABC_NAMESPACE_IMPL_START

Alan Mishchenko committed
25 26 27 28 29 30 31 32 33 34
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

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

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

Alan Mishchenko committed
35
  Synopsis    [Starts the rewriting manager.]
Alan Mishchenko committed
36

Alan Mishchenko committed
37
  Description []
Alan Mishchenko committed
38 39 40 41 42 43
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
44
Dar_Man_t * Dar_ManStart( Aig_Man_t * pAig, Dar_RwrPar_t * pPars )
Alan Mishchenko committed
45 46
{
    Dar_Man_t * p;
Alan Mishchenko committed
47 48
    Aig_ManCleanData( pAig );
    p = ABC_ALLOC( Dar_Man_t, 1 );
Alan Mishchenko committed
49
    memset( p, 0, sizeof(Dar_Man_t) );
Alan Mishchenko committed
50 51
    p->pPars = pPars;
    p->pAig  = pAig;
Alan Mishchenko committed
52
    p->vCutNodes = Vec_PtrAlloc( 1000 );
Alan Mishchenko committed
53
    p->pMemCuts = Aig_MmFixedStart( p->pPars->nCutsMax * sizeof(Dar_Cut_t), 1024 );
Alan Mishchenko committed
54 55 56 57 58 59
    p->vLeavesBest = Vec_PtrAlloc( 4 );
    return p;
}

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

Alan Mishchenko committed
60
  Synopsis    [Stops the rewriting manager.]
Alan Mishchenko committed
61 62 63 64 65 66 67 68 69 70

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Dar_ManStop( Dar_Man_t * p )
{
Alan Mishchenko committed
71 72
    if ( p->pPars->fVerbose )
        Dar_ManPrintStats( p );
Alan Mishchenko committed
73 74
    if ( p->vCutNodes )
        Vec_PtrFree( p->vCutNodes );
Alan Mishchenko committed
75 76 77 78
    if ( p->pMemCuts )
        Aig_MmFixedStop( p->pMemCuts, 0 );
    if ( p->vLeavesBest ) 
        Vec_PtrFree( p->vLeavesBest );
Alan Mishchenko committed
79
    ABC_FREE( p );
Alan Mishchenko committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
}

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

  Synopsis    [Stops the AIG manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Dar_ManPrintStats( Dar_Man_t * p )
{
Alan Mishchenko committed
95 96 97 98
    unsigned pCanons[222];
    int Gain, i;
    extern void Kit_DsdPrintFromTruth( unsigned * pTruth, int nVars );

Alan Mishchenko committed
99
    Gain = p->nNodesInit - Aig_ManNodeNum(p->pAig);
100
    printf( "Tried = %8d. Beg = %8d. End = %8d. Gain = %6d. (%6.2f %%).  Cut mem = %d MB\n", 
Alan Mishchenko committed
101
        p->nNodesTried, p->nNodesInit, Aig_ManNodeNum(p->pAig), Gain, 100.0*Gain/p->nNodesInit, p->nCutMemUsed );
Alan Mishchenko committed
102 103 104
    printf( "Cuts = %8d. Tried = %8d. Used = %8d. Bad = %5d. Skipped = %5d. Ave = %.2f.\n", 
        p->nCutsAll, p->nCutsTried, p->nCutsUsed, p->nCutsBad, p->nCutsSkipped,
        (float)p->nCutsUsed/Aig_ManNodeNum(p->pAig) );
Alan Mishchenko committed
105

Alan Mishchenko committed
106 107
    printf( "Bufs = %5d. BufMax = %5d. BufReplace = %6d. BufFix = %6d.  Levels = %4d.\n", 
        Aig_ManBufNum(p->pAig), p->pAig->nBufMax, p->pAig->nBufReplaces, p->pAig->nBufFixes, Aig_ManLevels(p->pAig) );
Alan Mishchenko committed
108 109 110 111
    ABC_PRT( "Cuts  ", p->timeCuts );
    ABC_PRT( "Eval  ", p->timeEval );
    ABC_PRT( "Other ", p->timeOther );
    ABC_PRT( "TOTAL ", p->timeTotal );
Alan Mishchenko committed
112 113 114 115

    if ( !p->pPars->fVeryVerbose )
        return;
    Dar_LibReturnCanonicals( pCanons );
Alan Mishchenko committed
116 117 118 119 120 121 122
    for ( i = 0; i < 222; i++ )
    {
        if ( p->ClassGains[i] == 0 && p->ClassTimes[i] == 0 )
            continue;
        printf( "%3d : ", i );
        printf( "G = %6d (%5.2f %%)  ", p->ClassGains[i], Gain? 100.0*p->ClassGains[i]/Gain : 0.0 );
        printf( "S = %8d (%5.2f %%)  ", p->ClassSubgs[i], p->nTotalSubgs? 100.0*p->ClassSubgs[i]/p->nTotalSubgs : 0.0 );
Alan Mishchenko committed
123
        printf( "R = %7d   ", p->ClassGains[i]? p->ClassSubgs[i]/p->ClassGains[i] : 9999999 );
Alan Mishchenko committed
124
//        Kit_DsdPrintFromTruth( pCanons + i, 4 );
Alan Mishchenko committed
125
//        ABC_PRTP( "T", p->ClassTimes[i], p->timeEval );
Alan Mishchenko committed
126
        printf( "\n" );
Alan Mishchenko committed
127
    }
Alan Mishchenko committed
128
    fflush( stdout );
Alan Mishchenko committed
129 130
}

Alan Mishchenko committed
131

132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
/**Function*************************************************************

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
#if 0

ABC_NAMESPACE_IMPL_END

147
#include "bool/kit/kit.h"
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166

ABC_NAMESPACE_IMPL_START

void Dar_ManPrintScript()
{
    unsigned pCanons[222];
    int i;
    Dar_LibReturnCanonicals( pCanons );
    for ( i = 1; i < 222; i++ )
    {
        Kit_DsdNtk_t * pNtk;
        pNtk = Kit_DsdDecompose( pCanons + i, 4 );
        printf( "    \"" );
        Kit_DsdPrint( stdout, pNtk );
        printf( "\",              /* %3d  */\n", i );
        Kit_DsdNtkFree( pNtk );
    }
}
#endif
Alan Mishchenko committed
167 168 169 170 171 172

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


173 174
ABC_NAMESPACE_IMPL_END