9
$\begingroup$

Bug fixed in 10.0.0


This crashes my kernel

Compile[{{x, _Real}, {center, _Real, 1}, {point, _Real, 1}}, 
(1` + (x - 1`) Exp[-Norm[point - center] 10`]), 
RuntimeAttributes -> Listable][3`, {0`, 0`}, {{1`, 1`}, {{1`, 1`}}}]

Changing the input parameters doesn't seem to change anything.

Changing (x - 1`) to x or to (3` - 1`) solves it.

Passing a proper matrix {{1`, 1`}, {1`, 1`}} solves it too.

Removing the 10` solves it too

What could be going on?

$\endgroup$
13
$\begingroup$

Since the compiled function is Listable, there's an attempt to evaluate it in parallel across different threads, and that's where the crash occurs.

Disabling the parallel evaluation works around the problem and stays in the virtual machine:

cf = Compile[{{x, _Real}, {center, _Real, 1}, {point, _Real, 1}}, 
    (1` + (x - 1`) Exp[-Norm[point - center] 10`]), 
    RuntimeAttributes -> Listable, Parallelization->False];
cf[3`, {0`, 0`}, {{1`, 1`}, {{1`, 1`}}}]
$\endgroup$
  • $\begingroup$ @DanielLichtblau said this is a bug, and has already been reported. jfklein13 had also suggested in chat setting Parallelization->False explicitly. Silvia's suggestion also seems to work. It would still be nice, if this can't be fixed, to have a better idea of the cases in which one runs the risk of meeting this bug $\endgroup$ – Rojo Jan 18 '13 at 0:52
7
$\begingroup$

Although I absolutely don't know what is going on at all, adding a Print before the real evaluation seems a possible working around in my Mathematica 9 64bit version.

Compile[{{x, _Real}, {center, _Real, 1}, {point, _Real, 1}},
  Print[];
  (1` + (x - 1`) Exp[-Norm[point - center] 10`]), 
  RuntimeAttributes -> Listable][3`, {0`, 0`}, {{1`, 1`}, {{1`, 1`}}}]

enter image description here

$\endgroup$
  • $\begingroup$ Print[] causes the compiled function to call MainEvaluate, so this is probably the cause. $\endgroup$ – shrx Aug 7 '15 at 8:33
  • $\begingroup$ @shrx It's possible. I don't have pre-10 version now, but maybe you can test your hypothesis by replacing the bytecode {46, Function[{x, center, point}, Print[]], 3, 0, 0, 3, 1, 0, 3, 1, 1, 6, 0, 17} in compiled expression with something like {46, Function[{}, Null], 6, 0, 17}, see if the crash still happens. $\endgroup$ – Silvia Aug 9 '15 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.