1 / 15

MPI

MPI. MPI Clase 3. “Mas P2P” en C con MPI. Código seguro IF (rank.eq.0) THEN CALL MPI_SEND(sbuff,count,MPI_REAL,1,tag,comm,ierr) CALL MPI_RECV(rbuff,count,MPI_REAL,1,tag,comm,status,ierr) ELSE IF (rank.eq.1) THEN CALL MPI_RECV(rbuff,count,MPI_REAL,0,tag,comm,status,ierr)

hua
Download Presentation

MPI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MPI MPI Clase 3

  2. “Mas P2P” en C con MPI Código seguro IF (rank.eq.0) THEN CALL MPI_SEND(sbuff,count,MPI_REAL,1,tag,comm,ierr) CALL MPI_RECV(rbuff,count,MPI_REAL,1,tag,comm,status,ierr) ELSE IF (rank.eq.1) THEN CALL MPI_RECV(rbuff,count,MPI_REAL,0,tag,comm,status,ierr) CALL MPI_SEND(sbuff,count,MPI_REAL,0,tag,comm,ierr) END IF Hola Mundo C DEAD LOCK IF (rank.eq.0) THEN CALL MPI_RECV(rbuff,count,MPI_REAL,1,tag,comm,status,ierr) CALL MPI_SEND(sbuff,count,MPI_REAL,1,tag,comm,ierr) ELSE IF (rank.eq.1) THEN CALL MPI_RECV(rbuff,count,MPI_REAL,0,tag,comm,status,ierr) CALL MPI_SEND(sbuff,count,MPI_REAL,0,tag,comm,ierr) END IF

  3. Non-blocking Send/Recv • MPI_ISEND(buff,count,datatype,dest,tag,comm,request) IN buff intial address of message buffer IN count number of entries to send (int) IN datatype datatype of each entry (handle) IN dest rank of destination (int) IN tag message tag (int) IN comm communicator (handle) OUT request request handle (handle) • MPI_IRECV(buff,count,datatype,dest,tag,comm,request) OUT buff intial address of message buffer IN count number of entries to send (int) IN datatype datatype of each entry (handle) IN dest rank of destination (int) IN tag message tag (int) IN comm communicator (handle) OUT request request handle (handle) • request manejador utilizado para seguir el estado de la comunicación y esperar para que se complete. El usuario no puede sobrescribir el buffer de envio hasta que se complete la operación.

  4. Completando la operación No Bloqueante • MPI_WAIT(request,status) INOUT request handle (handle) OUT status object (status) • MPI_TEST(request,flag,status) INOUT request request handle (handle) OUT flag true if operation complete (logical) OUT status status object (Status) • MPI WAIT retorna cuando la operación se completo. El status se retorno en el recv • MPI TEST retorna inmediatamente con flag = true si al operación del manejador request se comeplto (status es similar a MPI WAIT).

  5. Operación No Bloqueante. Ejemplo i f ( rank == 0) { MPI_Irecv ( b ,100 ,MPI REAL,1 ,19 ,MPI COMM WORLD,& request ) ; MPI_Send ( a ,100 ,MPI REAL,1 ,17 ,MPI COMMWORLD) ; MPI_Wait (&request ,& s tatus ) ;} else i f ( rank == 1) { MPI_Irecv ( b ,100 ,MPI REAL,0 ,17 ,MPI COMM WORLD,& request ) ; MPI_Send ( a ,100 ,MPI REAL,0 ,19 ,MPI COMMWORLD) ; MPI_Wait (&request ,& status ) ;} MPI_Get_count (& status ,MPI REAL,& s t a t c o u n t ) ; p r i n t f ( ” Exchange complete : process %d of %dnn ” , rank , nprocs ) ; p r i n t f ( ” source %d , tag %d , count %dnn ” , s tatus .MPI SOURCE, s tatus .MPI TAG , s t a t c o u n t ) ;

  6. Algebra de matrices Producto Interno  TP1 Multiplicando matrices A*b A*B • Algoritmo de FOX

  7. Algebra de matrices Tipo de Matrices DENSAS BANDAS SPARSE

  8. Algebra de matrices • Densas: Algoritmos triviales o especiales (FOX) • Package storage LAPACK-ScaLAPACK/PLASMA /MAGMA

  9. Algebra de matrices • Bandas.. Bandwith

  10. Algebra de matrices • Sparse • Vector de valores • Vector de columnas • Vector de índices de cada fila Val = 1 -1 -3 -1 5 4 6 4 -3 6 7 4 -5 col = 1 2 4 1 2 3 4 5 1 3 4 4 5 Ind= 1 4 6 9 12 Simetricas Val = 1 -1 -3 5 4 6 4 7 -5 col = 1 2 4 2 4 5 4 5 Ind= 1 4 5 8 9

  11. Algebra de matrices • Técnicas de multiplicación en cada caso varían. Lo mas usual, es A*b, y en este caso hay que ver que dato de matriz tengo guardado y multiplicarlo por el vector • Para que se usa? Solución de sistemas de ecuaciones!! Métodos iterativos. Los directos no son paralelizables o lo son con muy baja eficiencia, Cholesky, LU, etc. Los iterativos, son altamente paralelizables ya que en definitiva, implican la multiplicación de una matriz por un vector, muchas veces…

  12. Sistemas lineales A*x=b Métodos Iterativos Jacobi (Matriz diagonal dominanate) Gauss Seidel (variante del Jacobi, Matriz diagonal dominante, o simétrica y definida positiva) Subespacios de Krilov (Grad-conj, Grad Bi-Conj, Residuo min.) converge en N iteraciones, donde N es el tamaño del sistema. Sin embargo, en la presencia de errores de redondeo esta afirmación no se sostiene; además, en la práctica N puede ser muy grande, y el proceso iterativo alcanza una precisión suficiente mucho antes.

  13. Sistemas Lineales • Grad-conj  Simetricas y definidas positivas • Grad-BI-conj  matrices NO simétricas!! • Pre-condicionadores !!!! Son búsquedas de factores que convierten a la matriz en una mejor matriz para hallar la solución. Hay bastantes precondicionadores estándares. Uno muy usual y sencillo es dividir o multiplicar por la Diagonal de la matriz. (Precondicionador de Jacobi)

  14. Sistemas Lineales

  15. ?

More Related