Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
A version of ParallelMap with incremental progress display
| ResourceFunction["ParallelMapProgress"][f,expr] evaluates ParallelMap[f,expr] and displays incremental progress information, including an estimated time to completion. | 
| DistributedContexts | $DistributedContexts | specifies which symbols appearing in expr have their definitions automatically distributed to all available kernels before the computation | 
| Method | "FinestGrained" | specifies the parallelization method to use | 
Find Mersenne primes:
| In[1]:= | ![res = ResourceFunction["ParallelMapProgress"][PrimeQ[2^# - 1] &, Range[9601, 12000]];](https://www.wolframcloud.com/obj/resourcesystem/images/135/135c849b-ae8c-4532-a788-39e5cfcf187e/1a48f9ecd52995db.png) | 

Perform a series of calculations with large integers:
| In[2]:= | ![res = ResourceFunction[
   "ParallelMapProgress"][{#, Total[FactorInteger[10^60 + #][[All, 2]]]} &, Range[1000], Method -> "ItemsPerEvaluation" -> 4];](https://www.wolframcloud.com/obj/resourcesystem/images/135/135c849b-ae8c-4532-a788-39e5cfcf187e/29f8ff644bc32d52.png) | 

The stop button will gracefully terminate the computation without aborting the kernels:
| In[3]:= | ![res = ResourceFunction[
   "ParallelMapProgress"][{#, Total[FactorInteger[10^60 + #][[All, 2]]]} &, Range[1000], Method -> "ItemsPerEvaluation" -> 4];](https://www.wolframcloud.com/obj/resourcesystem/images/135/135c849b-ae8c-4532-a788-39e5cfcf187e/5b25892544638a8e.png) | 

For immediate termination, abort the computation:
| In[4]:= | ![res = ResourceFunction[
   "ParallelMapProgress"][{#, Total[FactorInteger[10^60 + #][[All, 2]]]} &, Range[1000], Method -> "ItemsPerEvaluation" -> 4];](https://www.wolframcloud.com/obj/resourcesystem/images/135/135c849b-ae8c-4532-a788-39e5cfcf187e/792f833ab0f0309c.png) | 
| Out[4]= |  | 
By default, definitions in the current context are distributed automatically:
| In[5]:= | ![remote[x_] := {$KernelID, x^3}](https://www.wolframcloud.com/obj/resourcesystem/images/135/135c849b-ae8c-4532-a788-39e5cfcf187e/2bc9de8f81d37c26.png) | 
| In[6]:= | ![ResourceFunction["ParallelMapProgress"][remote, {1, 2, 3, 4}]](https://www.wolframcloud.com/obj/resourcesystem/images/135/135c849b-ae8c-4532-a788-39e5cfcf187e/6ae1506fa3f0b97c.png) | 
| Out[6]= |  | 
Do not distribute any definitions of functions. In this case, the definition of local is applied only after the results are returned to the local kernel:
| In[7]:= | ![local[x_] := {$KernelID, x^2}](https://www.wolframcloud.com/obj/resourcesystem/images/135/135c849b-ae8c-4532-a788-39e5cfcf187e/63b94535395615c3.png) | 
| In[8]:= | ![ResourceFunction["ParallelMapProgress"][local, {1, 2, 3, 4}, DistributedContexts -> None]](https://www.wolframcloud.com/obj/resourcesystem/images/135/135c849b-ae8c-4532-a788-39e5cfcf187e/1b483f575560c0ad.png) | 
| Out[8]= |  | 
If the larger computations are near the end of the input list, timing estimates will be inaccurate:
| In[9]:= | ![ResourceFunction["ParallelMapProgress"][
 Timing[Inverse[RandomReal[{-1, 1}, {#, #}]]; #] &, 2^Range[13]]](https://www.wolframcloud.com/obj/resourcesystem/images/135/135c849b-ae8c-4532-a788-39e5cfcf187e/6f60880502454689.png) | 
| Out[9]= |  | 

This work is licensed under a Creative Commons Attribution 4.0 International License