rasmusto / vtr-verilog-to-routing

Automatically exported from code.google.com/p/vtr-verilog-to-routing
0 stars 0 forks source link

Random number generation: Linux vs Mac vs Windows #35

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
As we have discussed, the VTR flow produces different results in Linux, Max or 
Windows.

I've tracked the problem down to ABC.  ODIN produces identical blifs; however, 
when ABC optimized the blif, the results vary.

I believe this is due to different random number generators in the different 
platforms, and I think we should use a platform-independent solution. 

One possible random number generator is here: 
http://www-cs-faculty.stanford.edu/~knuth/programs/rng.c

However, I'm not sure how to tell the gcc linker to use a different function 
instead of srand/rand.  Could someone explain the process so that I can see if 
this fixes the variation problem?  I think we have briefly discussed it when 
talking about using a new malloc implementation.

Original issue reported on code.google.com by jeffrey....@gmail.com on 8 Jun 2012 at 10:26

GoogleCodeExporter commented 9 years ago
I have confirmed that by using the same random number generator, the 
discrepancies are eliminated.

Original comment by jeffrey....@gmail.com on 11 Jun 2012 at 9:34

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Jeff,

Are you talking about a random number generator in ABC or VPR?  VPR already 
includes its own random number generator and doesn't call the C library one.

Over the years I've found many reasons why output differs on different 
platforms, mostly due to different operation ordering leading to slightly 
different floating point roundoff, and related floating point library round-off 
differences etc.  So in VPR at least, getting a guaranteed same result on 
different platforms is not easy.  Random numbers won't be a problem there, but 
the rest of the code will be.

Vaughn

Original comment by vaughnb...@gmail.com on 27 Jun 2012 at 7:46

GoogleCodeExporter commented 9 years ago
Yes, I suppose that due to floating point it may be very difficult to make VPR 
produce the same results on different platforms.

I'm not sure if we should bother doing anything at this point.  

However, a few things to consider:
 - ABC does not have an internal RNG.  Possibly be adding one we could at least provide VPR with equivalent circuits across platforms.  This would eliminate inconsistencies such as different # of CLBs.  (Does this even matter?)

 - VPR's integer RNG uses floating-point.  In my testing it behaved differently with 32-bit vs 64-bit systems.  However, changing the RNG to use double instead of float corrected this.

Original comment by jeffrey....@gmail.com on 27 Jun 2012 at 10:34