Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to dump a choice network? #349

Closed
chestercc1997 opened this issue Dec 12, 2024 · 3 comments
Closed

How to dump a choice network? #349

chestercc1997 opened this issue Dec 12, 2024 · 3 comments

Comments

@chestercc1997
Copy link

read /abc/32_32_S_SP_AR_BK_GenMul.aig;choice;ps;
abc/32_32_S_SP_AR_BK_GenMul: i/o = 64/ 64 lat = 0 and = 18822 (choice = 2782) lev =304
write test.aig
read test.aig;ps
abc/test : i/o = 64/ 64 lat = 0 and = 11682 lev =304
``
Can the choice network be dumped and read back in ABC? It seems that the dumped AIG contains choice nodes, but when reading it back, the choices cannot be recognized. I also tried using GIA write and read, which seems to keep the choice networks. However, when transferring it back to the AIG manager with &put, there are errors. If it cannot be put back into the AIG manager, it seems that ASIC tech mapping cannot be done in GIA.

@wjrforcyber
Copy link
Contributor

wjrforcyber commented Dec 13, 2024

Yes and no.
As you mentioned:

but when reading it back, the choices cannot be recognised.

It is because the choices nodes(specifically speaking the candidates nodes, not the representative one with fanout) have no fanout, they are treated as dangling nodes, and are collected and cleaned up by:

Abc_AigCleanup( (Abc_Aig_t *)pNtkNew->pManFunc );

If you comment out this line, you will get back your aiger with all dangling nodes(all choices candidates):

./abc -c "read_aiger i10.aig; strash; choice; ps; write_aiger i10w.aig"
ABC command line: "read_aiger i10.aig; strash; choice; ps; write_aiger i10w.aig".

i10                           : i/o =  257/  224  lat =    0  and =   3764 (choice = 541)  lev = 51
The node number before writing 3764
./abc -c "read_aiger i10w.aig; ps;"                                    
ABC command line: "read_aiger i10w.aig; ps;".

i10w                          : i/o =  257/  224  lat =    0  and =   3764  lev = 51

but you can't tell the relations between representative node and candidate nodes (As you can see, there's no (choice = XXX)).
The original relations are maintained by pointers

union { void * pData; // the network specific data

in ABC (See Figure 4 in this paper for a clear illustration), so after dumping all these nodes without fanout into file format, this information is lost, so I am wondering if the write_aiger forgets to check and remove all choices candidates, it only checks the Ntk type:
assert( Abc_NtkIsStrash(pNtk) );

and when you use write_aiger it dump choices candidates if you have them in your network, actually I don't see the point here. Maybe there's other application I don't know, let's just ask @alanminko for his opinion to see if this is by intention or just a small typo missing case.

So yes, you could get back all your nodes, but no, you can't tell which candidate belongs to which representative node easily.

Further more, I think it's not totally impossible if you'd like to save the relations of the choices somewhere else before dumping by yourself, and you can recover it after read aiger back anyway.

@chestercc1997
Copy link
Author

Hi Wang, thanks for sharing. I am doing some testing.

It seems that in AIG, pData is used to maintain the linked list of all equivalent choices of each node.

union { void * pData; // the network specific data

in Aig_Man_t, pEquivs uses a linked list to represent the equivalent nodes corresponding to each node.
Aig_Obj_t ** pEquivs; // linked list of equivalent nodes (when choices are used)

By traversing the support nodes of each choice node, their representative (the logic cone of the root node) can be obtained.

And when reading back, the mapping of which AIG node each choice node belongs to is not written in the AIG file, which results in the issue you mentioned: they are dumped but cannot be recognized as choices when read back.

I’m testing in GIA to see if this information will be dumped, and I’ve also found that there are still some issues that I’m currently fixing when covert GIA choice network into AIG network.
./abc -c "read i10.aig;ps;&get;&choice;&put;ps;"
it will have an error :
abc: src/base/abci/abcDar.c:1227: Abc_NtkFromDarChoices: Assertion `pTemp->pData != NULL' failed. Aborted (core dumped)

assert( pTemp->pData != NULL );

It should be said that for each choice node, this assert must be satisfied—having pData. However, it is currently unclear why the assert fails.

If this assert is commented out, the program can run, but it can be observed that even after dumping back to an AIG, the information about the choice nodes still isn't saved. By turning the below test from 0 to 1, it can be seen that the Abc_AigNodeIsChoice check still doesn't succeed.

abc/src/base/abci/abcDar.c

Lines 1241 to 1254 in 8ba3d9b

if ( 0 )
{
Abc_Obj_t * pNode;
Abc_NtkForEachNode( pNtkNew, pNode, i )
if ( Abc_AigNodeIsChoice( pNode ) )
{
int Counter = 0;
for ( pNode = Abc_ObjEquiv(pNode); pNode; pNode = Abc_ObjEquiv(pNode) )
Counter++;
printf( "%d ", Counter );
}
printf( "\n" );
}
return pNtkNew;

I will continue to investigate where the issues lie. If there is any progress, I will provide continuous updates

wjrforcyber added a commit to wjrforcyber/abc that referenced this issue Dec 17, 2024
@chestercc1997
Copy link
Author

Solved with:#350
it works now , read the dumped choice GIA aiger and using &put could reconstruct the choice network

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants