Re: [Haskell-cafe] Optimization flag changing result of code execution
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 tracker: https://github.com/bos/mwc-random/issues It's way past time to file an issue and/or talk to the maintainer. Issue turned out to be GHC bug. Here are relevant tickets https://github.com/bos/mwc-random/issues/25 http://ghc.haskell.org/trac/ghc/ticket/8072 No workaround for mwc-random yet ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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. Are you on 32-bit system? I only tested on 64-bit ones. If this isn't the case I'm out of ideas. I finally wrote test case that doesn't depends on anything besides mwc-random (it's in attachment). Could you check whether it still triggers the bug testcase.hs Description: Binary data ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 0 0 0 0 0 1 1 0 Word32 52 45 86 4 85 44 71 59 91 10 65 89 41 78 84 88 3 60 71 0 Word64 12 82 25 1 11 14 76 58 1 77 9 25 57 20 41 8 2 29 21 29 ghci: Int 53 13 24 58 66 71 19 16 73 54 95 87 2 34 62 67 2 45 56 2 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 41 19 99 69 27 58 92 45 9 38 51 39 50 14 2 21 25 94 96 2 Word32 52 45 86 4 85 44 71 59 91 10 65 89 41 78 84 88 3 60 71 0 Word64 12 82 25 1 11 14 76 58 1 77 9 25 57 20 41 8 2 29 21 29 I run a 32-bit system, as I've said before. Gentoo Linux _i686_ 3.8.2-pf Could perhaps be something with my system, I'll test on Ubuntu later today, and if there are no problems with compiling mwc-random on ghc git — on it too. On Wed, 17 Jul 2013 12:19:29 +0400 Aleksey Khudyakov alexey.sklad...@gmail.com wrote: 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. Are you on 32-bit system? I only tested on 64-bit ones. If this isn't the case I'm out of ideas. I finally wrote test case that doesn't depends on anything besides mwc-random (it's in attachment). Could you check whether it still triggers the bug ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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, Jul 17, 2013 at 7:22 AM, kudah kudahkuka...@gmail.com wrote: 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 0 0 0 0 0 1 1 0 Word32 52 45 86 4 85 44 71 59 91 10 65 89 41 78 84 88 3 60 71 0 Word64 12 82 25 1 11 14 76 58 1 77 9 25 57 20 41 8 2 29 21 29 ghci: Int 53 13 24 58 66 71 19 16 73 54 95 87 2 34 62 67 2 45 56 2 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 41 19 99 69 27 58 92 45 9 38 51 39 50 14 2 21 25 94 96 2 Word32 52 45 86 4 85 44 71 59 91 10 65 89 41 78 84 88 3 60 71 0 Word64 12 82 25 1 11 14 76 58 1 77 9 25 57 20 41 8 2 29 21 29 I run a 32-bit system, as I've said before. Gentoo Linux _i686_ 3.8.2-pf Could perhaps be something with my system, I'll test on Ubuntu later today, and if there are no problems with compiling mwc-random on ghc git — on it too. On Wed, 17 Jul 2013 12:19:29 +0400 Aleksey Khudyakov alexey.sklad...@gmail.com wrote: 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. Are you on 32-bit system? I only tested on 64-bit ones. If this isn't the case I'm out of ideas. I finally wrote test case that doesn't depends on anything besides mwc-random (it's in attachment). Could you check whether it still triggers the bug ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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/issues It's way past time to file an issue and/or talk to the maintainer. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 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 seem properly randomized. No luck. On my computer script works correctly with and without optimizations. My best guess that uniformR is problematic. Does (\g - randName g 20) = create show different behavior with and without optimizations? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 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 vector of (a,a) i.e in the part V.generateM ((round $ p*(fromIntegral $ l*z)) `div` 2) (\i- R.uniformR ((0,0) , (l-1,l-1)) gen) in line 16. Thanks again. 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? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 everything works fine. Could you post test case and compiler/libraries/OS versions you use? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 seem properly randomized. ghc-7.6.2, vector-0.10.0.1, primitive-0.5.0.1, mwc-random-0.12.0.1, Gentoo Linux i686 3.8.2-pf. On Tue, 09 Jul 2013 22:43:36 +0400 Aleksey Khudyakov alexey.sklad...@gmail.com wrote: 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 everything works fine. Could you post test case and compiler/libraries/OS versions you use? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-name-shadowing -fno-warn-unused-imports #-} module Main where import Shelly import Filesystem.Path.CurrentOS (splitDirectories, encodeString, decodeString) import qualified Filesystem as F import qualified Data.Text as T import qualified Data.ByteString as B import Control.Monad.IO.Class import System.Random.MWC import Control.Monad.Primitive import Control.Monad import Control.Applicative import Prelude hiding (FilePath) import Data.String import System.Environment rands :: (PrimMonad m, Variate a) = Gen (PrimState m) - Int - m [a] rands gen i = replicateM i (uniform gen) randRs :: (PrimMonad m, Variate a) = Gen (PrimState m) - Int - (a, a) - m [a] randRs gen i z = replicateM i (uniformR z gen) lastElemLength :: FilePath - Int lastElemLength fd = case splitDirectories fd of [] - error $ Empty filepath ++ show fd g - T.length $ toTextIgnore $ last g randName :: Gen (PrimState IO) - Int - IO FilePath randName gen l = decodeString . map toEnum $ randRs gen l (fromEnum 'a', fromEnum 'z') main :: IO () main = do g - getArgs case g of [inDir, outDir] - withSystemRandom . asGenIO $ \gen - do shellyNoDir $ do escaping False $ do -- verbosely $ do out - absPath (decodeString outDir) in' - absPath (decodeString inDir) descent gen out in' _ - putStrLn Specify input directory and output directory descent :: Gen (PrimState IO) - FilePath - FilePath - Sh () descent gen outDir fd = do isDir - test_d fd if isDir then do n - liftIO $ randName gen $ lastElemLength fd let newDir = outDir / n mkdir_p newDir chdir fd $ do filesOrDirs - ls . mapM_ (descent gen newDir) filesOrDirs else do file - absPath fd liftIO $ do size - F.getSize file newFname - randName gen $ lastElemLength file bs - B.pack $ rands gen (fromInteger size) B.writeFile (encodeString $ outDir / newFname) bs ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 of a's and b's, but file contents seem properly randomized. No luck. On my computer script works correctly with and without optimizations. My best guess that uniformR is problematic. Does (\g - randName g 20) = create show different behavior with and without optimizations? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 use? By approximate do you mean you are getting Monte Carlo noise or Floating Point noise? If the latter then that's reasonable; if the former then that's worrying. Difficult to say. I got values around 10 with and without optimizations. Most likely it's MC noise I was using GHC-7.6.2 and latest vector/primitive/mwc-random. I didn't tried to reproduce bug with versions which Azeem Ul Hasan use. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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.uniformR ((0,0) , (l-1,l-1)) gen) in line 16. Thanks again. 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? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 vector of (a,a) i.e in the part V.generateM ((round $ p*(fromIntegral $ l*z)) `div` 2) (\i- R.uniformR ((0,0) , (l-1,l-1)) gen) in line 16. Thanks again. 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? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 or Floating Point noise? If the latter then that's reasonable; if the former then that's worrying. Dominic. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
Hi Carter, Thank you for your help, but I can confirm that this is not due to floating point errors. My own hunch is that it is due to the way I am using random number generation from System.Random.MWC. To check it I wrote a version of mkNetwork function using random number generation 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...@live.com CC: haskell-cafe@haskell.org 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 averaging the averages, which i *believe* can get pretty nasty in terms of numerical precision. Rationals would be a bit slower, but you could then sort out which number is more correct. On Fri, Mar 15, 2013 at 4:07 PM, Azeem -ul-Hasan aze...@live.com wrote: 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 fine when compiled with -O0 and consistently yields an answer around 10, but with -O1 and -O2 it consistently gives an answer around 25. Can somebody explain what is happening here? [1] http://pages.physics.cornell.edu/~sethna/StatMech/EntropyOrderParametersComplexity.pdf Azeem ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
Perhaps the problem is in withSystemRandom, which uses unsafePerformIO? Does the problem persist if you seed your program with some predefined seed? Roman * Azeem -ul-Hasan aze...@live.com [2013-03-16 13:46:54+0500] Hi Carter, Thank you for your help, but I can confirm that this is not due to floating point errors. My own hunch is that it is due to the way I am using random number generation from System.Random.MWC. To check it I wrote a version of mkNetwork function using random number generation 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...@live.com CC: haskell-cafe@haskell.org 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 averaging the averages, which i *believe* can get pretty nasty in terms of numerical precision. Rationals would be a bit slower, but you could then sort out which number is more correct. On Fri, Mar 15, 2013 at 4:07 PM, Azeem -ul-Hasan aze...@live.com wrote: 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 fine when compiled with -O0 and consistently yields an answer around 10, but with -O1 and -O2 it consistently gives an answer around 25. Can somebody explain what is happening here? [1] http://pages.physics.cornell.edu/~sethna/StatMech/EntropyOrderParametersComplexity.pdf Azeem ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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.uniformR ((0,0) , (l-1,l-1)) gen) 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 Perhaps the problem is in withSystemRandom, which uses unsafePerformIO? Does the problem persist if you seed your program with some predefined seed? Roman * Azeem -ul-Hasan aze...@live.com [2013-03-16 13:46:54+0500] Hi Carter, Thank you for your help, but I can confirm that this is not due to floating point errors. My own hunch is that it is due to the way I am using random number generation from System.Random.MWC. To check it I wrote a version of mkNetwork function using random number generation 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...@live.com CC: haskell-cafe@haskell.org 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 averaging the averages, which i *believe* can get pretty nasty in terms of numerical precision. Rationals would be a bit slower, but you could then sort out which number is more correct. On Fri, Mar 15, 2013 at 4:07 PM, Azeem -ul-Hasan aze...@live.com wrote: 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 fine when compiled with -O0 and consistently yields an answer around 10, but with -O1 and -O2 it consistently gives an answer around 25. Can somebody explain what is happening here? [1] http://pages.physics.cornell.edu/~sethna/StatMech/EntropyOrderParametersComplexity.pdf Azeem ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Optimization flag changing result of code execution
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 fine when compiled with -O0 and consistently yields an answer around 10, but with -O1 and -O2 it consistently gives an answer around 25. Can somebody explain what is happening here? [1] http://pages.physics.cornell.edu/~sethna/StatMech/EntropyOrderParametersComplexity.pdf Azeem ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
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 averaging the averages, which i *believe* can get pretty nasty in terms of numerical precision. Rationals would be a bit slower, but you could then sort out which number is more correct. On Fri, Mar 15, 2013 at 4:07 PM, Azeem -ul-Hasan aze...@live.com wrote: 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 http://hpaste.org/84114 It runs fine when compiled with -O0 and consistently yields an answer around 10, but with -O1 and -O2 it consistently gives an answer around 25. Can somebody explain what is happening here? [1] http://pages.physics.cornell.edu/~sethna/StatMech/EntropyOrderParametersComplexity.pdf Azeem ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe