Skip to main content

A pseudo-application that can be used as a black box to reproduce Amdahl's Law

Project description

"Black Box" Amdahl's Law Simulator

This Python module contains a pseudo-application that can be used as a black box to reproduce Amdahl's Law. It does not do real calculations, nor any real communication, so can easily be overloaded.

The application is installed as a Python module with a shell script wrapper. The only requirements are a Message Passing Interface (MPI) library and the MPI for Python module, mpi4py.

Background

Amdahl's Law posits that some unit of work comprises a proportion $p$ that benefits from parallel resources, and a proportion $s$ that is constrained to execute in serial. The theoretical maximum speedup achievable for such a workload is

$$ S = \frac{1}{s + p/N} $$

where $S$ is the speedup relative to performing all of the work in serial and $N$ is the number of parallel workers. A plot of $S$ vs. $N$ ought to look like this, for $p = 0.89$ (since $s = 1 - p = 0.11$):

  5┬────────┼────────┼────────┼────────·────────┼────────┼────────┼────────┼────────*
   │                                  ·                                             │
   │                                 ·                                     *        │
   │                                ·                                               │
   │                               ·                              *                 │
   │                              ·                                                 │
   │                             ·                                                  │
   │                            ·                        *                          │
   │                           ·                                                    │
  4┼                          ·                                                     ┼
   │                         ·                  *                                   │
   │                        ·                                                       │
   │                       ·                                                        │
   │                      ·                                                         │
   │                     ·             *                                            │
S  │                    ·                                                           │
p  │                   ·                                                            │
e  │                  ·                                                             │
e 3┼                 ·        *                                                     ┼
d  │                ·                                                               │
u  │               ·                                                                │
p  │              ·                                                                 │
   │             ·                                                                  │
   │            ·    *                                                              |
   │           ·                                                                    │
   │          ·                                                                     │
   │         ·                                                                      │
  2┼        ·                                                                       ┼
   │       ·                                                                        │
   │      · *                                                                       │
   │     ·                                                                          │
   │    ·                                                                           │
   │   ·                                                                            │
   │  ·                                                                             │
   │ ·                                                                              │
   │·                                                                               │
  1*────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
   1        2        3        4        5        6        7        8        9       10
                                         Workers

"Ideal scaling" ($p = 1$) is represented by the dotted line, $S = N$.

This graph shows there is a speed limit for every workload, and diminishing returns on throwing more parallel processors at a problem. It is worth running a "scaling study" to assess how far away that speed limit might be for the given task.

Setup

An external requirement is a Message Passing Interface (MPI) library, such as OpenMPI or MPICH. To check whether you have one installed, run

which mpirun

If the command returns a filesystem path, e.g. /usr/bin/mpirun, you're all set! If not, contact an administrator or use your operating system's package manager to install both the binaries and the development headers for either OpenMPI or MPICH.

Once an MPI library is installed, you should be able to install the amdahl package and its dependencies using pip:

python3 -m pip install --user amdahl

Usage

Once installed, you can run the program using

mpirun -np 2 amdahl

You should see something like the following output:

Doing 30 seconds of 'work' on 2 processors, which should take 18 seconds
with 0.8 parallel proportion of the workload.

  Hello, World! I am process 0 of 2. I will do all the serial 'work' for 6 seconds.
  Hello, World! I am process 0 of 2. I will do parallel 'work' for 10 seconds.
  Hello, World! I am process 1 of 2. I will do parallel 'work' for 14 seconds.

Total execution time (according to rank 0): 16 seconds

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amdahl-0.4.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amdahl-0.4.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file amdahl-0.4.1.tar.gz.

File metadata

  • Download URL: amdahl-0.4.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for amdahl-0.4.1.tar.gz
Algorithm Hash digest
SHA256 a3c2a2119beee6096f954b0285b336b6c2b19ae2a24f8bbbe07d2a0805e4c825
MD5 d5ed0a73ed8e3879680b9ca2fbe8ace2
BLAKE2b-256 535d82f5a1fd67c17503d888beab3d0eba1b34ea2b92020edee01701cac75ee7

See more details on using hashes here.

Provenance

The following attestation bundles were made for amdahl-0.4.1.tar.gz:

Publisher: python-publish.yml on hpc-carpentry/amdahl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file amdahl-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: amdahl-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for amdahl-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e5425034544a20f14a824205adf5202c4e6e3d44643dc1726655566c737086d
MD5 ecd0053306bcc2c93554e9c48fbc86c5
BLAKE2b-256 aa92e77bcd3e0a1d3d5dfc82a61aea9b07377e708ddc19ae961d6b2fb2685e0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for amdahl-0.4.1-py3-none-any.whl:

Publisher: python-publish.yml on hpc-carpentry/amdahl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page