Introduction to Parallel Programming (Session 2: MPI + Matlab/Octave/R)

Similar documents
Matlab MPI. Shuxia Zhang Supercomputing Institute Tel: (direct) (help)

300x Matlab. Dr. Jeremy Kepner. MIT Lincoln Laboratory. September 25, 2002 HPEC Workshop Lexington, MA

To connect to the cluster, simply use a SSH or SFTP client to connect to:

Parallel programming in Matlab environment on CRESCO cluster, interactive and batch mode

Our new HPC-Cluster An overview

Holland Computing Center Kickstart MPI Intro

Introduction to the Message Passing Interface (MPI)

To connect to the cluster, simply use a SSH or SFTP client to connect to:

L14 Supercomputing - Part 2

Message Passing Interface

Distributed Memory Programming with Message-Passing

CS4961 Parallel Programming. Lecture 16: Introduction to Message Passing 11/3/11. Administrative. Mary Hall November 3, 2011.

Practical Introduction to Message-Passing Interface (MPI)

Introduction to MPI. Ekpe Okorafor. School of Parallel Programming & Parallel Architecture for HPC ICTP October, 2014

Simple examples how to run MPI program via PBS on Taurus HPC

ACEnet for CS6702 Ross Dickson, Computational Research Consultant 29 Sep 2009

MPI 1. CSCI 4850/5850 High-Performance Computing Spring 2018

Parallel Matlab: The Next Generation

Introduction to MPI. SHARCNET MPI Lecture Series: Part I of II. Paul Preney, OCT, M.Sc., B.Ed., B.Sc.

HPC Parallel Programing Multi-node Computation with MPI - I

Tech Computer Center Documentation

mith College Computer Science CSC352 Week #7 Spring 2017 Introduction to MPI Dominique Thiébaut

Programming with MPI on GridRS. Dr. Márcio Castro e Dr. Pedro Velho

Introduction to Parallel and Distributed Systems - INZ0277Wcl 5 ECTS. Teacher: Jan Kwiatkowski, Office 201/15, D-2

Calcul intensif et Stockage de Masse. CÉCI/CISM HPC training sessions Use of Matlab on the clusters

Calcul intensif et Stockage de Masse. CÉCI/CISM HPC training sessions

Programming with MPI. Pedro Velho

Getting started with the CEES Grid

ITCS 4145/5145 Assignment 2

Practical Introduction to Message-Passing Interface (MPI)

CS 426. Building and Running a Parallel Application

High Performance Computing Course Notes Message Passing Programming I

Introduction to Parallel Programming with MPI

int sum;... sum = sum + c?

The Message Passing Interface (MPI) TMA4280 Introduction to Supercomputing

COSC 6374 Parallel Computation. Message Passing Interface (MPI ) I Introduction. Distributed memory machines

MPI: Parallel Programming for Extreme Machines. Si Hammond, High Performance Systems Group

Programming Scalable Systems with MPI. Clemens Grelck, University of Amsterdam

Part One: The Files. C MPI Slurm Tutorial - Hello World. Introduction. Hello World! hello.tar. The files, summary. Output Files, summary

CS4961 Parallel Programming. Lecture 18: Introduction to Message Passing 11/3/10. Final Project Purpose: Mary Hall November 2, 2010.

Message Passing Interface

Supercomputing in Plain English Exercise #6: MPI Point to Point

Message Passing Programming. Introduction to MPI

MPI introduction - exercises -

Outline. Communication modes MPI Message Passing Interface Standard. Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa Tp.HCM

Message-Passing Computing

Parallel Computing and the MPI environment

MPI and OpenMP (Lecture 25, cs262a) Ion Stoica, UC Berkeley November 19, 2016

ECE 574 Cluster Computing Lecture 13

MPI MESSAGE PASSING INTERFACE

Számítogépes modellezés labor (MSc)

CSE 613: Parallel Programming. Lecture 21 ( The Message Passing Interface )

Distributed Memory Parallel Programming

Distributed Memory Programming with MPI

Tutorial 2: MPI. CS486 - Principles of Distributed Computing Papageorgiou Spyros

The Message Passing Model

Parallel Programming Assignment 3 Compiling and running MPI programs

Introduction to parallel computing concepts and technics

Message Passing Interface. most of the slides taken from Hanjun Kim

MPI. (message passing, MIMD)

Computing with the Moore Cluster

Distributed Simulation in CUBINlab

PCAP Assignment I. 1. A. Why is there a large performance gap between many-core GPUs and generalpurpose multicore CPUs. Discuss in detail.

COMP/CS 605: Introduction to Parallel Computing Topic : Distributed Memory Programming: Message Passing Interface

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI

CSE. Parallel Algorithms on a cluster of PCs. Ian Bush. Daresbury Laboratory (With thanks to Lorna Smith and Mark Bull at EPCC)

The Message Passing Interface (MPI): Parallelism on Multiple (Possibly Heterogeneous) CPUs

UBDA Platform User Gudie. 16 July P a g e 1

Practical Course Scientific Computing and Visualization

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI

Outline. Communication modes MPI Message Passing Interface Standard

Parallele Numerik. Blatt 1

High performance computing. Message Passing Interface

Introduction to Parallel Programming Message Passing Interface Practical Session Part I

Computer Architecture

An Introduction to MPI

What is Hadoop? Hadoop is an ecosystem of tools for processing Big Data. Hadoop is an open source project.

Programming Scalable Systems with MPI. UvA / SURFsara High Performance Computing and Big Data. Clemens Grelck, University of Amsterdam

Debugging on Blue Waters

Introduction to MPI. Branislav Jansík

AMath 483/583 Lecture 21

The Message Passing Interface (MPI): Parallelism on Multiple (Possibly Heterogeneous) CPUs

Parallel Computing: Overview

MPI and comparison of models Lecture 23, cs262a. Ion Stoica & Ali Ghodsi UC Berkeley April 16, 2018

MPI: The Message-Passing Interface. Most of this discussion is from [1] and [2].

Parallel hardware. Distributed Memory. Parallel software. COMP528 MPI Programming, I. Flynn s taxonomy:

Introduction to the SHARCNET Environment May-25 Pre-(summer)school webinar Speaker: Alex Razoumov University of Ontario Institute of Technology

15-440: Recitation 8

MPI Message Passing Interface

Elementary Parallel Programming with Examples. Reinhold Bader (LRZ) Georg Hager (RRZE)

Lecture 14: Mixed MPI-OpenMP programming. Lecture 14: Mixed MPI-OpenMP programming p. 1

JURECA Tuning for the platform

Before We Start. Sign in hpcxx account slips Windows Users: Download PuTTY. Google PuTTY First result Save putty.exe to Desktop

MPI: Message Passing Interface An Introduction. S. Lakshmivarahan School of Computer Science

What s in this talk? Quick Introduction. Programming in Parallel

Parallel Computing with Matlab and R

MPI Tutorial. Shao-Ching Huang. High Performance Computing Group UCLA Institute for Digital Research and Education

Parallel Processing Experience on Low cost Pentium Machines

Parallel Computing Paradigms

Parallel Programming in C with MPI and OpenMP

Transcription:

Introduction to Parallel Programming (Session 2: MPI + Matlab/Octave/R) Xingfu Wu Department of Computer Science & Engineering Texas A&M University IAMCS, Feb 24, 2012

Survey n Who is mainly programming in u Matlab u Octave u R n Who has experience with parallel processing in Matlab/R? u If yes, who has used MPI + Matlab/R? u Any other parallel programming model(s) used?

Outline http://prophesy.cs.tamu.edu n Parallel Matlab/Octave u Matlab, Octave u Parallel Computing Toolbox u MatlabMPI, pmatlab n Parallel R (R, Rmpi, snow) n IAMCS Clusters: Brazos and Hurr n Try to parallelize your own code n Q&A

MATLAB http://prophesy.cs.tamu.edu n MATLAB: MATrix LABoratory, the language of technical computing developed by MathWorks ( http://www.mathworks.com/) n An interactive environment for algorithm development, data visualization, data analysis, and numerical computation n Widely used in a lot of applications in engineering, math., stat., biology, and so on.

Octave http://prophesy.cs.tamu.edu n GNU Octave is a high-level interactive language, primarily intended for numerical computations that is mostly compatible with Matlab (http:// www.gnu.org/software/octave/) n It provides a convenient command line interface for solving linear and nonlinear problems numerically n The name Octave is actually the name of one of the author's former professors

Comparison: Matlab and Octave http://prophesy.cs.tamu.edu n Free Octave available under the GNU General Public License (GNU GPL); Commercial Matlab n As free alternatives, Octave reimplements a MATLAB subset n MATLAB clone: Octave s syntax is very similar to MATLAB so that most programs are easily portable. n Octave for open source community all over the world

Differences: Matlab and Octave http://prophesy.cs.tamu.edu n Octave's parser allows some syntax that Matlab's does not, so programs written for Octave might not run in Matlab. u Octave supports the use of both single and double quotes. Matlab only supports single quotes, which means parsing errors will occur if you try to use double quotes. n See the link for detailed differences: http://en.wikibooks.org/wiki/ MATLAB_Programming/ Differences_between_Octave_and_M ATLAB

Parallel Computing Toolbox (http://www.mathworks.com) n Parallel Computing Toolbox lets you solve computationally and dataintensive problems using multicore processors, GPUs, and computer clusters. n High-level constructs parallel for-loops (parfor), special array types, and parallelized numerical algorithms let you parallelize MATLAB applications without CUDA or MPI.

parfor - Parallel for loop

Parallel Computing Toolbox n The toolbox provides twelve workers (MATLAB computational engines) to execute applications locally on a multicore desktop. n Without changing the code, you can run the same application on a computer cluster using MATLAB Distributed Computing Server (DCS). n MATLAB Distributed Computing Server : MATLAB and Simulink based applications

Parallel Computing Toolbox Source: http://www.mathworks.com/products/parallel-computing/

Limitations: Parallel Computing Toolbox n The toolbox provides only twelve workers (MATLAB computational engines) to execute applications locally n It requires MATLAB Distributed Computing Server for a computer cluster u Efficient hardware support, License n Low program portability on another cluster without MATLAB DCS n Need a general, portable parallel Matlab

MatlabMPI h"p://www.ll.mit.edu/mission/isr/matlabmpi/matlabmpi.html

What is MatlabMPI? n It is a MATLAB implementation of the MPI standards that allows any MATLAB program to exploit multiple processors. n It implements, the basic MPI functions that are the core of the MPI point-topoint communications with extensions to other MPI functions using pure M-file implementation. n It runs anywhere MATLAB/Octave runs. n Principal developer: Dr. Kepner (MIT Lincoln Laboratory)

General Requirements n As MatlabMPI uses Matlab file I/O for communication, a common file system must be visible to every machine/ processor. n On shared memory platforms: single MATLAB license is enough since any user is allowed to launch many MATLAB sessions. n On distributed memory platforms: one MATLAB license per machine / node.

Basic Concepts of MatlabMPI http://prophesy.cs.tamu.edu n MatlabMPI Core Lite requires eight capabilities and additional convenience functions n MatlabMPI implements the fundamental communication operations in MPI using MATLAB s file I/O functions n Any message passing can be implemented using file I/O provided by Matlab via load and save functions

Basic Concepts of MatlabMPI n Messages: MATLAB variables transferred from one processor to another n Synchronous transfer: a function call does not return until the message is sent or received

MPI: Message Passing Interface The minimal set of MPI routines MPI_Init Initializes MPI. MPI_Finalize Terminates MPI. MPI_Comm_size Determines the number of processes. MPI_Comm_rank Determines the label of calling process. MPI_Send MPI_Recv Sends a message. Receives a message. mpirun: launches MPI processes on multiple processors

MatlabMPI Functionality http://prophesy.cs.tamu.edu n Core Lite requires eight capabilities u MPI_Init: initializes MPI at beginning of program u MPI_Finalize: finalizes MPI at end of program u MPI_Comm_size: returns the number of processors u MPI_Comm_rank: returns the id of each processor u MPI_Send: sends Matlab variable(s) to another processor u MPI_Recv: receives Matlab variable(s) from another processor u MPI_Run: launches multiple copies of a Matlab script on multiple processors u MatMPI_Delete_all: cleans up all files after a run

MatlabMPI Functionality n Additional convenience functions u MPI_Abort: kills all jobs u MPI_Bcast: broadcasts a message u MPI_Probe: returns a list of all incoming messages u MPI_cc: passes program through Matlab compiler u MatMPI_Save_messages: toggles deletion of messages u MatMPI_Comm_settings: user can set MatlabMPI internals

MPI: Point-to-Point Communication Mechanism Network

MatlabMPI: Point-to-Point Communication Mechanism Source: Dr. Kepner s talks: Parallel Matlab: the Next GeneraBon

Example: MPI + C (Hello World) #include <stdio.h> #include "mpi.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 from process %d of %d\n", rank, size ); MPI_Finalize(); return 0; Output: Hello world from process 0 of 2 Hello world from process 1 of 2

How to Write a MatlabMPI Code 1. Initialize MPI MPI_Init; 2. Create MPI communicator comm= MPI_COMM_WORLD; 3. Get size and rank size = MPI_Comm_size(comm); rank= MPI_Comm_rank(comm); 4. Some computation for each processor using Matlab disp(['hello world from process : ',num2str(rank), of, num2str(size)]); 5. Communication using MPI for data exchange if needed MPI_Send, MPI_Recv 6. Some computation for each processor using Matlab 7.Finalize MPI MPI_Finalize;

Example: MatlabMPI (Hello World) % Initialize MPI MPI_Init; % Create the MPI communicator comm= MPI_COMM_WORLD; % Get size and rank size = MPI_Comm_size(comm); rank= MPI_Comm_rank(comm); disp(['hello world from process : ',num2str(rank), of, num2str(size)]); % Finalize MatlabMPI MPI_Finalize; Output: Hello world from process 0 of 2 Hello world from process 1 of 2

Example: MatlabMPI (Basic) % Initialize MPI. MPI_Init; % Create communicator. comm = MPI_COMM_WORLD; % Get size and rank. comm_size = MPI_Comm_size(comm); my_rank = MPI_Comm_rank(comm); % Print rank. disp(['my_rank: ',num2str(my_rank)]); % Set who is source and who is destination. source = 1; dest = 0; % Create a unique tag id for this message (very important in Matlab MPI!). tag = 1;

Example: MatlabMPI (Basic) % Check to make sure that we have exactly two processors. if(comm_size == 2) % Source. if (my_rank == source) % Create data. data = 1:10; % Send it. MPI_Send( dest, tag, comm, data, data ); end % Destination. if (my_rank == dest) % Receive data. [data data1] = MPI_Recv( source, tag, comm ); % Check data. if(any((data - (1:10)) ~= 0)) disp('error: incorrect data sent.'); exit; end end end % Finalize Matlab MPI. disp('success'); MPI_Finalize;

A Simple Matlab Code: Summation % sequential summation using Matlab/Octave n = 100000000; s = 0; % a large loop for i=1:n s = s+i; end % print the total summation disp(['total summation: ', num2str(s)]);

How to Parallelize a Matlab Code 1. Initialize MPI MPI_Init; 2. Create MPI communicator comm= MPI_COMM_WORLD; 3. Get size and rank size = MPI_Comm_size(comm); rank= MPI_Comm_rank(comm); 4. Parallelize some computation using Matlab 5. Communication using MPI for data exchange if needed MPI_Send, MPI_Recv 6. Some computation for each processor using Matlab 7.Finalize MPI MPI_Finalize;

Parallelize the Simple Code n = 100000000; s = 0; % Initialize MPI MPI_Init; % Create MPI communicator comm= MPI_COMM_WORLD; % Get size and rank size = MPI_Comm_size(comm); rank= MPI_Comm_rank(comm); master = 0; rank=0 rank=1 % Split the for loop into size partitions m = n / size; r = mod(n, m); if ( rank == size-1 ) se = (rank + 1)*m + r; else (rank*m)+1 se = (rank + 1)*m; end % Each process works on a partition of the loop independently s1 = s; for i=(rank * m)+1:se s1 = s1 + i; end % print the partial summation on each process disp(['partial summation: ', num2str(s1), ' on process ', num2str(rank)]); rank=size-1 se

Parallelize the Simple Code % Create a unique tag id for this message (very important in Matlab MPI!). tag = 1000 + rank; % Send the partial summation from each process to the master (rank=0) if ( rank > 0 ) MPI_Send( master, tag, comm, s1 ); else % Receive the partial summation from each process (rank > 0) and add them together s = s1; for j=1:size-1 tag1 = 1000 + j; s1 = MPI_Recv( j, tag1, comm ); s = s + s1; end end % print the total summation on the master (rank = 0) if (rank == 0) disp(['total summation : ',num2str(s)]); end % Finalize MatlabMPI MPI_Finalize;

pmatlab http://prophesy.cs.tamu.edu n Allow a Matlab user to write parallel programs with the least possible modification to existing matlab codes n New parallel concepts should be intuitive to matlab users u parallel matrices and functions instead of message passing n Support the types of parallelism we see in our applications u data parallelism, task parallelism, pipeline parallelism

pmatlab: Parallel Matlab Toolbox Source: Dr. Kepner s talks: Parallel Matlab: the Next GeneraBon

Outline http://prophesy.cs.tamu.edu n Parallel Matlab/Octave u Matlab, Octave u Parallel Computing Toolbox u MatlabMPI, pmatlab n Parallel R (R, Rmpi, snow) n IAMCS Clusters: Brazos and Hurr n Try to parallelize your own code n Q&A

R Language n R project (http://www.r-project.org/) n R is a free language and environment for statistical computing and graphics. n R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering,...) and graphical techniques, and is highly extensible.

Parallel Computing in R http://prophesy.cs.tamu.edu n Threaded R with OpenMP u Romp (http://code.google.com/p/ romp/wiki/ropenmp) n Parallel R using MPI u Rmpi (http://www.stats.uwo.ca/faculty/ yu/rmpi/) u Rpvm n Parallel R using packages (http://cran.rproject.org/)

Romp (R + OpenMP)

Rmpi, Rpvm

Outline http://prophesy.cs.tamu.edu n Parallel Matlab/Octave u Matlab, Octave u Parallel Computing Toolbox u MatlabMPI, pmatlab n Parallel R (R, Rmpi, snow) n IAMCS Clusters: Brazos and Hurr n Try to parallelize your own code n Q&A

IAMCS Clusters: Brazos/Hurr n Total of 300 nodes, 2400 cores n Brazos: u 172 nodes, each with two quad-core Intel Xeon (Harpertown) processors with 2.5GHz and 16GB per node n Hurr u 128 nodes, each with two quad core AMD Opteron (Shanghai) processors with 2.5GHz and 32GB per node

Remote Login Brazos n ssh username@brazos.tamu.edu n See brazos.tamu.edu for the details n Setup Environments (.bashrc) u Matlab/Octave, R u MatlabMPI u Brazos: only two Matlab licenses n Examples: cp r /data/wuxf/examples/matlabmpi.

List in MatlabMPI http://prophesy.cs.tamu.edu n doc/ n examples/ original MatlabMPI document original MatlabMPI examples n matlab/ n.octaverc n README n readme.brazos n README.pc directory for MatlabMPI configuration to support Matlab MatlabMPI configuration file to support Octave original MatlabMPI readme readme for Brazos/Hurr original file n src/ n tests/ original MatlabMPI source files test examples and pbs scripts to run the codes on Brazos/Hurr

Configure MatlabMPI to support MPI + Matlab codes http://prophesy.cs.tamu.edu n To add the path of MatlabMPI to Matlab, copy the directory matlab to your home directory as follows: cp -r matlab ~ n Then, edit matlab/startup.m to change "/data/ wuxf/examples/matlabmpi/src" to "yourdirectory/matlabmpi/src", and "/home/ wuxf/matlab" to "yourhomedirectory/matlab". n Test your MatlabMPI codes in Matlab environment

Configure MatlabMPI to support MPI + Octave codes http://prophesy.cs.tamu.edu n To add the path of MatlabMPI to Octave, copy the file.octaverc to your home directory as follows: cp.octaverc ~ n Then, edit the file.octaverc to change "/data/ wuxf/examples/matlabmpi/src" to "yourdirectory/matlabmpi/src", and "/home/ wuxf/matlab" to "yourhomedirectory/matlab". n Test your MatlabMPI codes in Octave environment

List of files in Directory tests n run.pbs: the pbs script for running MPI + Matlab codes Please edit the file run.pbs to change "/data/wuxf/examples/ MatlabMPI/tests" to "yourdirectory/matlabmpi/tests". n run-hello.m: run.pbs uses the m file to get a list of processors n orun.pbs: the pbs script for running MPI + Octave codes Please edit the file orun.pbs to change "/data/wuxf/examples/ MatlabMPI/tests" to "yourdirectory/matlabmpi/tests". n n ohello.m: orun.pbs uses the m file to get a list of processors hello.m: a MatlabMPI example for "Hello World n n n basic.m: is from the MatlabMPI examples Sum/sum.m: a sequential summation code Sum/psum.m: a MatlabMPI code

Execution Models for Running Multiple Processes n SPMD: Single Program Multiple Data u There is only one program u Each process uses the same exacutable working on different sets of data n MPMD: Multiple Programs Multiple Data u Different programs for different processes u The processes collaborate to solve the same problem

Examples: SPMD, MPMD 1. SPMD 2. MPMD: 3. MPMD: Master/Worker Coupled Analysis

Running the Code n Interactive Mode u What most of us are used to u Like we are "interacting" with the computer u Use command line to run the program immediately n Batch Mode u The programs (jobs) are not performed immediately, but instead, put onto a queue to execute later u Use a PBS scheduler to schedule a job to run

Running a Code (interactive) n In Matlab environment [wuxf@brazos:/data/wuxf/examples/matlabmpi/tests]$ matlab >> eval( MPI_Run('hello',8,{}) ); Launching MPI rank: 7 on: brazos.tamu.edu Launching MPI rank: 6 on: brazos.tamu.edu Launching MPI rank: 5 on: brazos.tamu.edu Launching MPI rank: 4 on: brazos.tamu.edu Launching MPI rank: 3 on: brazos.tamu.edu Launching MPI rank: 2 on: brazos.tamu.edu Launching MPI rank: 1 on: brazos.tamu.edu Launching MPI rank: 0 on: brazos.tamu.edu unix_launch = /bin/sh./matmpi/unix_commands.brazos.tamu.edu.0.sh & Hello world from process : 0 of 8 >>

MPI_Run: Run MatlabMPI m_file n Launches a Matlab script (m_file) on multiple processors MPI_Run( m_file, n, machines ) n Runs n copies of m_file on machines, where u machines = {} means to run on n local / reserved processors u machines = {'machine1' 'machine2 machinen } means to run on n processors machine1,, and machinen.

Running a Code (interactive) n In Matlab environment Note: Before running another program basic.m, execute MatMPI_Delete_all. >> MatMPI_Delete_all; >> eval( MPI_Run('basic',2,{}) ); Launching MPI rank: 1 on: brazos.tamu.edu Launching MPI rank: 0 on: brazos.tamu.edu unix_launch = /bin/sh./matmpi/unix_commands.brazos.tamu.edu.0.sh & my_rank: 0 SUCCESS >>

Running a Code (interactive) n In Octave environment [wuxf@brazos:/data/wuxf/examples/matlabmpi/tests]$ octave octave:1> eval(mpi_run('hello, 8, {})); Launching MPI rank: 7 on: brazos.tamu.edu Launching MPI rank: 6 on: brazos.tamu.edu Launching MPI rank: 5 on: brazos.tamu.edu Launching MPI rank: 4 on: brazos.tamu.edu Launching MPI rank: 3 on: brazos.tamu.edu Launching MPI rank: 2 on: brazos.tamu.edu Launching MPI rank: 1 on: brazos.tamu.edu Launching MPI rank: 0 on: brazos.tamu.edu unix_launch = /bin/sh./matmpi/unix_commands.brazos.tamu.edu. 0.sh & Hello world from process : 0 of 8 octave:2>

Running a Code (interactive) n In Octave environment Note: Before running another program basic.m, execute MatMPI_Delete_all. octave:2> MatMPI_Delete_all remove entire contents of./matmpi? (yes or no) yes octave:3> eval(mpi_run('basic',2, {})); Launching MPI rank: 1 on: brazos.tamu.edu Launching MPI rank: 0 on: brazos.tamu.edu unix_launch = /bin/sh./matmpi/ Unix_Commands.brazos.tamu.edu.0.sh & my_rank: 0 SUCCESS octave:4>

Running a Code (batch) n In Matlab environment (run.pbs) #!/bin/sh #PBS -l walltime=00:10:00 #PBS -q iamcs #PBS -l nodes=2:ppn=8 #PBS -j oe #PBS -N matlabmpi-hello Nprocs=16 source ~/.bashrc ### go to your working directory cd /data/wuxf/examples/matlabmpi/tests ### copy the node list file to your working directory cp $PBS_NODEFILE./machines.m ### run the program /apps/matlab/r2010b/bin/matlab -nojvm -nosplash -display null < run-hello.m

machines.m n reserved machine list file c0533b c0533b c0533b c0533b c0533b c0533b c0533b c0533b c0615a c0615a c0615a c0615a c0615a c0615a c0615a c0615a

Running a Code (batch) http://prophesy.cs.tamu.edu n In Matlab environment (run-hello.m) % Read the node list file into a array machines = textread('machines.m','%s','delimiter','\n','whitespace',''); % Re-arrange the dimension of the nodes to 1xn machines2 = reshape(machines,1,[]); % Get the length of node list node_num = size(machines); % Clean up matlabmpi MatMPI_Delete_all % Run your porgram eval(mpi_run('hello',node_num(1), machines2)); n Submit a MatlabMPI job u qsub run.pbs

Running a Code (batch) http://prophesy.cs.tamu.edu n In Octave environment (orun.pbs) #!/bin/sh #PBS -l walltime=00:10:00 #PBS -q iamcs #PBS -l nodes=4:ppn=8 #PBS -j oe #PBS -N octavempi-hello Nprocs=32 source ~/.bashrc ### go to your working directory cd /data/wuxf/examples/matlabmpi/tests ### copy the node list file to your working directory cp $PBS_NODEFILE./machines.m ### run the program /apps/octave-3.2.4/bin/octave < ohello.m

Running a Code (batch) http://prophesy.cs.tamu.edu n In Octave environment (ohello.m) % Read the node list file into a array %machines = textread('machines.m','%s','delimiter','\n','whitespace',''); % Re-arrange the dimension of the nodes to 1xn %machines2 = reshape(machines,1,[]); % Get the length of node list %node_num = size(machines); % Clean up matlabmpi MatMPI_Delete_all % Run your porgram eval(mpi_run('hello',32, {})); n Submit a MatlabMPI job u qsub orun.pbs

Submit a batch job n TORQUE Resource Manager provides control over batch jobs and distributed computing resources. n It is an advanced open-source product based on the OpenPBS. n Submit a batch job u qsub file.pbs n Look at the job status u qstat u username u qdel jobid (delete the job with jobid)

Outline http://prophesy.cs.tamu.edu n Parallel Matlab/Octave u Matlab, Octave u Parallel Computing Toolbox u MatlabMPI, pmatlab n Parallel R (R, Rmpi, snow) n IAMCS Clusters: Brazos and Hurr n Try to parallelize your own code n Q&A

Download the Tutorial Slides n http://iamcs.tamu.edu/flyer/iamcs- ParallelProgramming.pdf Or http://faculty.cs.tamu.edu/wuxf/ talks/iamcs-parallelprogramming.pdf n http://iamcs.tamu.edu/flyer/iamcs- ParallelProgramming2.pdf Or http://faculty.cs.tamu.edu/wuxf/ talks/iamcs-parallelprogramming2.pdf

Parallel Performance Evaluation and Optimization Methodology and Techniques Xingfu Wu Department of Computer Science & Engineering Texas A&M University IAMCS, Feb 2012 (Next Time)