Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-18 Thread Aleksey Khudyakov
On 17.07.2013 16:11, Brian Lewis wrote: On 2013.07.17, at 08:03, Jan-Willem Maessen wrote: This has all the marks of a 64-bit-only code running on a 32 bit machine. This discussion is interesting, but I'm not sure why so much of it is taking place here instead of on the mwc-random issue

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-17 Thread Aleksey Khudyakov
On 10 July 2013 14:10, kudah kudahkuka...@gmail.com wrote: Yes, it does. Without optimizations the result is ndgorsfesnywaiqraloa, while with optimizations the result is always aabb. Sorry for taking so long. So problem is uniformR. You can reproduce bug reliably and I cannot.

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-17 Thread kudah
Test triggers the bug, only zeros and ones like you said, but only for native-sized types: -O2: Int 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 Int32 41 37 25 85 27 84 70 8 70 32 36 1 14 92 1 74 17 28 38 76 Int64 37 77 57 75 17 58 28 77 23 51 1 13 50 35 21 11 70 43 6 5 Word 0 0 1 1 0 0 1 0 0 0 0 0

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-17 Thread Jan-Willem Maessen
This has all the marks of a 64-bit-only code running on a 32 bit machine. It looks like you're getting the high bits of the rng with a signed shift right, ultimately yielding only the sign bit. I suspect mwc-random needs to use Int64 rather than Int internally in a few critical places. On Wed,

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-17 Thread Brian Lewis
On 2013.07.17, at 08:03, Jan-Willem Maessen wrote: This has all the marks of a 64-bit-only code running on a 32 bit machine. This discussion is interesting, but I'm not sure why so much of it is taking place here instead of on the mwc-random issue tracker:

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-10 Thread kudah
Yes, it does. Without optimizations the result is ndgorsfesnywaiqraloa, while with optimizations the result is always aabb. On Wed, 10 Jul 2013 02:21:10 +0400 Aleksey Khudyakov alexey.sklad...@gmail.com wrote: On 10.07.2013 01:38, kudah wrote: I've attached the script that I

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-09 Thread kudah
Same here, I used mwc-random to generate random strings. It works in ghci and when compiled with -O0, but with -O1 and -O2 I've been getting exclusively a's and b's. On Sun, 17 Mar 2013 18:48:06 +0500 Azeem -ul-Hasan aze...@live.com wrote: I am using GHC 7.6.1 mwc-random 0.12.0.1

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-09 Thread Aleksey Khudyakov
On 09.07.2013 22:10, kudah wrote: Same here, I used mwc-random to generate random strings. It works in ghci and when compiled with -O0, but with -O1 and -O2 I've been getting exclusively a's and b's. It looks like MWC generates only 0 and 1 for some reason. I've tried to write simple test but

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-09 Thread kudah
I've attached the script that I had trouble with. It tries to replicate one directory structure in another directory, while replacing filenames and file contents with random data. When compiled with -O1 or -O2 resulting file and directory names are composed only of a's and b's, but file contents

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-07-09 Thread Aleksey Khudyakov
On 10.07.2013 01:38, kudah wrote: I've attached the script that I had trouble with. It tries to replicate one directory structure in another directory, while replacing filenames and file contents with random data. When compiled with -O1 or -O2 resulting file and directory names are composed only

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-03-18 Thread Aleksey Khudyakov
On 17 March 2013 21:49, Dominic Steinitz domi...@steinitz.org wrote: Aleksey Khudyakov alexey.skladnoy at gmail.com writes: I've tried to run you program and I've got approximately same results regardless of optimization level. Which versions of GHC, mwc-random, vector and primitive do you

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-03-17 Thread Aleksey Khudyakov
On 16.03.2013 13:31, Azeem -ul-Hasan wrote: Nope that isn't the case either. Even if I make use of defaultSeed through create the problem still remains. The problem seems to be in the generation of a vector of (a,a) i.e in the part V.generateM ((round $ p*(fromIntegral $ l*z)) `div` 2) (\i-

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-03-17 Thread Azeem -ul-Hasan
I am using GHC 7.6.1 mwc-random 0.12.0.1 vector 0.9.1 primitive 0.4.1 Azeem On 16.03.2013 13:31, Azeem -ul-Hasan wrote: Nope that isn't the case either. Even if I make use of defaultSeed through create the problem still remains. The problem seems to be in the generation of a

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-03-17 Thread Dominic Steinitz
Aleksey Khudyakov alexey.skladnoy at gmail.com writes: I've tried to run you program and I've got approximately same results regardless of optimization level. Which versions of GHC, mwc-random, vector and primitive do you use? By approximate do you mean you are getting Monte Carlo noise

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-03-16 Thread Azeem -ul-Hasan
from System.Random and it works fine with optimizations turned on. So any ideas why optimizations are messing with System.Random.MWC? Azeem From: carter.schonw...@gmail.com Date: Fri, 15 Mar 2013 17:09:36 -0400 Subject: Re: [Haskell-cafe] Optimization flag changing result of code execution To: aze

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-03-16 Thread Roman Cheplyaka
ideas why optimizations are messing with System.Random.MWC? Azeem From: carter.schonw...@gmail.com Date: Fri, 15 Mar 2013 17:09:36 -0400 Subject: Re: [Haskell-cafe] Optimization flag changing result of code execution To: aze...@live.com CC: haskell-cafe@haskell.org Hey Azeem,have you

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-03-16 Thread Azeem -ul-Hasan
16. Thanks again. Azeem Date: Sat, 16 Mar 2013 10:58:50 +0200 From: r...@ro-che.info To: aze...@live.com CC: carter.schonw...@gmail.com; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Optimization flag changing result of code execution Perhaps the problem is in withSystemRandom

[Haskell-cafe] Optimization flag changing result of code execution

2013-03-15 Thread Azeem -ul-Hasan
I was trying to solve a computational problem form James P Sethna's book Statistical Mechanics: Entropy, Order Parameters, and Complexity[1]. The problem is on page 19 of the pdf linked and is titled Six degrees of separation. For it I came up with this code: http://hpaste.org/84114 It runs

Re: [Haskell-cafe] Optimization flag changing result of code execution

2013-03-15 Thread Carter Schonwald
Hey Azeem, have you tried running the same calculation using rationals? Theres some subtleties to writing numerically stable code using floats and doubles, where simple optimizations change the orders of operations in ways that *significantly* change the result. In this case it looks like you're