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 tracke

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: https://github.com/bos/mwc-random/iss

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 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 Aleksey Khudyakov
On 10 July 2013 14:10, kudah 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. Are you on 32-b

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 wrote: > On 10.07.2013 01:38, kudah wrote: > > I've attached the script that I had trouble with. It

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-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 se

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 e

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 wrote: > I am using >GHC 7.6.1 >mwc-random 0.12.0.1 >vector 0.9.1 >

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

2013-03-18 Thread Aleksey Khudyakov
On 17 March 2013 21:49, Dominic Steinitz wrote: > Aleksey Khudyakov 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 yo

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

2013-03-17 Thread Dominic Steinitz
Aleksey Khudyakov 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 or Floating Poi

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 v

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-> R.u

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

2013-03-16 Thread Azeem -ul-Hasan
in line 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 >

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

2013-03-16 Thread Roman Cheplyaka
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...@live.com &g

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-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 av