Seleziona una delle parole chiave a sinistra ...

Numerical ComputationParallel Computing

Momento della lettura: ~5 min

Parallel computing involves decomposing a computational task into subtasks which may be performed concurrently.

The problem of adding the numbers in an array is readily parallelizable, since we can subdivide the array, sum the values in each smaller array, and add up the resulting sums at the end.

You can start a Julia session with n worker processes via julia -p n and loading the distributed computing tools with using Distributed.

  • pmap(f,A) applies the function f to each element of the collection A, taking advantage of the available worker processes. For example, to check the primality of the positive integers up to 100,000 in parallel:

    using Distributed, Primes
  • If (op) is an operator, then @distributed (op) for ... end assigns a subrange of the given for loop to each worker. The values returned by the body of the loop are combined using the operator op. For example, to sum a million random Gaussians in parallel fashion:

    using Distributed
    @distributed (+) for i=1:1_000_000

Congratulations! You have finished the Data Gymnasia numerical computation course.

Bruno Bruno