Currently, the code is split into two distinct paths depending on if parallel or sequential evaluation of the poll point is being done. This is not ideal because it essentially is duplicating the same code with only minor differences. There is a Julia package called FLoops.jl that provides automatic parallelization of for loops using an executor that can be changed at runtime. There are various executors, including a sequential and a threaded one. Using FLoops.jl for the parallelization aspect then means we only need to change the executor we pass to the loop instead of having to duplicate the code as we currently do. Additionally, there is also a GPU executor for running loops in parallel on a GPU, so we can eventually make use of that once our loop is GPU-compatible (and if the blackbox function is GPU-compatble).
We may also be able to leverage FLoops.jl for doing the opportunistic evaluation, since the underlying library FLoops uses (Transducers.jl) includes an example of early termination in its usage (https://juliafolds.github.io/Transducers.jl/dev/tutorials/tutorial_parallel/#Example:-early-termination). It may be possible we can do something similar in our code.
Currently, the code is split into two distinct paths depending on if parallel or sequential evaluation of the poll point is being done. This is not ideal because it essentially is duplicating the same code with only minor differences. There is a Julia package called FLoops.jl that provides automatic parallelization of for loops using an executor that can be changed at runtime. There are various executors, including a sequential and a threaded one. Using FLoops.jl for the parallelization aspect then means we only need to change the executor we pass to the loop instead of having to duplicate the code as we currently do. Additionally, there is also a GPU executor for running loops in parallel on a GPU, so we can eventually make use of that once our loop is GPU-compatible (and if the blackbox function is GPU-compatble).
We may also be able to leverage FLoops.jl for doing the opportunistic evaluation, since the underlying library FLoops uses (Transducers.jl) includes an example of early termination in its usage (https://juliafolds.github.io/Transducers.jl/dev/tutorials/tutorial_parallel/#Example:-early-termination). It may be possible we can do something similar in our code.