Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
2  
5  
What is going on is this is a bug. I filed a report with what diagnosis I was able to provide. –  Daniel Lichtblau Jan 17 '13 at 21:28
    
Thanks @DanielLichtblau! –  Rojo Jan 17 '13 at 21:30
3  
Here is something similar from before: stackoverflow.com/questions/8262218/… –  asim Jan 18 '13 at 3:21

2 Answers 2

up vote 9 down vote accepted

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`}}}]
share|improve this answer
    
@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 –  Rojo Jan 18 '13 at 0:52

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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