Parallel Programming with Java

Slides:



Advertisements
Similar presentations
MPI Message Passing Interface
Advertisements

Parallel Processing1 Parallel Processing (CS 667) Lecture 9: Advanced Point to Point Communication Jeremy R. Johnson *Parts of this lecture was derived.
Its.unc.edu 1 Collective Communication University of North Carolina - Chapel Hill ITS - Research Computing Instructor: Mark Reed
MPI Collective Communications
Programming Parallel Hardware using MPJ Express
HPDC Spring MPI 11 CSCI-6964: High Performance Parallel & Distributed Computing (HPDC) AE 216, Mon/Thurs. 2 – 3:20 p.m Message Passing Interface.
13 June mpiJava. Related projects mpiJava (Syracuse) JavaMPI (Getov et al, Westminster) JMPI (MPI Software Technology) MPIJ.
1 Parallel Computing—Higher-level concepts of MPI.
A Message Passing Standard for MPP and Workstations Communications of the ACM, July 1996 J.J. Dongarra, S.W. Otto, M. Snir, and D.W. Walker.
SOME BASIC MPI ROUTINES With formal datatypes specified.
Distributed Memory Programming with MPI. What is MPI? Message Passing Interface (MPI) is an industry standard message passing system designed to be both.
1 Parallel Computing—Introduction to Message Passing Interface (MPI)
Parallel Programming in C with MPI and OpenMP
EECC756 - Shaaban #1 lec # 7 Spring Message Passing Interface (MPI) MPI, the Message Passing Interface, is a library, and a software standard.
High Performance Communication using MPJ Express 1 Presented by Jawad Manzoor National University of Sciences and Technology, Pakistan 29 June 2015.
Collective Communication.  Collective communication is defined as communication that involves a group of processes  More restrictive than point to point.
Message Passing Interface. Message Passing Interface (MPI) Message Passing Interface (MPI) is a specification designed for parallel applications. The.
Jonathan Carroll-Nellenback CIRC Summer School MESSAGE PASSING INTERFACE (MPI)
Distributed Systems CS Programming Models- Part II Lecture 17, Nov 2, 2011 Majd F. Sakr, Mohammad Hammoud andVinay Kolar 1.
Message Passing Interface In Java for AgentTeamwork (MPJ) By Zhiji Huang Advisor: Professor Munehiro Fukuda 2005.
Basics of Message-passing Mechanics of message-passing –A means of creating separate processes on different computers –A way to send and receive messages.
Parallel Programming with Java YILDIRAY YILMAZ Maltepe Üniversitesi.
Collective Communication
A Message Passing Standard for MPP and Workstations Communications of the ACM, July 1996 J.J. Dongarra, S.W. Otto, M. Snir, and D.W. Walker.
Parallel Programming with MPI Matthew Pratola
ORNL is managed by UT-Battelle for the US Department of Energy Crash Course In Message Passing Interface Adam Simpson NCCS User Assistance.
Parallel Processing1 Parallel Processing (CS 676) Lecture 7: Message Passing using MPI * Jeremy R. Johnson *Parts of this lecture was derived from chapters.
Parallel Programming and Algorithms – MPI Collective Operations David Monismith CS599 Feb. 10, 2015 Based upon MPI: A Message-Passing Interface Standard.
1 Collective Communications. 2 Overview  All processes in a group participate in communication, by calling the same function with matching arguments.
1 MPI: Message-Passing Interface Chapter 2. 2 MPI - (Message Passing Interface) Message passing library standard (MPI) is developed by group of academics.
Parallel Programming Dr Andy Evans. Parallel programming Various options, but a popular one is the Message Passing Interface (MPI). This is a standard.
HPCA2001HPCA Message Passing Interface (MPI) and Parallel Algorithm Design.
Part I MPI from scratch. Part I By: Camilo A. SilvaBIOinformatics Summer 2008 PIRE :: REU :: Cyberbridges.
Parallel Computing A task is broken down into tasks, performed by separate workers or processes Processes interact by exchanging information What do we.
Parallel Programming with MPI Prof. Sivarama Dandamudi School of Computer Science Carleton University.
CS 838: Pervasive Parallelism Introduction to MPI Copyright 2005 Mark D. Hill University of Wisconsin-Madison Slides are derived from an online tutorial.
Message Passing Programming Model AMANO, Hideharu Textbook pp. 140-147.
MPI Introduction to MPI Commands. Basics – Send and Receive MPI is a message passing environment. The processors’ method of sharing information is NOT.
MPJ Express Alon Vice Ayal Ofaim. Contributors 2 Aamir Shafi Jawad Manzoor Kamran Hamid Mohsan Jameel Rizwan Hanif Amjad Aziz Bryan Carpenter Mark Baker.
MPI (continue) An example for designing explicit message passing programs Advanced MPI concepts.
Parallel Programming with MPI By, Santosh K Jena..
Oct. 23, 2002Parallel Processing1 Parallel Processing (CS 730) Lecture 6: Message Passing using MPI * Jeremy R. Johnson *Parts of this lecture was derived.
MPI Jakub Yaghob. Literature and references Books Gropp W., Lusk E., Skjellum A.: Using MPI: Portable Parallel Programming with the Message-Passing Interface,
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Message-passing Model.
-1.1- MPI Lectured by: Nguyễn Đức Thái Prepared by: Thoại Nam.
Message Passing Programming Based on MPI Collective Communication I Bora AKAYDIN
Message Passing Interface Using resources from
MPI-Message Passing Interface. What is MPI?  MPI is a specification for the developers and users of message passing libraries. By itself, it is NOT a.
Programming Parallel Hardware using MPJ Express By A. Shafi.
COMP7330/7336 Advanced Parallel and Distributed Computing MPI Programming: 1. Collective Operations 2. Overlapping Communication with Computation Dr. Xiao.
1 MPI: Message Passing Interface Prabhaker Mateti Wright State University.
Distributed Processing with MPI International Summer School 2015 Tomsk Polytechnic University Assistant Professor Dr. Sergey Axyonov.
Computer Science Department
Introduction to MPI Programming Ganesh C.N.
MPI Jakub Yaghob.
CS4402 – Parallel Computing
Computer Science Department
Send and Receive.
Collective Communication with MPI
An Introduction to Parallel Programming with MPI
Send and Receive.
More on MPI Nonblocking point-to-point routines Deadlock
Distributed Systems CS
Lecture 14: Inter-process Communication
MPI: Message Passing Interface
More on MPI Nonblocking point-to-point routines Deadlock
Hardware Environment VIA cluster - 8 nodes Blade Server – 5 nodes
Computer Science Department
5- Message-Passing Programming
Parallel Processing - MPI
Presentation transcript:

Parallel Programming with Java Aamir Shafi National University of Sciences and Technology (NUST) http://hpc.seecs.edu.pk/~aamir http://mpj-express.org

Two Important Concepts Two fundamental concepts of parallel programming are: Domain decomposition Functional decomposition

Domain Decomposition Image taken from https://computing.llnl.gov/tutorials/parallel_comp/

Functional Decomposition Image taken from https://computing.llnl.gov/tutorials/parallel_comp/

Message Passing Interface (MPI) MPI is a standard (an interface or an API): It defines a set of methods that are used by application developers to write their applications MPI library implement these methods MPI itself is not a library—it is a specification document that is followed! MPI-1.2 is the most popular specification version Reasons for popularity: Software and hardware vendors were involved Significant contribution from academia MPICH served as an early reference implementation MPI compilers are simply wrappers to widely used C and Fortran compilers History: The first draft specification was produced in 1993 MPI-2.0, introduced in 1999, adds many new features to MPI Bindings available to C, C++, and Fortran MPI is a success story: It is the mostly adopted programming paradigm of IBM Blue Gene systems At least two production-quality MPI libraries: MPICH2 (http://www-unix.mcs.anl.gov/mpi/mpich2/) OpenMPI (http://open-mpi.org) There’s even a Java library: MPJ Express (http://mpj-express.org)

Message Passing Model Message passing model allows processors to communicate by passing messages: Processors do not share memory Data transfer between processors required cooperative operations to be performed by each processor: One processor sends the message while other receives the message

Distributed Memory Cluster barq.niit.edu.pk (cluster head node) chenab1 chenab2 chenab3 chenab7 chenab6 chenab4 chenab5

Steps involved in executing the “Hello World!” program Let’s logon to the cluster head node Write the Hello World program Compile the program Write the machines files Start MPJ Express daemons Execute the parallel program Stop MPJ Express daemons

Step1: Logon to the head node

Step 2: Write the Hello World Program

Step 3: Compile the code

Step 4: Write the machines file

Step 5: Start MPJ Express daemons

Step 6: Execute the parallel program aamir@barq:~/projects/mpj-user> mpjrun.sh -np 6 -headnodeip 10.3.20.120 -dport 11050 HelloWorld .. Hi from process <3> of total <6> Hi from process <1> of total <6> Hi from process <2> of total <6> Hi from process <4> of total <6> Hi from process <5> of total <6> Hi from process <0> of total <6> …

Step 7: Stop the MPJ Express daemons

COMM WORLD Communicator import java.util.*; import mpi.*; .. // Initialize MPI MPI.Init(args); // start up MPI // Get total number of processes and rank size = MPI.COMM_WORLD.Size(); rank = MPI.COMM_WORLD.Rank();

What is size? Total number of processes in a communicator: import java.util.*; import mpi.*; .. // Get total number of processes size = MPI.COMM_WORLD.Size(); Total number of processes in a communicator: The size of MPI.COMM_WORLD is 6

What is rank? import java.util.*; import mpi.*; .. // Get total number of processes rank = MPI.COMM_WORLD.Rank(); The “unique” identify (id) of a process in a communicator: Each of the six processes in MPI.COMM_WORLD has a distinct rank or id

Single Program Multiple Data (SPMD) Model import java.util.*; import mpi.*; public class HelloWorld { MPI.Init(args); // start up MPI size = MPI.COMM_WORLD.Size(); rank = MPI.COMM_WORLD.Rank(); if (rank == 0) { System.out.println(“I am Process 0”); } else if (rank == 1) { System.out.println(“I am Process 1”); MPI.Finalize();

Single Program Multiple Data (SPMD) Model import java.util.*; import mpi.*; public class HelloWorld { MPI.Init(args); // start up MPI size = MPI.COMM_WORLD.Size(); rank = MPI.COMM_WORLD.Rank(); if (rank%2 == 0) { System.out.println(“I am an even process”); } else if (rank%2 == 1) { System.out.println(“I am an odd process”); MPI.Finalize();

Point to Point Communication The most fundamental facility provided by MPI Basically “exchange messages between two processes”: One process (source) sends message The other process (destination) receives message

Point to Point Communication It is possible to send message for each basic datatype: Floats (MPI.FLOAT), Integers (MPI.INT), Doubles (MPI.DOUBLE) … Java Objects (MPI.OBJECT) Each message contains a “tag”—an identifier Tag1 Tag2

Point to Point Communication Process 1 Process 2 Process 0 message Integers Process 4 Tag COMM_WORLD Process 3 Process 7 Process 6 Process 4 Process 5

Blocking Send() and Recv() Methods public void Send(Object buf, int offset, int count, Datatype datatype, int dest, int tag) throws MPIException public Status Recv(Object buf, int offset, int count, Datatype datatype, int src, int tag) throws MPIException

Blocking and Non-blocking Point-to-Point Comm There are blocking and non-blocking version of send and receive methods Blocking versions: A process calls Send() or Recv(), these methods return when the message has been physically sent or received Non-blocking versions: A process calls Isend() or Irecv(), these methods return immediately The user can check the status of message by calling Test() or Wait() Non-blocking versions provide overlapping of computation and communication: Asynchronous communication

“Blocking” “Non Blocking” Sender Receiver Send() Recv() time Isend() CPU waits “Blocking” Send() Recv() Sender Receiver time “Non Blocking” Isend() Irecv() CPU does computation Wait()

Non-blocking Point-to-Point Comm public Request Isend(Object buf, int offset, int count, Datatype datatype, int dest, int tag) throws MPIException public Request Irecv(Object buf, int offset, int count, Datatype datatype, int src, int tag) throws MPIException public Status Wait() throws MPIException public Status Test() throws MPIException

Performance Evaluation of Point to Point Communication Normally ping pong benchmarks are used to calculate: Latency: How long it takes to send N bytes from sender to receiver? Throughput: How much bandwidth is achieved? Latency is a useful measure for studying the performance of “small” messages Throughput is a useful measure for studying the performance of “large” messages

Latency on Myrinet

Throughput on Myrinet

Collective communications Provided as a convenience for application developers: Save significant development time Efficient algorithms may be used Stable (tested) Built on top of point-to-point communications These operations include: Broadcast, Barrier, Reduce, Allreduce, Alltoall, Scatter, Scan, Allscatter Versions that allows displacements between the data

Broadcast, scatter, gather, allgather, alltoall Image from MPI standard doc

Broadcast, scatter, gather, allgather, alltoall public void Bcast(Object buf, int offset, int count, Datatype type, int root) throws MPIException public void Scatter(Object sendbuf, int sendoffset, int sendcount, Datatype sendtype, Object recvbuf, int recvoffset, int recvcount, Datatype recvtype, int root) throws MPIException public void Gather(Object sendbuf, int sendoffset, int sendcount, Datatype sendtype, public void Allgather(Object sendbuf, int sendoffset int sendcount, Datatype sendtype, Object recvbuf, int recvoffset, int recvcount, Datatype recvtype) throws MPIException public void Alltoall(Object sendbuf, int sendoffset, int sendcount, Datatype sendtype, Object recvbuf, int recvoffset, int recvcount, Datatype recvtype) throws MPIException

Reduce collective operations Processes MPI.PROD MPI.SUM MPI.MIN MPI.MAX MPI.LAND MPI.BAND MPI.LOR MPI.BOR MPI.LXOR MPI.BXOR MPI.MINLOC MPI.MAXLOC

Reduce collective operations public void Reduce(Object sendbuf, int sendoffset, Object recvbuf, int recvoffset, int count, Datatype datatype, Op op, int root) throws MPIException public void Allreduce(Object sendbuf, int sendoffset, Datatype datatype, Op op)

Collective Communication Performance

Summary MPJ Express is a Java messaging system that can be used to write parallel applications: MPJ/Ibis and mpiJava are other similar software MPJ Express provides point-to-point communication methods like Send() and Recv(): Blocking and non-blocking versions Collective communications is also supported Feel free to contact me if you have any queries