Code Monkey home page Code Monkey logo

distributed-sieve-e's Introduction

Distributed Sieve of Eratosthenes

David Briggs

Source files: src/mail-sieve-e/*
Github Page:  https://github.com/iMultiPlay/Distributed-Sieve-e

Default setup (Run "Run Lead.bat") expects 3 machines. Run "Run Lead.bat" once and "Run Follower.bat" twice. Runs on port 10001.

Custom implementation of the Sieve of Eratosthenes (https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes)

Description --

This Sieve is designed to be able to compute primes between several machines (over the internet). 

Rather than listing all of the natural numbers, this sieve starts at 3 and skip counts by two. Each machine recieves an evenly sized chunk to process. If we wanted to compute the primes below 10000 between two machines, each machine would compute chunks of size 5000 (due to optimizations this is lowered to ~2500).

Machines are ordered starting at 1, with the lead machine starting at one. All other machines are followers, which report to the lead machine.

When machines mark a new prime, they report a vector of the machine number, prime position (in their chunk), and the prime. All machines with a number greater than the reporting machine recieve and process this vector. 

All communication between machines is done with sockets, with the lead computer acting as the middle man between all of the following machines.

Algorithm --

Lead:
- Mark first non-zero number in the chunk as prime
- Send prime vector to respective computers 
- Mark composites of prime
- Find next non-zero number, repeat until there is no non-zero numbers after last prime.
-> if no non-zero primes left, elect next machine in sequence as lead.

Follower:
- Wait for prime vector.
- Process prime vector, marking all composites of the prime number.
- If given an appoint sequence, check if appoint sequence is from previous machine. If it is, start sieve as Lead machine.
- Repeat.

distributed-sieve-e's People

Contributors

dpbriggs avatar

Watchers

 avatar  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.