PDC Lecture 14 MPI Sockets and Memory Models
PDC Lecture 14 MPI Sockets and Memory Models
Lecture – 14
INSTRUCTOR: MUHAMMAD ARSALAN RAZA
2
Hybrid model
Memory Models
Process Interaction:
Process interaction relates to the mechanisms by which parallel processes can communicate with each other.
The most common forms of interaction are shared memory and message passing, but interaction can also be
implicit. It is also known as the Process-centric approach.
Shared Memory
Distributed Memory
Implicit Interaction
Lahore Garrison University
6
Shared Memory
Parallel processes share a global address space that they read and write to asynchronously.
Asynchronous concurrent access can lead to race conditions, and mechanisms such as mutex locks, counting
semaphores, and monitors can be used to avoid these.
Conventional multi-core processors directly support shared memory, which many parallel programming
languages and libraries are designed to exploit, such as Cilk, OpenMP, and Threading Building Blocks.
A distributed memory system consists of multiple computers, known as nodes, inter-connected by message
passing network.
Each node acts as an autonomous computer having a processor, a local memory, and sometimes I/O devices.
In this case, all local memories are private and are accessible only to the local processors. Therefore, the
In an implicit model, no process interaction is visible to the programmer and instead the compiler and/or runtime is
responsible for performing it.
Examples of implicit parallelism are with domain-specific languages, where the concurrency within high-level operations
is prescribed functional programming languages, because the absence of side-effects allows non-dependent functions to
be executed in parallel.
However, this kind of parallelism is difficult to manage and functional languages such as Concurrent
Haskell, and Concurrent ML provide features to manage parallelism explicitly and correctly.
Example; If a particular problem involves performing the same operation on a group of numbers, a language that
provides implicit parallelism might allow the programmer to write the instruction as:
Sockets are rather low level, and the programming mistakes can be easily made. However, the way that
they are used is often the same (such as in a client-server setting).
ZeroMQ provides a higher level of expression by pairing sockets: one for sending messages at process P
and a corresponding one at process Q for receiving messages.
All communication is asynchronous.
Three patterns
Request-reply
Publish-subscribe
Pipeline
MPI
Example
MPI C-
Program
Example
18
Lesson Review
SHARED OPEN MP
MEMORY
URL:
https://docs.oracle.com/javase/tutorial/networking/sockets/
Google Search Engine