ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioWriteHMetis.c File Reference
#include "ioAbc.h"
Include dependency graph for ioWriteHMetis.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Io_WriteHMetis (Abc_Ntk_t *pNtk, char *pFileName, int fSkipPo, int fWeightEdges, int fVerbose)
 

Function Documentation

◆ Io_WriteHMetis()

ABC_NAMESPACE_IMPL_START void Io_WriteHMetis ( Abc_Ntk_t * pNtk,
char * pFileName,
int fSkipPo,
int fWeightEdges,
int fVerbose )

CFile****************************************************************

FileName [ioWriteHMetis.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write hMetis format developed by George Karypis and Vipin Kumar from the University of Minnesota (https://karypis.github.io/glaros/files/sw/hmetis/manual.pdf)]

Author [Jingren Wang]

Affiliation []

Date [Ver. 1.0. Started - December 16, 2006.]

Revision []

Definition at line 26 of file ioWriteHMetis.c.

27{
28 Abc_Obj_t *pObj;
29 Abc_Obj_t *pFanout;
30 int i, j;
31 Vec_Int_t *vHyperEdgeEachWrite;
32 int iEntry;
33 int nHyperNodesNum = 0;
34 // check that the network is valid
35 assert( Abc_NtkIsStrash( pNtk ) && Abc_NtkIsComb( pNtk ) );
36
37 FILE *pFHMetis = fopen( pFileName, "wb" );
38 Vec_Ptr_t *vHyperEdges = Vec_PtrAlloc( 1000 );
39 if ( pFHMetis == NULL )
40 {
41 fprintf( stdout, "Io_WriteHMetis(): Cannot open the output file \"%s\".\n", pFileName );
42 fclose( pFHMetis );
43 return;
44 }
45
46 // show pi/po/and number
47 if ( fVerbose )
48 {
49 Abc_Print( 1, "Writing hMetis file \"%s\" with %d nodes (%d pi, %d po, %d and nodes).\n", pFileName, Abc_NtkObjNum( pNtk ), Abc_NtkPiNum( pNtk ), Abc_NtkPoNum( pNtk ), Abc_NtkNodeNum( pNtk ) );
50 }
51
52 Abc_NtkForEachObj( pNtk, pObj, i )
53 {
54 Vec_Int_t *vHyperEdgeEach = Vec_IntAlloc( 20 );
55 // push the node itself, which is a source node
56 Vec_IntPush( vHyperEdgeEach, Abc_ObjId( pObj ) );
57 // iterate through all the fanouts(sink) of the node
58 if ( !Abc_ObjIsCo( pObj ) )
59 {
60 Abc_ObjForEachFanout( pObj, pFanout, j )
61 {
62 Vec_IntPush( vHyperEdgeEach, Abc_ObjId( pFanout ) );
63 }
64 } else
65 {
66 if ( fSkipPo )
67 {
68 continue;
69 }
70 Vec_IntPush( vHyperEdgeEach, Abc_ObjId( Abc_ObjFanin0( pObj ) ) );
71 }
72 Vec_PtrPush( vHyperEdges, vHyperEdgeEach );
73 }
74
75 nHyperNodesNum = Abc_NtkObjNum( pNtk );
76
77 // write the number of hyperedges and the number of vertices
78 if ( fWeightEdges )
79 {
80 fprintf( pFHMetis, "%d %d 1\n", Vec_PtrSize( vHyperEdges ), nHyperNodesNum );
81 } else
82 {
83 fprintf( pFHMetis, "%d %d\n", Vec_PtrSize( vHyperEdges ), nHyperNodesNum );
84 }
85 // write the hyperedges
86 Vec_PtrForEachEntry( Vec_Int_t *, vHyperEdges, vHyperEdgeEachWrite, i )
87 {
88 if ( fWeightEdges )
89 {
90 fprintf( pFHMetis, "%d ", Vec_IntSize( vHyperEdgeEachWrite ) );
91 }
92
93 Vec_IntForEachEntry( vHyperEdgeEachWrite, iEntry, j )
94 {
95 if ( j == Vec_IntSize( vHyperEdgeEachWrite ) - 1 )
96 {
97 fprintf( pFHMetis, "%d", iEntry );
98 } else
99 {
100 fprintf( pFHMetis, "%d ", iEntry );
101 }
102 }
103 fprintf( pFHMetis, "\n" );
104 }
105 // comments should be started with "%" in hMetis format
106 fprintf( pFHMetis, "%%This file was written by ABC on %s\n", Extra_TimeStamp() );
107 fprintf( pFHMetis, "%%For information about hMetis format, refer to %s\n", "https://karypis.github.io/glaros/files/sw/hmetis/manual.pdf" );
108 Vec_PtrFreeFree( vHyperEdges );
109 fclose( pFHMetis );
110}
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition abc.h:529
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
char * Extra_TimeStamp()
#define assert(ex)
Definition util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function: