1
$\begingroup$

I'm trying to carry out a parallel computation using Mathematica's inbuilt parallel functions, ParallelTable, etc. The problem is that the HPC doesn't seem to like my code.

Here is a significantly simplified version of my code (but should get across the issue):

LaunchKernels[5];

ParallelEvaluate[

f[x_]:=x^2;

];

table = ParallelTable[{x,f[x]},{x,1,5},Method -> "FinestGrained"];

func = Interpolation[table];

ParallelEvaluate[parafunc[x_] = func[x]];


Print[ParallelEvaluate[NIntegrate[parafunc[x],{x,1,5}],1]]

I have written this in a text editor that I have subsequently saved as a .m file.

When I run this code the output is simply a Mathematica error stating that the integrand as evaluated to non-numerical values for all sampling points. I really can't see what I'm doing wrong, as if I just get it to Print[ParallelEvaluate[parafunc[1.4],1]] for example, then it correctly gives me the value of parafunc[1.4] so the sub-kernels do seem to have access to the function.

Having run tests, it seems to be that for some reason Mathematica on the HPC doesn't get along with NIntegrate of the parallelised function parafunc.

Are there any subtleties to using ParallelEvaluate and NIntegrate on an HPC that I'm unaware of here?

| improve this question | | | | |
$\endgroup$

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.