Modelos de Pase de Mensajes MPI MPICH y LAM PVM Camacho, Duilmer Hansson, Martin Márquez, Ana...

Post on 23-Jan-2016

215 views 0 download

Tags:

Transcript of Modelos de Pase de Mensajes MPI MPICH y LAM PVM Camacho, Duilmer Hansson, Martin Márquez, Ana...

Modelos de Pase de Mensajes

MPIMPICH y LAM

PVM Camacho, DuilmerHansson, Martin

Márquez, Ana GabrielaSagarzazu, Iñaki

Universidad Simón BolívarSistemas Operativos IIIProf. Yudith Cardinale

MPIIntroducción

• ¿Que es MPI?Message Passing Interface

• Handles de MPI• Errores en MPI

MPI_ERRORS_ARE_FATAL

MPI_ERRORS_RETURN

• Inicializando y finalizando. Ejemplo básico

#include <mpi.h>

Main(int argc, char **argv)

{

MPI_Init(&argc, &argv);

/* Parte principal del Programa */

if ()

MPI_ABORT(comm, errcode);

/* Terminar el MPI */

MPI_Finalize();

Exit(0);

}

MPIIntroducción

MPIConceptos Básicos

• Procesos (Grupo, Rango)• Grupos

• MPI_COMM_GROUP• MPI_GROUP_EMPTY con no miembros.• MPI_GROUP_NULL es el valor usado para handles de

grupos invalidos.• MPI_GROUP_FREE(group) • MPI_GROUP_SIZE(group, size) • MPI_GROUP_RANK(group, rank)

• Contextos

MPIConceptos Básicos (cont)

• Topologías virtuales• Communicators MPI_COMM_WORLD

• int MPI_Comm_size(MPI_Comm comm, int *size)

• MPI_COMM_DUP(comm, newcomm)

• MPI_COMM_CREATE(comm, group, newcomm)

• MPI_COMM_FREE(comm)

• Inter-Communicators e Intra-Communicators

MPIComunicación Punto a Punto

• Blocking sendMPI_SEND(buf, count, datatype, dest, tag, comm)

• Mensajes de MPI

• Sobre de Mensajes• Blocking Receive

int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)

DataType ... ... ... ...

MPIManejo de Tipos de datos

• Matching de tipos de datos: con tipo y sin tipo y con datos empaquetados.

CALL MPI_COMM_RANK(comm, rank, ierr)

IF(rank.EQ.0) THEN

CALL MPI_SEND(a(1), 10, MPI_REAL, 1, tag, comm, ierr) ELSE

CALL MPI_RECV(b(1), 15, MPI_REAL, 0, tag, comm, status, ierr)

END IF

• Conversion de Datos•Conversion de tipo•Conversion de representación

MPIModos de Comunicación

• Blocking y Standard• Buffered

int MPI_Bsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)

• Synchronousint MPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)

• Readyint MPI_Rsend(void* buf, int count, MPI_Datatype datatype, int

dest, int tag, MPI_Comm comm)

MPISemantica de Comunicación PP

• Mensajes en ordenCALL MPI_COMM_RANK(comm, rank, ierr)

IF (rank.EQ.0) THEN

CALL MPI_BSEND(buf1, count, MPI_REAL, 1, tag, comm, ierr)

CALL MPI_BSEND(buf2, count, MPI_REAL, 1, tag, comm, ierr)

ELSE ! rank.EQ.1

CALL MPI_RECV(buf1, count, MPI_REAL, 0, MPI_ANY_TAG, comm, status, ierr)

CALL MPI_RECV(buf2, count, MPI_REAL, 0, tag, comm, status, ierr)

END IF

MPISemantica de Comunicación PP

• Progreso• Justicia• Limitaciones de recursos

CALL MPI_COMM_RANK(comm, rank, ierr)

IF (rank.EQ.0) THEN

CALL MPI_SEND(sendbuf, count, MPI_REAL, 1, tag, comm, ierr)

CALL MPI_RECV(recvbuf, count, MPI_REAL, 1, tag, comm, status, ierr)

ELSE ! rank.EQ.1

CALL MPI_RECV(recvbuf, count, MPI_REAL, 0, tag, comm, status, ierr)

CALL MPI_SEND(sendbuf, count, MPI_REAL, 0, tag, comm, ierr) END IF

MPIComunicación Non-Blocking

• int MPI_Isend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)

• int MPI_Ibsend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)

• int MPI_Issend(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)

• int MPI_Irecv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request)

MPICompletación de Comunicación

• MPI_WAIT y MPI_TEST• MPI_WAITANY • MPI_TESTANY • MPI_WAITALL • MPI_TESTALL • MPI_WAITSOME • MPI_TESTSOME

MPIComunicación Colectiva

int MPI_Barrier(MPI_Comm comm ) int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm )

int MPI_Gather(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm)

int MPI_Gatherv(sendbuf, sendcount, sendtype, recvbuf, *recvcounts, *displs, recvtype, root, comm)

  int MPI_Scatter(void* sendbuf, sendcount, sendtype, void* recvbuf, recvcount, recvtype, root, comm)

int MPI_Scatterv(void* sendbuf, *sendcounts, *displs, sendtype, void* recvbuf, recvcount, recvtype, root, comm)

MPIComunicación Colectiva

MPIComunicación Colectiva

• Todos los procesos llaman a las rutinas• La sintaxis es consistente con las

llamadas a comunicación punto a punto• Existe el proceso root.• Type matching es más estricto• Cantidad de datos en send debe ser

igual a la del receive

MPIOperaciones Extendidas MPI-2

• Creación de Inter-communicators• Dos nuevas rutinas colectivas• Un all-to-all generalizado• Operaciones de Intra-communicator• MPI_BCAST,

• MPI_GATHER, MPI_GATHERV,

• MPI_SCATTER, MPI_SCATTERV,

• MPI_ALLGATHER, MPI_ALLGATHERV,

• MPI_ALLTOALL, MPI_ALLTOALLV, MPI_ALLTOALLW

• MPI_REDUCE, MPI_ALLREDUCE,

• MPI_REDUCE_SCATTER,

• MPI_BARRIER.

MPIAdministración y Creación de Procesos

• Creando Procesosint MPI_Comm_spawn(char *command, char *argv[], int maxprocs, MPI_Info info, int root, MPI_Comm comm, MPI_Comm *intercomm, int array_of_errcodes[])

int MPI_Comm_spawn_multiple(int count, char *array_of_commands[], char **array_of_argv[], int array_of_maxprocs[], MPI_Info array_of_info[], int root, MPI_Comm comm, MPI_Comm *intercomm, int array_of_errcodes[])

MPICliente Servidor

• El servidorMPI_Open_port(MPI_INFO_NULL, port_name); MPI_Publish_name("ocean", MPI_INFO_NULL, port_name); MPI_Comm_accept(port_name, MPI_INFO_NULL, 0, MPI_COMM_SELF, &intercomm); /* do something with intercomm */ MPI_Unpublish_name("ocean", MPI_INFO_NULL, port_name);

• El clienteMPI_Lookup_name("ocean", MPI_INFO_NULL, port_name); MPI_Comm_connect( port_name, MPI_INFO_NULL, 0, MPI_COMM_SELF, &intercomm);

MPICHArquitectura

Principios guías del diseño

• DesempeñoMaximizar la cantidad de código que puede ser compartida sin comprometer el desempeño

• PortabilidadProveer una estructura en donde mpich pueda ser portable rápidamente

MPICHArquitectura

Abstract Device Interface

1. Especificar un mensaje para ser enviado o recibido

2. Mover datos entre el ADI y el Hardware3. Administrar listas de mensajes Pendientes4. Proveer información básica sobre el

ambiente de ejecución

MPICHArquitectura

ADI - Channel Interface

• Eager Protocol• Rendezvouz Protocol• Get Protocol

MPICHArquitectura

ADI – Lower Level

• Chameleon• Shared Memory• Specialized• SCI

LAMLocal Area Multicomputer

Historia

• Desarrollado en el Ohio Supercomputer Center• Existe de antes del MPI y fue adoptado para

implementar la interfaz de MPI

LAMLocal Area Multicomputer

Características

• convierte una red de estaciones de trabajo en una computadora paralela virtual

• Amplia la capacidad de monitoreo (tunning y debugging)

• Monitoreo Activado – comunicación a través de demonios, es posible habilitar la comunicación directa entre clientes.

LAM vs. MPICH

Short Message Protocol

Long Message Protocol

LAMEncabezado + Mensaje

es enviado en un mensaje

Dividido en paquetes. Se envia el primero,

una vez que el sender recibe un ack del

receiver procede a enviar el resto.

MPICH Eager ProtocolRendezvouz Protocol

Get Protocol

LAM vs. MPICH

MTUMaximun Transmission

Unit

Communications Channels

LAM Aumentar el MTU mejora el desempeño

del LAM, si embargo se disminuye el

desempeño del MPICH. En ambos casos

aumenta la latencia

Se establece una red completamente

conectada al momento de la inicialización

MPICHSe realizan las

conecciones con base en la demanda

LAM vs. MPICHPing

LAM vs. MPICHPing-Pong

LAM vs. MPICHBroadcast

LAM vs. MPICHGather

LAM vs. MPICHAll To All

PVM

• Introducción• Atributos

• User-configured host pool• Translucent access to hardware• Process-based computation• Explicit message-passing model• Heterogeneity support• Multiprocessor support

PVM

• Compuesto por:• Daemon• Library of PVM interface routines

• Basic Programming techniques• Common Parallel Programming Paradigms

• Crowd– Master-slave– The node only

• Tree

PVM Basic Programming techniques

• Data Descomposition• Funtion Descomposition

1

6

78

543

2

9

PVMUser Interface

• Process Control• Information • Dynamic Configuration• Signaling• Setting and Getting Options• Message Passing• Dynamic Process Groups

PVM

• Message Passing• pvm_initsend()• pvm_pk*()• pvm_send()• pvm_mcast()• pvm_recvf()

• Message Buffers• pvm_initsend()• pvmDataDefault• pvm_mkbufer()• pvm_send(dst ,tag)

PVM

• Packing Data• pvm_pkbyte(char *cp, int nitem, int strike)• pvm_pkint(int *cp, int nitem, int strike)• pvm_pkstr(char *cp)

• Sending and Receiving Data• pvm_send(int tid,int msgtag)• pvm_mcast(int *tids, int ntask, int msgtag)• pvm_recv(int tid,msgtag)

PVM

• Unpacking Data• pvm_upkbyte(char *cp,int nitem,int strike)• pvm_upkint(int *np, int nitem,int strike)• Pvm_upkstr(char *cp)

PVMEjemplo

• Hello.c#include "pvm3.h"main(){ int cc, tid, msgtag; char buf[100]; printf("i'm t%x\n", pvm_mytid()); cc = pvm_spawn("hello_other",(char**)0,0,"", 1,&tid);  if (cc == 1){ msgtag = 1;

pvm_recv(tid, msgtag); pvm_upkstr(buf);

printf("from t%x: %s\n", tid, buf); }else { printf("can't start hello_other\n"); }

pvm_exit();}

PVMEjemplo

• Hello_other.c#include "pvm3.h" main(){

int ptid, msgtag; char buf[100]; ptid = pvm_parent();  strcpy(buf, "hello, world from "); gethostname(buf + strlen(buf), 64);

msgtag = 1; pvm_initsend(PvmDataDefault); pvm_pkstr(buf); pvm_send(ptid, msgtag); pvm_exit();}

TituloSubtítulo

• Punto 1• Punto 2

TituloSubtítulo

• Punto 1• Punto 2

TituloSubtítulo

• Punto 1• Punto 2

TituloSubtítulo

• Punto 1• Punto 2

TituloSubtítulo

• Punto 1• Punto 2

TituloSubtítulo

• Punto 1• Punto 2