0% found this document useful (0 votes)
3 views17 pages

Meet-7-Parallel Programming Models Bag1

The document discusses various parallel programming models, including Shared Memory, Thread, Message Passing, Data Parallel, and Hybrid models, emphasizing that these models can be implemented on different hardware architectures. It details the Shared Memory and Thread models, highlighting their advantages and disadvantages, as well as their implementations like POSIX Threads and OpenMP. The choice of model often depends on availability and personal preference, with no single best model for all situations.

Uploaded by

Rahmad Syukur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views17 pages

Meet-7-Parallel Programming Models Bag1

The document discusses various parallel programming models, including Shared Memory, Thread, Message Passing, Data Parallel, and Hybrid models, emphasizing that these models can be implemented on different hardware architectures. It details the Shared Memory and Thread models, highlighting their advantages and disadvantages, as well as their implementations like POSIX Threads and OpenMP. The choice of model often depends on availability and personal preference, with no single best model for all situations.

Uploaded by

Rahmad Syukur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

PEMROSESAN

PARALLEL
OKTAF BRILLIAN KHARISMA, ST., MT

www.youtube.com/c/RoboticNusantara
Parallel Programming Models
(Chapter 1)
Pemrosesan Parallel
Agenda
01 Overview

02 Shared Memory Model

03 Thread Model

04
Overview
 There are several parallel programming models in common use:
– Shared Memory
– Threads
– Message Passing
– Data Parallel
– Hybrid
 Parallel programming models exist as an abstraction above hardware
and memory architectures.
 Although it might not seem apparent, these models are NOT specific to a part
icular type of machine or memory architecture. In fact, any of these models c
an (theoretically) be implemented on any underlying hardware.
 Shared memory model on a distributed memory machine: Kendall Square Re
search (KSR) ALLCACHE approach.
– Machine memory was physically distributed, but appeared to the user as
a single shared memory (global address space). Generically, this approach
is referred to as "virtual shared memory".
 Message passing model on a shared memory machine: MPI on SGI Origin
 The SGI Origin employed the CC-NUMA type of shared memory architecture,
where every task has direct access to global memory. However, the ability to s
end and receive messages with MPI, as is commonly done over a network of di
stributed memory machines, is not only implemented but is very commonly us
ed.
Which model to use?

 Which model to use is often a combination of what is


available and personal choice. There is no "best" mod
el, although there certainly are better implementation
s of some models over others.
 The following sections describe each of the models m
entioned above, and also discuss some of their actual
implementations.
Share Memory Model
Shared Memory Model
 In the shared-memory programming model, tasks share a common a
ddress space, which they read and write asynchronously.
 Various mechanisms such as locks / semaphores may be used to co
ntrol access to the shared memory.
 An advantage of this model from the programmer's point of view is th
at the notion of data "ownership" is lacking, so there is no need to sp
ecify explicitly the communication of data between tasks. Program de
velopment can often be simplified.
 An important disadvantage in terms of performance is that it becomes more
difficult to understand and manage data locality.
• Keeping data local to the process that works on it conserves memory acce
sses, cache refreshes and bus traffic that occurs when multiple processes
use the same data.
• Unfortunately, controlling data locality is hard to understand and may be be
yond the control of the average user.
Shared Memory Model: Implementations

 On shared memory platforms, the native compilers translate


user program variables into actual memory addresses, which
are global.
 No common distributed memory platform implementations cu
rrently exist. However, as mentioned previously in the Overvi
ew section, the KSR ALLCACHE approach provided a share
d memory view of data even though the physical memory of t
he machine was distributed.
Thread Model
 In the threads model of parallel programming, a si
ngle process can have multiple, concurrent execu
tion paths.
 Perhaps the most simple analogy that can be use
d to describe threads is the concept of a single pr
ogram that includes a number of subroutines:
– The main program a.out is scheduled to run by the
native operating system. a.out loads and acquires al
l of the necessary system and user resources to run
.
– a.out performs some serial work, and then creates
a number of tasks (threads) that can be scheduled
and run by the operating system concurrently.
– Each thread has local data, but also, shares the e
ntire resources of a.out. This saves the overhead
associated with replicating a program's resources fo
r each thread. Each thread also benefits from a glob
al memory view because it shares the memory spac
e of a.out.
Thread Model (con’t)
• A thread's work may best be described
as a subroutine within the main program
. Any thread can execute any subroutine
at the same time as other threads.
• Threads communicate with each other
through global memory (updating addr
ess locations). This requires synchroniz
ation constructs to insure that more than
one thread is not updating the same glo
bal address at any time.
• Threads can come and go, but a.out re
mains present to provide the necessary
shared resources until the application h
as completed.
 Threads are commonly associated with shar
ed memory architectures and operating syst
ems.
Threads Model Implementations
 From a programming perspective, threads implementations commonly compris
e:
– A library of subroutines that are called from within parallel source code
– A set of compiler directives imbedded in either serial or parallel source cod
e
 In both cases, the programmer is responsible for determining all parallelism.
 Threaded implementations are not new in computing. Historically, hardware ve
ndors have implemented their own proprietary versions of threads. These impl
ementations differed substantially from each other making it difficult for progra
mmers to develop portable threaded applications.
Threads Model Implementations
 Unrelated standardization efforts have resulted in two very different implementations of threa
ds: POSIX Threads and OpenMP.
 POSIX Threads
• Library based; requires parallel coding
• Specified by the IEEE POSIX 1003.1c standard (1995).
• C Language only
• Commonly referred to as Pthreads.
• Most hardware vendors now offer Pthreads in addition to their proprietary threads imple
mentations.
• Very explicit parallelism; requires significant programmer attention to detail.
Threads Model: OpenMP
 OpenMP
– Compiler directive based; can use serial code
– Jointly defined and endorsed by a group of major computer hardware and software vendors. The Open
MP Fortran API was released October 28, 1997. The C/C++ API was released in late 1998.
– Portable / multi-platform, including Unix and Windows NT platforms
– Available in C/C++ and Fortran implementations
– Can be very easy and simple to use - provides for "incremental parallelism"
 Microsoft has its own implementation for threads, which is not related to the UNIX
POSIX standard or OpenMP.
Thank you
Any Question?

You might also like