Riječnik

Odaberite jednu od ključnih riječi s lijeve strane ...

Numerical ComputationParallel Computing

Vrijeme čitanja: ~5 min

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

Example
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
    pmap(isprime,2:100_000)
  • 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
      randn()
    end

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

Bruno
Bruno Bruno