Tag Info

Hot answers tagged

10

In Mathematica 10 or newer, as pointed out by Szabolcs, $ProcessorCount will return the number of physical CPU cores, not the number of logical cores. Thus, on a system with 4 cores and 8 threads, In[1]:= $ProcessorCount Out[1]= 4 Functionality which uses multiple kernels in parallel, for example ParallelEvaluate and friends, will then launch ...


7

Never use pattern matching unless you absolutely have to. Using Cases instead of Select can make a huge difference. Vectorize operations. Use Range instead of Table if you can. Test several things at once. And[test1, test2, test3] will abort when it can for maximum efficiency ("short circuit evaluation"). Taking this into consideration your code looks ...


6

The OP's (current) definition of ncalc is unreadable and unsalvageable, so I made one up from pieces of the code. ncalc = Piecewise[{ {-21. + 294. u - 1029. u^2, u < 1/7}, {2. v (131.25 - 367.5 u + 257.25 u^2), 5/7 < u < 6/7}, {5.25, u == 6/7}, {33.8811 v^2 , u > 1/7}}, -1380.75 + 3160.5 u - 1800.75 u^2] When you set shared ...


5

After a bit of consideration I recommend that you use ParallelSubmit and related functionality, e.g. WaitAll. Please consider this example: job = Array[ParallelSubmit[Pause[1]; If[Random[] > 0.7, Quit[]]; Print[#]] &, 10] This creates a series EvaluationObject tasks to perform. Within each is a 30% chance of failure simulated by If[Random[] ...


4

In Mathematica every inter-Kernel communication comes with significant overhead. Your simple Do loop with a shared Sow on every value is about the worst possible situation. Instead (for performance) you want to gather results within each Kernel and only pass them back to the master in a single call. (Or at least a limited number of calls.) Using linked ...


2

I do not have time to explore this deeply, but a quick Trace of the issue indicates that the functionality simply is not written to preserve packing. Observe: args = RandomReal[1, {10000}]; On["Packing"]; tr = Trace @ ParallelTable[x, {x, args}, Method -> "ItemsPerEvaluation" -> 100]; FirstPosition[tr, Developer`FromPackedArray::punpack1] {5, ...


1

I've solved the problem by using the tunnel_sub.sh from Sacha Kratky script provided here. Thank you



Only top voted, non community-wiki answers of a minimum length are eligible