Discussion Overview
The discussion revolves around issues encountered when compiling a Monte Carlo simulation written in C using different compilers (g++ and icc). Participants explore the potential causes of differing outputs, focusing on random number generation and compiler behavior.
Discussion Character
- Technical explanation
- Debate/contested
Main Points Raised
- One participant notes that the program produces different outputs when compiled with different compilers, despite no changes in the source code.
- Another participant questions whether different outputs are expected, suggesting that outputs should vary with each run regardless of the compiler.
- It is mentioned that consistent outputs are obtained with the same compiler, indicating that differences arise only when switching compilers.
- A participant asks for clarification on the nature of the different outputs and the specifics of the randomization process used in the simulation.
- Concerns are raised that different compilers may handle seed generation differently, potentially affecting the first random number produced.
- One participant argues that the differing outputs could stem from the compilers utilizing different math libraries, as the behavior of rand() is poorly specified in standards.
- Another participant emphasizes the importance of avoiding rand/srand due to their limitations and suggests using more reliable random number generators.
- It is noted that different compilers may implement floating point operations differently, which can lead to variations in results due to the non-associative nature of these operations.
Areas of Agreement / Disagreement
Participants express varying opinions on the causes of the differing outputs, with no consensus reached. Some agree on the potential issues with rand/srand, while others focus on compiler-specific behaviors.
Contextual Notes
Participants highlight limitations in the specifications of random number generation and floating point operations, which may contribute to the observed discrepancies without resolving the underlying issues.