ParallelSubmit[expr]
submits expr for evaluation on the next available parallel kernel and returns an EvaluationObject expression representing the submitted evaluation.
ParallelSubmit[{var1,var2, …},expr]
builds a closure for the variables given before submitting expr.
ParallelSubmit
ParallelSubmit[expr]
submits expr for evaluation on the next available parallel kernel and returns an EvaluationObject expression representing the submitted evaluation.
ParallelSubmit[{var1,var2, …},expr]
builds a closure for the variables given before submitting expr.
Details and Options
- ParallelSubmit[{var1,var2, …},expr] substitutes the current values of the vari into expr before submitting it for evaluation.
- ParallelSubmit has attribute HoldAllComplete.
Examples
open all close allBasic Examples (3)
ParallelSubmit[1 + 2]WaitAll[%]Schedule a range of evaluations concurrently:
Table[ParallelSubmit[{i}, Total[FactorList[x ^ i + 1][[2 ;; , 2]]]], {i, 15, 20}]Start the calculations and wait for all results:
WaitAll[%]Functions used need to be distributed first:
fl[n_] := Total[FactorList[x ^ n + 1][[2 ;; , 2]]]DistributeDefinitions[fl]WaitAll[Table[ParallelSubmit[{i}, fl[i]], {i, 21, 30}]]Scope (3)
Use Table to submit evaluations:
evs = Table[ParallelSubmit[{i}, {i, PrimeQ[2 ^ i - 1]}], {i, 2200, 2222}];WaitAll[evs]Use a function to generate evaluations:
evs = Map[ParallelSubmit[PrimeQ[2 ^ # - 1]]&, Range[2200, 2222]];WaitAll[evs]Schedule the same expression on each available kernel:
WaitAll[Table[ParallelSubmit[First[Timing[Inverse[RandomReal[{-1, 1}, {1000, 1000}]]]]], {$KernelCount}]]Applications (4)
Run a search for a random prime on each parallel kernel:
With[{base = 10 ^ 1000, r = 10 ^ 10}, WaitAll[Table[ParallelSubmit[
While[!PrimeQ[p = RandomInteger[{base, base + r}]], Null];p], {$KernelCount}]] - base]Watch the scheduling of the evaluations while they are running:
With[{base = 10 ^ 1000, r = 10 ^ 10}, evs = Table[ParallelSubmit[
While[!PrimeQ[p = RandomInteger[{base, base + r}]], Null];p - base], {$KernelCount}];
PrintTemporary[evs];
WaitAll[evs]]Stop all evaluations as soon as one result has been found using a shared variable:
With[{base = 10 ^ 1000, r = 10 ^ 10},
SetSharedVariable[stop];stop = False;
WaitAll[Table[ParallelSubmit[
While[!PrimeQ[p = RandomInteger[{base, base + r}]], If[stop, Return[$Failed]]];stop = True;Return[p - base]], {$KernelCount}]]]Write a command that evaluates the arguments of a list in parallel:
SetAttributes[concurrentEvaluate, HoldAll]
concurrentEvaluate[l_List] := WaitAll[ParallelSubmit /@ Unevaluated[l]]concurrentEvaluate[{$KernelID, PrimeQ[2 ^ 2203 - 1], $KernelID}]Use ParallelCombine for the same purpose:
ParallelCombine[Identity, Unevaluated[{$KernelID, PrimeQ[2 ^ 2203 - 1], $KernelID}], Method -> "FinestGrained"]Submit evaluations for searching adjacent ranges:
evs = Table[ParallelSubmit[{i}, Count[2 ^ Range[1000i, 1000(i + 1) - 1] - 1, _ ? PrimeQ]], {i, 2, 5}];
Total[WaitAll[evs]]Use Parallelize for the same purpose:
Parallelize[Count[2 ^ Range[2000, 5999] - 1, _ ? PrimeQ]]Properties & Relations (3)
The "FinestGrained" Method setting schedules each item as a single evaluation:
ParallelTable[Labeled[Framed[f[i]], $KernelID], {i, 12}, Method -> "FinestGrained"]Internally it works similarly to WaitAll[ParallelSubmit[…]]:
WaitAll[Table[ParallelSubmit[{i}, Labeled[Framed[f[i]], $KernelID]], {i, 12}]]Scheduling larger evaluations first usually leads to better load balancing:
AbsoluteTiming[WaitAll[Table[ParallelSubmit[{t}, Pause[t];t], {t, 1, 7}]]]AbsoluteTiming[WaitAll[Table[ParallelSubmit[{t}, Pause[t];t], {t, 7, 1, -1}]]]Use LocalSubmit for a single evaluation to be run concurrently:
LocalSubmit[$ProcessID, HandlerFunctions -> <|"TaskFinished" -> ((processID = #EvaluationResult)&)|>,
HandlerFunctionsKeys -> "EvaluationResult"
]Obtain its result after it has finished:
processIDUse LocalEvaluate to perform the same evaluation in a separate local kernel and wait for the result:
LocalEvaluate[$ProcessID]Use ParallelSubmit to perform the same evaluation in a parallel subkernel:
job = ParallelSubmit[$ProcessID]Schedule the evaluation and wait for the result:
WaitAll[job]Possible Issues (3)
ParallelSubmit does not evaluate its arguments on the master kernel:
WaitAll[Table[ParallelSubmit[2 ^ i], {i, 10}]]Use a closure to insert the values of local variables into the expressions to be evaluated:
WaitAll[Table[ParallelSubmit[{i}, 2 ^ i], {i, 10}]]Use With to insert the values of local variables:
WaitAll[Table[With[{i = i}, ParallelSubmit[2 ^ i]], {i, 10}]]Side effects are local to each evaluation:
results = {};
WaitAll[Table[ParallelSubmit[{p}, If[PrimeQ[2 ^ p - 1], AppendTo[results, p]];], {p, 2000, 3000}]];
resultsUse a shared variable to support global side effects:
SetSharedVariable[global]global = {};
WaitAll[Table[ParallelSubmit[{p}, If[PrimeQ[2 ^ p - 1], Quiet[AppendTo[global, p]]];], {p, 2000, 3000}]];
globalThere is a considerable overhead for scheduling trivial calculations:
AbsoluteTiming[WaitAll[Table[ParallelSubmit[{i}, N[Sin[i]]], {i, 1000}]];]The overhead is smaller for generating fewer, but larger, evaluation units:
AbsoluteTiming[ParallelTable[N[Sin[i]], {i, 1000}, Method -> "CoarsestGrained"];]A sequential evaluation avoids all communication overhead:
AbsoluteTiming[Table[N[Sin[i]], {i, 1000}];]Neat Examples (2)
Parallelize a functional operation by functional composition with ParallelSubmit:
Map[f, {a, b, c, d}]WaitAll[Map[Composition[ParallelSubmit, f], {a, b, c, d}]]Watch the scheduling of evaluations taking vastly varying amounts of time:
factors = Table[ParallelSubmit[{i}, Plus@@FactorInteger[2 ^ i - 1][[All, 2]]], {i, 195, 170, -1}];
PrintTemporary[factors];
WaitAll[factors]See Also
WaitAll WaitNext DistributeDefinitions EvaluationObject AbortKernels LocalSubmit
Function Repository: EvaluationObjectState
Related Guides
Related Workflows
- Run a Computation in Parallel
History
Text
Wolfram Research (2008), ParallelSubmit, Wolfram Language function, https://reference.wolfram.com/language/ref/ParallelSubmit.html.
CMS
Wolfram Language. 2008. "ParallelSubmit." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ParallelSubmit.html.
APA
Wolfram Language. (2008). ParallelSubmit. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ParallelSubmit.html
BibTeX
@misc{reference.wolfram_2026_parallelsubmit, author="Wolfram Research", title="{ParallelSubmit}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/ParallelSubmit.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_parallelsubmit, organization={Wolfram Research}, title={ParallelSubmit}, year={2008}, url={https://reference.wolfram.com/language/ref/ParallelSubmit.html}, note=[Accessed: 13-June-2026]}