Code Monkey home page Code Monkey logo

Comments (4)

sbeamer avatar sbeamer commented on May 27, 2024 2

This is an unfortunate situation that has been getting worse. Although C++ standards carefully specify how the random number generators should behave, they do not do the same for uniform_int_distribution (reddit post). With seeding, the generator will produce the same values, but the distribution will not. When this codebase was first constructed, gcc, clang, icc, and suncc used the same distribution algorithm. Recently, there has been some divergence. On a linux box, g++ 9.4 and clang++ 12 produce the same right answer. However, on my mac, Apple clang 14 and g++-12 produce different results.

Fortunately, for those concerned about running the exact same benchmark graphs, SuiteSparse captured the graphs a couple years ago (https://sparse.tamu.edu/GAP).

I'm going to leave this issue open, since the only solutions I can think of are unsatisfactory. I would be grateful if anyone has a better idea. So far, the options I can think of all have downsides:

  1. Do nothing - Although randomly generated graphs will be subtly different, for most research purposes this is ok. The most worrisome part is a unit test not passing. For now, GitHub's CI is using a compiler that still has the same distribution function, so it is still passing.
  2. Replace the distribution with % - This will be portable, however, modulus can add bias to the distribution. This is especially likely as the range gets close to the size of the random numbers, which someone might do with SCALE=29 or SCALE=30.
  3. Write a portable distribution function - This might be the least bad but the most work. Doing it well involves both removing bias as well as being high-performance. Typically, I duplicate functionality from the standard library as a last result.
  4. Make test case weaker - This might be an expedient solution, but then the test case may not be checking much.

from gapbs.

sbeamer avatar sbeamer commented on May 27, 2024

With CI failing, I checked to see the current state of which distribution each compiler is using.

In my lab, I had Linux boxes with gcc 9,10,11,13 and clang 12 and 14. Gcc 9 & 10 behaved like the original reference output. Gcc 11 onwards as well as the clang versions all behaved the same. With any luck, gcc & clang will continue to have the same implementation behavior.

Thus, going with a slightly modified version of option 1 (via commit 30197cf).

from gapbs.

sbeamer avatar sbeamer commented on May 27, 2024

Spoke too soon. Clang (14) on my Mac produces yet another answer.

Option 3 will probably be the best.

from gapbs.

sbeamer avatar sbeamer commented on May 27, 2024

I went with option 3 to further standardize this reference code.

from gapbs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.