GithubHelp home page GithubHelp logo

danielwe / distributed.jl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from julialang/distributed.jl

0.0 1.0 0.0 462 KB

Create and control multiple Julia processes remotely for distributed computing. Ships as a Julia stdlib.

Home Page: https://docs.julialang.org/en/v1/stdlib/Distributed/

License: MIT License

Julia 100.00%

distributed.jl's Introduction

Distributed

The Distributed package provides functionality for creating and controlling multiple Julia processes remotely, and for performing distributed and parallel computing. It uses network sockets or other supported interfaces to communicate between Julia processes, and relies on Julia's Serialization stdlib package to transform Julia objects into a format that can be transferred between processes efficiently. It provides a full set of utilities to create and destroy new Julia processes and add them to a "cluster" (a collection of Julia processes connected together), as well as functions to perform Remote Procedure Calls (RPC) between the processes within a cluster. See API for details.

This package ships as part of the Julia stdlib.

Using development versions of this package

To use a newer version of this package, you need to build Julia from scratch. The build process is the same as any other build except that you need to change the commit used in stdlib/Distributed.version.

It's also possible to load a development version of the package using the trick used in the Section named "Using the development version of Pkg.jl" in the Pkg.jl repo, but the capabilities are limited as all other packages will depend on the stdlib version of the package and will not work with the modified package.

API

The public API of Distributed consists of a variety of functions for various tasks; for creating and destroying processes within a cluster:

  • addprocs - create one or more Julia processes and connect them to the cluster
  • rmprocs - shutdown and remove one or more Julia processes from the cluster

For controlling other processes via RPC:

  • remotecall - call a function on another process and return a Future referencing the result of that call
  • Future - an object that references the result of a remotecall that hasn't yet completed - use fetch to return the call's result, or wait to just wait for the remote call to finish
  • remotecall_fetch - the same as fetch(remotecall(...))
  • remotecall_wait - the same as wait(remotecall(...))
  • remote_do - like remotecall, but does not provide a way to access the result of the call
  • @spawnat - like remotecall, but in macro form
  • @spawn - like @spawn, but the target process is picked automatically
  • @fetch - macro equivalent of fetch(@spawn expr)
  • @fetchfrom - macro equivalent of fetch(@spawnat p expr)
  • myid - returns the Int identifier of the process calling it
  • nprocs - returns the number of processes in the cluster
  • nworkers - returns the number of worker processes in the cluster
  • procs - returns the set of IDs for processes in the cluster
  • workers - returns the set of IDs for worker processes in the cluster
  • interrupt - interrupts the specified process

For communicating between processes in the style of a channel or stream:

  • RemoteChannel - a Channel-like object that can be put! to or take! from any process

For controlling multiple processes at once:

  • WorkerPool - a collection of processes than can be passed instead a process ID to certain APIs
  • CachingPool - like WorkerPool, but caches functions (including closures which capture large data) on each process
  • @everywhere - runs a block of code on all (or a subset of all) processes and waits for them all to complete
  • pmap - performs a map operation where each element may be computed on another process
  • @distributed - implements a for-loop where each iteration may be computed on another process

Process Identifiers

Julia processes connected with Distributed are all assigned a cluster-unique Int identifier, starting from 1. The first Julia process within a cluster is given ID 1, while other processes added via addprocs get incrementing IDs (2, 3, etc.). Functions and macros which communicate from one process to another usually take one or more identifiers to determine which process they target - for example, remotecall_fetch(myid, 2) calls myid() on process 2.

!!! note Only process 1 (often called the "head", "primary", or "master") may add or remove processes, and manages the rest of the cluster. Other processes (called "workers" or "worker processes") may still call functions on each other and send and receive data, but addprocs/rmprocs on worker processes will fail with an error.

distributed.jl's People

Contributors

jeffbezanson avatar vtjnash avatar stefankarpinski avatar tkelman avatar kristofferc avatar staticfloat avatar vchuravy avatar fredrikekre avatar timholy avatar amitmurthy avatar tanmaykm avatar keno avatar c42f avatar dilumaluthge avatar kshyatt avatar ararslan avatar quinnj avatar viralbshah avatar krynju avatar jpsamaroo avatar ssikdar1 avatar stevengj avatar mgkuhn avatar andrioni avatar rfourquet avatar sacha0 avatar aviatesk avatar nalimilan avatar jishnub avatar musm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.