Tag Info

Hot answers tagged

4

If the goal is to perform a parallel search for the first result that meets some condition, then we can consider using ParallelTry instead of throw/catch: ParallelTry[If[PrimeQ[#], #, $Failed]&, Range[492114, 500000]] (* 492227 *) This evaluates a function for every value in the second argument (in parallel). The first result that is anything other ...


4

As you are changing the DownValues of m inside your ParallelDo you have to share them among the parallel kernels using SetSharedFunction first: SetSharedFunction[m] Parallelize[Do[m[i] = 2, {i, 1, 10}]] m[1] 2 As you refer to m as a variable, something like m = ConstantArray[0, 10] SetSharedVariable[m] Parallelize[Do[m[[i]] = 2, {i, 1, 10}]] ...


4

It depends on how PBS and the cluster environment are set up. Ideally, if cpuset support has been compiled in to PBS, and if you start Mathematica directly inside the PBS job, you should find that it uses all processors allocated by PBS (on that node--Eigensystem is not MPI-parallelized). If cpuset support isn't provided, then you risk starting as many ...


2

With a = Table[0, {4}, {4}] b = Table[2 i + j, {i, 1, 2}, {j, 1, 2}] using SetSharedVariable[a] ParallelDo[a[[j, i]] += b[[i, j]], {i, 1, 2}, {j, 1, 2}] a {{3, 5, 0, 0}, {4, 6, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}} would work, but using a += Transpose[b] ~PadRight~ Dimensions@a {{3, 5, 0, 0}, {4, 6, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}} is much ...


2

This is not likely a practical approach, but it illustrates whats going on: Clear[x]; ParallelDo[x[i] = i^2, {i, 1, 10}]; as noted the global x has not been defined, however each of our kernels retains the definition: ParallelEvaluate[{$KernelID, DownValues[x]}] // MatrixForm as a bit of a kludge we can pull the values back to global like this: ...


2

As mentioned by Albert Retey in the comment above, you can't expect that NDSolve makes use of your parallel kernels, period. However, since your equation set is just a system of 1st order linear ODEs, you can turn to MatrixExp, which seems to parallelize automatically: coe = gamma - DiagonalMatrix@Total@gamma; init = ConstantArray[0., 816]; init[[-2]] = ...


2

Perhaps this: inhom = Plus @@ Table[a[i] Exp[b[i] x], {i, 1, 100}]; eq[inhom_] := {u''[x] + u[x] + inhom == 0, u[0] == 0, u[1] == 0}; sol = u -> ParallelMap[DSolveValue[eq[#], u[x], x] &, inhom] (* u -> -(1/(1 + b[1]^2)) a[1] (-Cos[x] + E^(x b[1]) Cos[x]^2 + Cot[1] Sin[x] - E^b[1] Cos[1] Cot[1] Sin[x] - E^b[1] Sin[1] Sin[x] + ...


1

Edited to reflect later comments below : These examples will work: ParallelMap[Identity, {<|1 -> 1|>, <|2 -> 2|>}] (* {<|1 -> 1|>, <|2 -> 2|>} *) ParallelMap[Identity, {<|1 -> 1, 3 -> 3|>, <|2 -> 2, 3 -> 3|>}] (* {<|1 -> 1, 3 -> 3|>, <|2 -> 2, 3 -> 3|>} *) Its worth ...


1

Using ParallelDo[Print[i]; Break[], {i, 1, 100}, Method -> "CoarsestGrained"] or ParallelDo[Print[i]; Break[], {i, 1, 100}, Method -> "EvaluationsPerKernel" -> 1] should give you the desired behavior. These options are explained and illustrated in the Options ▶ Method section of Parallelize. Mathematica breaks the computation within ...


1

Did you try DistributeDefinitions[evolve] before running ParallelTable ?


1

Try checking the parallel kernel settings by clicking on the menu bar: Evaluation > Parallel Kernel Configuration Click the tab Parallel in the window that pops up. Uncheck Automatic as it may have fewer kernels than you want, subject to the limit imposed by your license. Then click Manual setting, and set the number of kernels desired.


1

Similar to my answer to this question you probably have to redesign your code. Depending on your need Module[{counter = 1}, ParallelDo[ While[2 != (num = RandomInteger[{1, 15}]) && counter <= 10, counter++; Print[num]]; If[counter <= 10, Print["Thrown at trial " <> ToString[counter]]], {$ProcessorCount}]] or Module[{counter = ...



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