[Llvm-bgq-discuss] Details behind MPI wrapper for bgclang++

Jack Poulson jack.poulson at gmail.com
Fri Mar 1 19:23:53 CST 2013


Hi Hal,

Due to a temporary lapse in judgement, I'll explain the subtle bug in my
program that I just found that seems to be the cause of this issue:

Take the square [a,b] x [a,b] and subdivide it into an 8 x 8 grid of
subsquares, and then draw a large number of random samples from [a,b) x
[a,b) using std::uniform_real_dist, then determine which subsquare a random
sample (x,y) is in via floor((x-a)/w) and floor((y-a)/w), where w=(b-a)/8
is the width of each box.

The problem is fairly obvious in hindsight, but even though x and y are not
allowed to be exactly equal to b due to being drawn from [a,b), the
round-off error in (x-a)/w makes that irrelevant, and what was
mathematically floor(7.9999999) might be computed as floor(8.00000000),
which produced a box index which was out of bounds and therefore resulted
in a segfault when I loaded from an invalid memory location.

The probability of running into this edge case of course increases with the
number of samples taken, which explains why I never ran into it developing
on my own machine.

I think this issue seems to be resolved now...thank you very much for your
help Hal and Jeff.

Jack
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alcf.anl.gov/pipermail/llvm-bgq-discuss/attachments/20130301/85429be9/attachment-0001.html>


More information about the llvm-bgq-discuss mailing list