caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: oleg@okmij.org
To: paulfsnively@gmail.com
Cc: caml-list@inria.fr
Subject: [Caml-list] Delimcc.0 OPAM Package Difficulty on Mac OS X
Date: 16 Apr 2013 06:01:02 -0000	[thread overview]
Message-ID: <20130416060102.68444.qmail@www1.g3.pair.com> (raw)


> ./test_samplingM
> rejection_sample: done 100 worlds
> Fatal error: exception Assert_failure("samplingM.ml", 16, 9)

Luckily, the assertion failure is harmless. Here is the complete code
where the failure occurs:

let tflip2_shared () =   (* sharing of flips *)
  let v = flip 0.5 in
  v && v;;
let () = assert (
  sample_rejection (random_selector 1) 100 tflip2_shared
    = [(0.48, V true); (0.52, V false)]);;

Essentially, we flip a coin 100 times and see how many times it comes
out head. The `random source' (random_selector 1) seeds the random
generator with a fixed value -- 1 in this case. Therefore, re-running
the code should give the same results. Alas, the implementation of
random number generator may change -- and it did between OCaml 3.11
and OCaml 3.12. Therefore, given the same seed, the sequence of
produced numbers can be different. Also, the behavior of the random
number generator may be platform-specific.

So, the good news is that the failure is harmless. The bad news is that
the change in the random number generator or the platform has
invalidated the regression tests. To see that Hansei functions
properly, one has to check the results manually. For example, 

  sample_rejection (random_selector 1) 100 tflip2_shared

may now produce  [(0.49, V true); (0.51, V false)]) or
[(0.52, V true); (0.48, V false)], etc.


> this is a little disturbing: I got almost-correct output with -O0 and
> -DDEBUG=1, but there was still a message about "can't happen" at the
> very end, still using Apple's GCC 4.2.1 for Mac OS X 10.6.8.  I got
> similarly incorrect results using the current release, 3.2, of clang.
> I then remembered that, some time ago, I'd installed a binary of a
> much more recent GCC 4.6.2 that I could optionally use. Using it, I
> get correct results from testd0opt, even without using -O0!
Very interesting! I do use GCC 4.2.1 but on FreeBSD. I guess the
problem is platform-specific (or GCC-backend specific). It could
happen that GCC 4.2.1 over-optimized on MacOS, and the later versions
of GCC have corrected the problem. Thank you for the investigation!



             reply	other threads:[~2013-04-16  6:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-16  6:01 oleg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-04-12  8:56 oleg
2013-04-09 11:08 oleg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130416060102.68444.qmail@www1.g3.pair.com \
    --to=oleg@okmij.org \
    --cc=caml-list@inria.fr \
    --cc=paulfsnively@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).