Industrial Software Engineering

Transkrypt

Industrial Software Engineering
Wprowadzenie

System rozproszony jest kolekcją niezależnych,
autonomicznych komputerów, które dla użytkownika
prezentują się jak jeden komputer.
 Można wyróżnić dwa aspekty tej definicji:
– sprzętowy – komputery są autonomiczne
– użytkownika – dla użytkownika system sprawia
wrażenie jakby pracował na jednym komputerze.
1
1
Klasyfikacja Architektur Równoległych
 ze względu na mechanizm sterowania
- SIMD
- MIMD
 ze względu na organizacje przestrzeni adresowej
- architektura message-passing
- architektura ze współdzielona pamięcią
- UMA
- NUMA
 Ze względu na charakter sieci połączeniowej
- statyczne
- dynamiczne
2
2
Architektura ze współdzieloną pamięcią
P
P
M
P
M
P
Sieć
połączeniowa
M
M
Sieć
połączeniowa
M
P
P
M
UMA
3
NUMA
3
Page 1
1
Typowa architektura message-passing
Sieć Połączeniowa
.............
P
P
P
P
M
M
M
M
P
.............
M
P - Procesor
M - Pamięć
4
4
Dynamiczne sieci połączeniowe
System z przełącznicą krzyżową
Architektura szynowa
Wielostanowa sieć połączeń
5
5
System z przełącznicą krzyżową
M0
M1
M2
M3
M0
P0
P1
P2
P3
P4
Element
przełączający
Pp-1
6
6
Page 2
2
Architektura Szynowa
Pamięć Główna
Szyna
Procesor
Procesor
Procesor
7
7
Wielostanowa sieć połączeń
Banki Pamięci
Procesory
0
1
0
1
Stan 1
Stan 2
Stan n
p-1
b-1
8
8
Koszt & Wydajność
przełącznica
wielostanowa
Liczba procesorów
9
przełącznica
Wydajność
Koszt
szyna
wielostanowa
szyna
Liczba procesorów
9
Page 3
3
Sieć Omega
Przełączenie krzyżowe
Przełączenie proste
000
001
000
001
010
011
010
011
100
101
100
101
110
111
110
111
10
10
Sieci Statyczne
Sieć pełna
Sieć typu gwiazda
Sieć typu magistrala
Sieć typu Ring
Sieć typu Mesh – krata (2D, 3D, z
zapętleniami)
Sieć typu Hypercube (Hiperkostka)
11
11
Sieci Statyczne
12
Siec pełna
Sieć typu gwiazda
Sieć typu magistrala
Sieć typu ring
Dwu-wymiarowa siec typu Mesh
Dwu wymiarowa sieć Mesh z zapętleniami
12
Page 4
4
Sieci Statyczne
Trzy wymiarowa sieć typu Mesh (krata)
Procesor
Element
przełączający
Sieć typu drzewo binarne
13
13
Sieć Hypercube (hiperkostka)
100
0
00
110
10
000
010
101
1
0-D hypercube
01
001
1-D hypercube
0100
0000
011
2-D hypercube
3-D hypercube
1100
0110
0010
0101
0001
111
11
1000
1110
1010
1101
0111
1001
0011
1111
1011
4-D hypercube
14
14
Message passing parallel programming paradigm
several instances of the sequential paradigm are
considered together
separate workers or processes
interact by exchanging information
Memory
Processor
M
M
P
P
M
…
M
P
P
communication network
15
15
Page 5
5
Message Passing Interface – MPI









extended message-passing model
for parallel computers, clusters and heterogeneous networks
not a language or compiler specification
not a specific implementation or product
support send/receive primitives communicating with other
workers
in-order data transfer without data loss
several point-to-point and collective communications
MPI supports the development of parallel libraries
MPI does not make any restrictive assumptions about the
underlying hardware architecture
16
16
Message Passing Interface – MPI
 MPI is very large (125 functions) - MPI’s extensive
functionality requires many functions
 MPI is very small and simple (6 functions) - many
parallel programs can be written with just 6 basic
functions
•
•
•
•
•
•
MPI_Init()
MPI_Finalize()
MPI_Comm_rank()
MPI_Comm_size()
MPI_Send()
MPI_Recv()
17
17
Two main functions
 Initializing MPI
– every MPI program must call this routine once,
before any other MPI routines
MPI_Init(&argc, &argv);
 Clean-up of MPI
– every MPI program must call this routine when all
communications have completed
MPI_Finalize();
18
18
Page 6
6
Communicator
 How do you identify different processes?
– an MPI process can query a communicator for
information about the group
– a communicator returns in rank of the calling
process
MPI_Comm_rank(MPI_COMM_WORLD,
&rank);
 How many processes are contained within a
communicator?
– a communicator returns the # of processes in the
communicator
19
MPI_Comm_size(MPI_COMM_WORLD, &size); 19
An example
#include “mpi.h”
#include <stdio.h>
int main(int argc, char** argv)
{
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf(“Hello, world! I’m %d of %d\n”, rank, size);
MPI_Finalize();
return 0;
}
20
20
Communicator
 Communicator
– MPI processes can only communicate if they share a
communicator
– MPI_COMM_WORLD
- predefined default communicator in MPI_Init()call
21
21
Page 7
7
Sending Messages
communicator
0
1
5 dest
3
2
source 4
communication between only 2 processes
source process sends message to destination process
destination process is identified by its rank in the
communicator
22
22
MPI types
 Message
– an array of elements of a particular MPI datatype
MPI datatype
 basic MPI datatype
-
MPI_(UNSIGNED_)CHAR : signed(unsigned) char
MPI_(UNSIGNED_)SHORT : signed(unsigned) short int
MPI_(UNSIGNED_)INT : signed(unsigned) int
MPI_(UNSIGNED_) LONG : signed(unsigned) long int
MPI_FLOAT : float
MPI_DOUBLE : double
23
23
Send Message
MPI_Send(void* buf, int count, MPI_Datatype datatype, int
dest,
int tag, MPI_COMM_WORLD);
/* (IN) buf : address of the data to be sent */
/* (IN) count : # of elements of the MPI Datatype */
/* (IN) dest : destination process for the message
(rank of the destination process) */
/* (IN) tag : marker distinguishes used message type */
24
24
Page 8
8
Receive Message
MPI_Recv(void
*buf,
int
count,
MPI_Datatype
datatype,
int
source, /* MPI_ANY_SOURCE */
int
tag,
/* MPI_ANY_TAG */
MPI_COMM_WORLD,
MPI_Status *status);
/* (IN) buf : address where the data should be placed*/
/* (IN) count : # of elements of the MPI Datatype */
/* (IN) source : rank of the source of the message */
/* (IN) tag : receives a message having this tag*/
/* (OUT) status : some information to be used at later */
25
25
Page 9
9