Cross-post: http://zhidao.baidu.com/question/2075301703219376588.html


a = N[1, 2];
ParallelDo[Print[a], {j, 1}];
a = N[1, 3];
ParallelDo[Print[a], {j, 1}];
a = N[2, 3];
ParallelDo[Print[a], {j, 1}]; 



On the 3rd line of the input, the change of the precision of a doesn't work. There is still 1.0 on the 2nd line of the output. On the 5th line of the input, the change of the precision of a works and seems to depend on the change of the value.

Of cause, inserting SetSharedVariable[a] can avoid this problem, but still remain unsatisfactory.

  • $\begingroup$ Hello, welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – xzczd Dec 22 '14 at 8:34
  • $\begingroup$ BTW, please don't use "bugs" tag until the community has confirmed it. $\endgroup$ – xzczd Dec 22 '14 at 8:34
  • $\begingroup$ Interesting! I am facing similar problems with parallel computing. Observe that you get a correct result when you leave out your first two lines of code, so there must be an interaction between them. For me it is just another bug. It is a little bit frustrating that subkernels seem not to be able to do the same things as the main kernel. $\endgroup$ – Fred Simons Dec 22 '14 at 10:44
  • $\begingroup$ Yeah, @FredSimons, I think you are right. It seems that when evaluating in subkernels, Mathematica has done some comparing between values, such as 1.0==1.00. This remind me of the function of cache, being used for second evaluation, which may skip the second = of a. $\endgroup$ – xyz Dec 22 '14 at 11:32

Your Answer

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

Browse other questions tagged or ask your own question.