Using low-level communications

Julia's native parallel computing model is based on two primitives: remote calls and remote references. At this level, we can give a certain worker a function with arguments to execute with remotecall, and get the result back with fetch. As a trivial example in the following code, we call upon worker 2 to execute a square function on the number 1000:

r1 = remotecall(x -> x^2, 2, 1000) 

This returns Future(2, 1, 15, nothing).

The arguments are: the worker ID, the function, and the function's arguments. Such a remote call returns immediately, thus not blocking the main worker (the REPL in this case). The main process continues executing while the remote worker does the assigned job. The remotecall function returns ...

Get Julia 1.0 Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.