Size: px
Start display at page:

Download ""

Transcription

1 1

2 2

3 ##: ********** ## ********** guillimin.hpc.mcgill.ca class## ********** qsub interactive.pbs 3

4 cp -a /software/workshop/cq-formation-advanced-python ~/ cd cq-formation-advanced-python module add git # If on Guillimin git clone -b mcgill \ cd cq-formation-advanced-python 4

5 multiprocessing mpi4py 5

6 6

7 7

8 8

9 // approx_pi.c double approx_pi(int intervals) { double pi = 0.0; # approx_pi.py def approx_pi(intervals): pi = 0.0 int i; for (i = 0; i < intervals; i++) { pi += (4 - ((i % 2) * 8)) / (double)(2 * i + 1); } for i in range(intervals): pi += (4-8 * (i % 2)) / (float)(2 * i + 1) return pi return pi; } 9

10 $ gcc -O2 pi_collect.c approx_pi.c -o pi_collect $./pi_collect $ module add python/3.3.2 $ python3 pi_collect.py approx_pi

11 11

12 $ module add pypy/ $ pypy3 pi_collect.py approx_pi

13 from future import division # only needed for Python 2.x def approx_pi(intervals): pi1 = 4/numpy.arange(1, intervals*2, 4) pi2 = -4/numpy.arange(3, intervals*2, 4) return numpy.sum(pi1) + numpy.sum(pi2) $ python3 pi_collect.py approx_pi_numpy

14 14

15 15

16 /* Example of wrapping approx_pi() with the Python-C-API. */ #include <Python.h> #include "approx_pi.h" static PyObject* approx_pi_func(pyobject* self, PyObject* args) // wrapped approx_pi() { int value; double answer; if (!PyArg_ParseTuple(args, "i", &value)) // parse input, python float to c double return NULL; /* if the above function returns -1, an appropriate Python exception will * have been set, and the function simply returns NULL */ answer =approx_pi(value); /* construct the output from approx_pi, from c double to python float */ return Py_BuildValue("f", answer); } 16

17 /* define functions in module */ static PyMethodDef PiMethods[] = { {"approx_pi", approx_pi_func, METH_VARARGS, "approximate Pi"}, {NULL, NULL, 0, NULL} }; static struct PyModuleDef PiModule = { PyModuleDef_HEAD_INIT, "approx_pi_pyapi", NULL, -1, PiMethods, NULL, NULL, NULL, NULL }; /* module initialization */ PyMODINIT_FUNC PyInit_approx_pi_pyapi(void) { (void) PyModule_Create(&PiModule);} $ python3 setup_approx_pi_pyapi.py build_ext -inplace from distutils.core import setup, Extension # define the extension module module = Extension('approx_pi_pyapi', sources=['approx_pi_pyapi.c', 'approx_pi.c']) setup(ext_modules=[module]) # run the setup 17

18 $ gcc -fpic -shared -O2 approx_pi.c -o approx_pi_ctypes.so # approx_pi_ctypes.py """ Example of wrapping approx_pi using ctypes. """ import ctypes approx_pi_dll = ctypes.cdll.loadlibrary('./approx_pi_ctypes.so') # find and load the library approx_pi_dll.approx_pi.argtypes = [ctypes.c_int] # set the argument type approx_pi_dll.approx_pi.restype = ctypes.c_double # set the return type def approx_pi(arg): ''' Wrapper for approx_pi ''' return approx_pi_dll.approx_pi(arg) 18

19 /* approx_pi_swig.i */ /* Example of wrapping approx_pi using SWIG. */ %module approx_pi_swig %{ /* the resulting C file should be built as a python extension */ #define SWIG_FILE_WITH_INIT /* Includes the header in the wrapper code */ #include "approx_pi.h" %} /* Parse the header file to generate wrappers */ %include "approx_pi.h" 19

20 python3 setup_approx_pi_swig.py build_ext --inplace from distutils.core import setup, Extension approx_pi_module = Extension("_approx_pi", sources= ["approx_pi.c", "approx_pi.i"]) setup(ext_modules=[approx_pi_module]]) approx_pi_swig.py approx_pi_swig_wrap.c _approx_pi_swig*.so 20

21 subroutine approx_pi(intervals, pi) integer, intent(in) :: intervals double precision, intent(out) :: pi integer i pi = 0 do i = 0, intervals - 1 pi = pi + (4 - (mod(i,2) * 8)) / dble(2 * i + 1) enddo end subroutine approx_pi f2py3 -c -m approx_pi_f2py approx_pi.f90 python3 pi_collect.py approx_pi_f2py

22 22

23 .pyx 23

24 approx_pi_cython1.pyx approx_pi.py def approx_pi(intervals): pi = 0.0 for i in range(intervals): pi += (4-8 * (i % 2)) / (float)(2 * i + 1) return pi python3 setup_cython.py build_ext --inplace from distutils.core import setup from Cython.Build import cythonize setup(ext_modules = cythonize("*.pyx")) python3 pi_collect.py approx_pi_cython

25 cdef approx_pi_cython2.pyx def approx_pi(int intervals): cdef double pi cdef int i pi = 0.0 for i in range(intervals): pi += (4-8 * (i % 2)) / (float)(2 * i + 1) return pi python3 setup_cython.py build_ext --inplace python3 pi_collect.py approx_pi_cython

26 approx_pi_cython2.c Pyx_mod_long( pyx_v_i, 2) pyx_v_i % 2. This is because in C, -1% 10=-1 but in Python, -1%10=9. #cython:cdivision=true python3 setup_cython.py build_ext --inplace python3 pi_collect.py approx_pi_cython %load_ext cythonmagic %%cython 26

27 # approx_pi_cython4.pyx cdef extern from "approx_pi.h": double c_approx_pi "approx_pi" (int intervals) # C name: approx_pi, Cython name: c_approx_pi def approx_pi(int intervals): return c_approx_pi(intervals) setup_cython4.py from distutils.core import setup, Extension from Cython.Distutils import build_ext setup(cmdclass={'build_ext': build_ext}, ext_modules=[extension("approx_pi_cython4", sources=["approx_pi_cython4.pyx", "approx_pi.c"])]) python3 setup_cython4.py build_ext --inplace python3 pi_collect.py approx_pi_cython

28 28

29 29

30 30

31 31

32 32

33 multiprocessing 33

34 multiprocessing threading multiprocessing 34

35 from multiprocessing import Pool Pool def prod(values): return values[0] * values[1] if name == ' main ': N = 12 values = [(i + 1, N - i) for i in range(0, N)] print(values) workers = Pool(processes=4) results = workers.map(prod, values) print(results) 35

36 python script.py 36

37 from multiprocessing import Pool import time def prod(values): time.sleep(1) return values[0] * values[1] map_async() if name == ' main ': N = 12 values = [(i + 1, N - i) AsyncResult for i in range(0, N)] print(values) workers = Pool(processes=4) results = workers.map_async(prod, values) print('waiting...') print(results.get(timeout=10)) 37

38 def printres(results): print(results) if name == ' main ': N = 12 values = [(i + 1, N - i) for i in range(0, N)] print(values) workers = Pool(processes=4) results = workers.map_async(prod, values, callback=printres) print('waiting...') workers.close() workers.join() 38

39 Pool([processes[,...]]) processes None processes=multiprocessing.cpu_count() map(func, iterable[,...]) map_async(func, iterable[,...]) AsyncResult close() join() close() 39

40 AsyncResult get([timeout]) wait([timeout]) ready() successful() 40

41 baby-genomic.py edproxy() editdistance() time -p python baby-genomic.py 41

42 Process Process Process(target=fct, args=(arg1,arg2)).start() Pipe Queue Lock 42

43 43

44 44

45 $ ipcluster start -n 4 Pool.map() Engines appear to have started successfully $ bg $ ipython from IPython.parallel import Client client = Client() client.ids [0, 1, 2, 3] def fct(): $ fg return 'hello' client[:].apply_sync(fct) ['hello', 'hello', 'hello', 'hello'] 45

46 python sleep kill ipcluster 46

47 ipython profile create --parallel --profile=name ~/.ipython/profile_name/ipcontroller_config.py c.hubfactory.ip = '*' local01./config_ipcluster.sh local01 47

48 localengines.pbs qsub qsub -N local01 localengines.pbs qstat -u $USER tail -f local01.log Engines appear to have started successfully 48

49 $ ipython --profile=local01 from IPython.parallel import Client client = Client() client.ids with client[:].sync_imports(): import socket %px print(socket.gethostname()) [stdout:0] sw-2r**-n** [stdout:1] sw-2r**-n** [stdout:2] sw-2r**-n** [stdout:3] sw-2r**-n** 49

50 ~/.ipython/profile_name/ipcluster_config.py c.ipclusterengines.engine_launcher_class = 'MPIEngineSetLauncher' mpi01 MPI./config_ipcluster.sh mpi01 MPI 50

51 mpiengines.pbs python openmpi qsub -N mpi01 mpiengines.pbs qstat -u $USER tail -f mpi01.log Engines appear to have started successfully 51

52 $ ipython --profile=mpi01 from IPython.parallel import Client client = Client() with client[:].sync_imports(): import socket, time %px print(socket.gethostname()) def fct(x): time.sleep(1) return x*x client[:].map_sync(fct, range(8)) [0, 1, 4, 9, 16, 25, 36, 49] 52

53 $ cd examples/ $ cat ipclusterex4.py $ ipython --profile=mpi01 from ipclusterex4 import parafct parafct() importing time on engine(s) [0, 1, 4, 9, 16, 25, 36, 49] 53

54 baby-genomic.py ipclustergenomic.py ipclustergenomic.py $ ipython --profile=mpi01 from ipclustergenomic import main main() 54

55 55

56 dest = 1; tag = 54321; MPI_Send( &matrix, count, MPI_INT, dest, tag, MPI_COMM_WORLD ) MPI.COMM_WORLD.Send(matrix, dest=1, tag=54321) 56

57 from mpi4py import MPI Then often use comm = MPI.COMM_WORLD Two variations for most functions: a. all lowercase, e.g. comm.recv() works on general Python objects, using pickle (can be slow) received object (value) returned: matrix = comm.recv(source=0, tag=mpi.any_tag) b. capitalized, e.g. comm.recv() works fast on numpy arrays & other buffers received object given as parameter: comm.recv(matrix, source=0, tag=mpi.any_tag) Specify [matrix, MPI.INT], or [data, count, MPI.INT] if autodetection fails. 57

58 from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.get_rank() size = comm.get_size() print( "%3d/%-3d :-D\n"%rank, size ) mpiexec -n 4 python smiley.py > smiley.out qsub smiley.pbs 58

59 smiley.py smileys.py smileys.py :- :-) :-D :-P smiley.pbs smileys.pbs 59

60 dot_product.py comm.scatter(sendbuf, recvbuf, root=...) comm.reduce comm.reduce comm.gather 60

61 61

62 62

Advanced and Parallel Python

Advanced and Parallel Python Advanced and Parallel Python December 1st, 2016 http://tinyurl.com/cq-advanced-python-20161201 By: Bart Oldeman and Pier-Luc St-Onge 1 Financial Partners 2 Setup for the workshop 1. Get a user ID and password

More information

C - extensions. only a small part of application benefits from compiled code

C - extensions. only a small part of application benefits from compiled code C - EXTENSIONS C - extensions Some times there are time critical parts of code which would benefit from compiled language 90/10 rule: 90 % of time is spent in 10 % of code only a small part of application

More information

Practical Introduction to Message-Passing Interface (MPI)

Practical Introduction to Message-Passing Interface (MPI) 1 Practical Introduction to Message-Passing Interface (MPI) October 1st, 2015 By: Pier-Luc St-Onge Partners and Sponsors 2 Setup for the workshop 1. Get a user ID and password paper (provided in class):

More information

Session 12: Introduction to MPI (4PY) October 9 th 2018, Alexander Peyser (Lena Oden)

Session 12: Introduction to MPI (4PY) October 9 th 2018, Alexander Peyser (Lena Oden) Session 12: Introduction to MPI (4PY) October 9 th 2018, Alexander Peyser (Lena Oden) Overview Introduction Basic concepts mpirun Hello world Wrapping numpy arrays Common Pitfalls Introduction MPI: de

More information

Session 12: Introduction to MPI (4PY) October 10 th 2017, Lena Oden

Session 12: Introduction to MPI (4PY) October 10 th 2017, Lena Oden Session 12: Introduction to MPI (4PY) October 10 th 2017, Lena Oden Overview Introduction Basic concepts mpirun Hello world Wrapping numpy arrays Common Pittfals Introduction MPI de facto standard for

More information

Extensions in C and Fortran

Extensions in C and Fortran Extensions in C and Fortran Why? C and Fortran are compiled languages Source code is translated to machine instructons by the compiler before you run. Ex: gfortran -o mycode mycode.f90 gcc -o mycode mycode.c

More information

PYTHON IS SLOW. Make it faster with C. Ben Shaw

PYTHON IS SLOW. Make it faster with C. Ben Shaw PYTHON IS SLOW Make it faster with C Ben Shaw It s OK that Python isn t fast, you can write your slow functions in C! Everyone TABLE OF CONTENTS C Module vs C Types TABLE OF CONTENTS C Module vs C Types

More information

Diffusion processes in complex networks

Diffusion processes in complex networks Diffusion processes in complex networks Digression - parallel computing in Python Janusz Szwabiński Outlook: Multiprocessing Parallel computing in IPython MPI for Python Cython and OpenMP Python and OpenCL

More information

Python Optimization and Integration

Python Optimization and Integration [Software Development] Python Optimization and Integration Davide Balzarotti Eurecom Sophia Antipolis, France 1 When Python is not Enough Python is great for rapid application development Many famous examples...

More information

multiprocessing and mpi4py

multiprocessing and mpi4py multiprocessing and mpi4py 02-03 May 2012 ARPA PIEMONTE m.cestari@cineca.it Bibliography multiprocessing http://docs.python.org/library/multiprocessing.html http://www.doughellmann.com/pymotw/multiprocessi

More information

Interfacing With Other Programming Languages Using Cython

Interfacing With Other Programming Languages Using Cython Lab 19 Interfacing With Other Programming Languages Using Cython Lab Objective: Learn to interface with object files using Cython. This lab should be worked through on a machine that has already been configured

More information

Introduction to Python for Scientific Computing

Introduction to Python for Scientific Computing 1 Introduction to Python for Scientific Computing http://tinyurl.com/cq-intro-python-20151022 By: Bart Oldeman, Calcul Québec McGill HPC Bart.Oldeman@calculquebec.ca, Bart.Oldeman@mcgill.ca Partners and

More information

Message Passing Interface

Message Passing Interface MPSoC Architectures MPI Alberto Bosio, Associate Professor UM Microelectronic Departement bosio@lirmm.fr Message Passing Interface API for distributed-memory programming parallel code that runs across

More information

Cython. April 2008 Brian Blais

Cython. April 2008 Brian Blais Cython O p t i m i z a t i o n i n P y t h o n April 2008 Brian Blais Rule #1 of Optimization Premature optimization is the root of all evil - Donald Knuth What is Cython/Pyrex? Python to C/Python-API

More information

Robot Vision Systems Lecture 8: Python wrappers in OpenCV

Robot Vision Systems Lecture 8: Python wrappers in OpenCV Robot Vision Systems Lecture 8: Python wrappers in OpenCV Michael Felsberg michael.felsberg@liu.se Why Python Wrappers Assume a small library based on OpenCV Python interface for Testing Distribution Prototyping

More information

MPI: the Message Passing Interface

MPI: the Message Passing Interface 15 Parallel Programming with MPI Lab Objective: In the world of parallel computing, MPI is the most widespread and standardized message passing library. As such, it is used in the majority of parallel

More information

Python, C, C++, and Fortran Relationship Status: It s Not That Complicated. Philip Semanchuk

Python, C, C++, and Fortran Relationship Status: It s Not That Complicated. Philip Semanchuk Python, C, C++, and Fortran Relationship Status: It s Not That Complicated Philip Semanchuk (philip@pyspoken.com) This presentation is part of a talk I gave at PyData Carolinas 2016. This presentation

More information

Cython: Stop writing native Python extensions in C

Cython: Stop writing native Python extensions in C Python extensions March 29, 2016 cython.org programming language similar to Python static typing from C/C++ compiler from Cython language to C/C++ to Python extension module or to standalone apps* feels

More information

Speeding up Python. Antonio Gómez-Iglesias April 17th, 2015

Speeding up Python. Antonio Gómez-Iglesias April 17th, 2015 Speeding up Python Antonio Gómez-Iglesias agomez@tacc.utexas.edu April 17th, 2015 Why Python is nice, easy, development is fast However, Python is slow The bottlenecks can be rewritten: SWIG Boost.Python

More information

Mixed language programming

Mixed language programming Mixed language programming Simon Funke 1,2 Ola Skavhaug 3 Joakim Sundnes 1,2 Hans Petter Langtangen 1,2 Center for Biomedical Computing, Simula Research Laboratory 1 Dept. of Informatics, University of

More information

Introduction to the Message Passing Interface (MPI)

Introduction to the Message Passing Interface (MPI) Introduction to the Message Passing Interface (MPI) CPS343 Parallel and High Performance Computing Spring 2018 CPS343 (Parallel and HPC) Introduction to the Message Passing Interface (MPI) Spring 2018

More information

Practical Introduction to Message-Passing Interface (MPI)

Practical Introduction to Message-Passing Interface (MPI) 1 Outline of the workshop 2 Practical Introduction to Message-Passing Interface (MPI) Bart Oldeman, Calcul Québec McGill HPC Bart.Oldeman@mcgill.ca Theoretical / practical introduction Parallelizing your

More information

Running Cython. overview hello world with Cython. experimental setup adding type declarations cdef functions & calling external functions

Running Cython. overview hello world with Cython. experimental setup adding type declarations cdef functions & calling external functions Running Cython 1 Getting Started with Cython overview hello world with Cython 2 Numerical Integration experimental setup adding type declarations cdef functions & calling external functions 3 Using Cython

More information

High Performance Computing with Python

High Performance Computing with Python High Performance Computing with Python Pawel Pomorski SHARCNET University of Waterloo ppomorsk@sharcnet.ca April 29,2015 Outline Speeding up Python code with NumPy Speeding up Python code with Cython Using

More information

CS/Math 471: Intro. to Scientific Computing

CS/Math 471: Intro. to Scientific Computing CS/Math 471: Intro. to Scientific Computing Getting Started with High Performance Computing Matthew Fricke, PhD Center for Advanced Research Computing Table of contents 1. The Center for Advanced Research

More information

Mixed language programming with NumPy arrays

Mixed language programming with NumPy arrays Mixed language programming with NumPy arrays Simon Funke 1,2 Ola Skavhaug 3 Joakim Sundnes 1,2 Hans Petter Langtangen 1,2 Center for Biomedical Computing, Simula Research Laboratory 1 Dept. of Informatics,

More information

Parallel Programming Basic MPI. Timothy H. Kaiser, Ph.D.

Parallel Programming Basic MPI. Timothy H. Kaiser, Ph.D. Parallel Programming Basic MPI Timothy H. Kaiser, Ph.D. tkaiser@mines.edu 1 Talk Overview Background on MPI Documentation Hello world in MPI Some differences between mpi4py and normal MPI Basic communications

More information

mpi4py HPC Python R. Todd Evans January 23, 2015

mpi4py HPC Python R. Todd Evans January 23, 2015 mpi4py HPC Python R. Todd Evans rtevans@tacc.utexas.edu January 23, 2015 What is MPI Message Passing Interface Most useful on distributed memory machines Many implementations, interfaces in C/C++/Fortran

More information

PyConZA High Performance Computing with Python. Kevin Colville Python on large clusters with MPI

PyConZA High Performance Computing with Python. Kevin Colville Python on large clusters with MPI PyConZA 2012 High Performance Computing with Python Kevin Colville Python on large clusters with MPI Andy Rabagliati Python to read and store data on CHPC Petabyte data store www.chpc.ac.za High Performance

More information

Exceptions in Python. AMath 483/583 Lecture 27 May 27, Exceptions in Python. Exceptions in Python

Exceptions in Python. AMath 483/583 Lecture 27 May 27, Exceptions in Python. Exceptions in Python AMath 483/583 Lecture 27 May 27, 2011 Today: Python exception handling Python plus Fortran: f2py Next week: More Python plus Fortran Visualization Parallel IPython Read: Class notes and references If you

More information

15-440: Recitation 8

15-440: Recitation 8 15-440: Recitation 8 School of Computer Science Carnegie Mellon University, Qatar Fall 2013 Date: Oct 31, 2013 I- Intended Learning Outcome (ILO): The ILO of this recitation is: Apply parallel programs

More information

Bag of Tasks Parallelism. Timothy H. Kaiser, Ph.D.

Bag of Tasks Parallelism. Timothy H. Kaiser, Ph.D. Bag of Tasks Parallelism Timothy H. Kaiser, Ph.D. tkaiser@mines.edu Examples at: http://hpc.mines.edu/examples/ To just get mpi4py examples: mkdir examples cd examples curl http://hpc.mines.edu/examples/examples/mpi/mpi4py/mpi4py.tgz

More information

Mixed Python/C programming with Cython September /14. Mixed Python/C programming with Cython Ben Dudson, 22nd September 2017

Mixed Python/C programming with Cython September /14. Mixed Python/C programming with Cython Ben Dudson, 22nd September 2017 Mixed Python/C programming with Cython September 2017 1/14 Mixed Python/C programming with Cython Ben Dudson, 22nd September 2017 Mixed Python/C programming with Cython September 2017 2/14 Cython http://cython.org/

More information

Speeding up Python using Cython

Speeding up Python using Cython Speeding up Python using Cython Rolf Boomgaarden Thiemo Gries Florian Letsch Universität Hamburg November 28th, 2013 What is Cython? Compiler, compiles Python-like code to C-code Code is still executed

More information

A message contains a number of elements of some particular datatype. MPI datatypes:

A message contains a number of elements of some particular datatype. MPI datatypes: Messages Messages A message contains a number of elements of some particular datatype. MPI datatypes: Basic types. Derived types. Derived types can be built up from basic types. C types are different from

More information

High Performance Computing with Python

High Performance Computing with Python High Performance Computing with Python Pawel Pomorski SHARCNET University of Waterloo ppomorsk@sharcnet.ca March 15,2017 Outline Speeding up Python code with NumPy Speeding up Python code with Cython Speeding

More information

Scientific Computing Using. Atriya Sen

Scientific Computing Using. Atriya Sen Scientific Computing Using Atriya Sen Broad Outline Part I, in which I discuss several aspects of the Python programming language Part II, in which I talk about some Python modules for scientific computing

More information

An Introduction to Parallel Programming using MPI

An Introduction to Parallel Programming using MPI Lab 13 An Introduction to Parallel Programming using MPI Lab Objective: Learn the basics of parallel computing on distributed memory machines using MPI for Python Why Parallel Computing? Over the past

More information

Reusing this material

Reusing this material Messages Reusing this material This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License. http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en_us

More information

Python is awesome. awesomeness C/gcc C++/gcc Java 6 Go/6g Haskell/GHC Scala Lisp SBCL C#/Mono OCaml Python

Python is awesome. awesomeness C/gcc C++/gcc Java 6 Go/6g Haskell/GHC Scala Lisp SBCL C#/Mono OCaml Python Python is awesome 30 28.07 awesomeness 22.5 15 7.5 0 2.95 3.35 2.16 2.22 2.67 1.55 2.01 1.07 1.19 C/gcc C++/gcc Java 6 Go/6g Haskell/GHC Scala Lisp SBCL C#/Mono OCaml Python A benchmark http://geetduggal.wordpress.com/2010/11/25/speed-up-your-python-unladen-vs-shedskin-vs-pypy-vs-c/

More information

Administrivia. HW1 due Oct 4. Lectures now being recorded. I ll post URLs when available. Discussing Readings on Monday.

Administrivia. HW1 due Oct 4. Lectures now being recorded. I ll post URLs when available. Discussing Readings on Monday. Administrivia HW1 due Oct 4. Lectures now being recorded. I ll post URLs when available. Discussing Readings on Monday. Keep posting discussion on Piazza Python Multiprocessing Topics today: Multiprocessing

More information

Scientific Computing with Python and CUDA

Scientific Computing with Python and CUDA Scientific Computing with Python and CUDA Stefan Reiterer High Performance Computing Seminar, January 17 2011 Stefan Reiterer () Scientific Computing with Python and CUDA HPC Seminar 1 / 55 Inhalt 1 A

More information

AMath 483/583 Lecture 21

AMath 483/583 Lecture 21 AMath 483/583 Lecture 21 Outline: Review MPI, reduce and bcast MPI send and receive Master Worker paradigm References: $UWHPSC/codes/mpi class notes: MPI section class notes: MPI section of bibliography

More information

Collective Communication

Collective Communication Lab 14 Collective Communication Lab Objective: Learn how to use collective communication to increase the efficiency of parallel programs In the lab on the Trapezoidal Rule [Lab??], we worked to increase

More information

multiprocessing HPC Python R. Todd Evans January 23, 2015

multiprocessing HPC Python R. Todd Evans January 23, 2015 multiprocessing HPC Python R. Todd Evans rtevans@tacc.utexas.edu January 23, 2015 What is Multiprocessing Process-based parallelism Not threading! Threads are light-weight execution units within a process

More information

Message Passing Interface

Message Passing Interface Message Passing Interface DPHPC15 TA: Salvatore Di Girolamo DSM (Distributed Shared Memory) Message Passing MPI (Message Passing Interface) A message passing specification implemented

More information

Introduction to Parallel Programming Message Passing Interface Practical Session Part I

Introduction to Parallel Programming Message Passing Interface Practical Session Part I Introduction to Parallel Programming Message Passing Interface Practical Session Part I T. Streit, H.-J. Pflug streit@rz.rwth-aachen.de October 28, 2008 1 1. Examples We provide codes of the theoretical

More information

MPI introduction - exercises -

MPI introduction - exercises - MPI introduction - exercises - Paolo Ramieri, Maurizio Cremonesi May 2016 Startup notes Access the server and go on scratch partition: ssh a08tra49@login.galileo.cineca.it cd $CINECA_SCRATCH Create a job

More information

Parallel programming MPI

Parallel programming MPI Parallel programming MPI Distributed memory Each unit has its own memory space If a unit needs data in some other memory space, explicit communication (often through network) is required Point-to-point

More information

MPI Collective communication

MPI Collective communication MPI Collective communication CPS343 Parallel and High Performance Computing Spring 2018 CPS343 (Parallel and HPC) MPI Collective communication Spring 2018 1 / 43 Outline 1 MPI Collective communication

More information

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

PCAP Assignment I. 1. A. Why is there a large performance gap between many-core GPUs and generalpurpose multicore CPUs. Discuss in detail. PCAP Assignment I 1. A. Why is there a large performance gap between many-core GPUs and generalpurpose multicore CPUs. Discuss in detail. The multicore CPUs are designed to maximize the execution speed

More information

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

MPI 1. CSCI 4850/5850 High-Performance Computing Spring 2018 MPI 1 CSCI 4850/5850 High-Performance Computing Spring 2018 Tae-Hyuk (Ted) Ahn Department of Computer Science Program of Bioinformatics and Computational Biology Saint Louis University Learning Objectives

More information

Computing. Parallel Architectures

Computing. Parallel Architectures 14 Introduction to Parallel Computing Lab Objective: Many modern problems involve so many computations that running them on a single processor is impractical or even impossible. There has been a consistent

More information

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

CS4961 Parallel Programming. Lecture 16: Introduction to Message Passing 11/3/11. Administrative. Mary Hall November 3, 2011. CS4961 Parallel Programming Lecture 16: Introduction to Message Passing Administrative Next programming assignment due on Monday, Nov. 7 at midnight Need to define teams and have initial conversation with

More information

ITCS 4145/5145 Assignment 2

ITCS 4145/5145 Assignment 2 ITCS 4145/5145 Assignment 2 Compiling and running MPI programs Author: B. Wilkinson and Clayton S. Ferner. Modification date: September 10, 2012 In this assignment, the workpool computations done in Assignment

More information

An introduction to scientific programming with. Session 5: Extreme Python

An introduction to scientific programming with. Session 5: Extreme Python An introduction to scientific programming with Session 5: Extreme Python Managing your environment Efficiently handling large datasets Optimising your code Squeezing out extra speed Writing robust code

More information

Alien GOO a Lightweight C Embedding Facility. Jonathan Bachrach MIT CSAIL. Alien MIT 1 19DEC03

Alien GOO a Lightweight C Embedding Facility. Jonathan Bachrach MIT CSAIL. Alien MIT 1 19DEC03 Alien GOO a Lightweight C Embedding Facility Jonathan Bachrach MIT CSAIL Alien GOO @ MIT 1 Quick Goo Intro! Dynamic type-based object-oriented language! Interpreter semantics! Classes, multiple inheritance,

More information

Running Cython and Vectorization

Running Cython and Vectorization Running Cython and Vectorization 1 Getting Started with Cython overview hello world with Cython 2 Numerical Integration experimental setup adding type declarations cdef functions & calling external functions

More information

MPI Lab. How to split a problem across multiple processors Broadcasting input to other nodes Using MPI_Reduce to accumulate partial sums

MPI Lab. How to split a problem across multiple processors Broadcasting input to other nodes Using MPI_Reduce to accumulate partial sums MPI Lab Parallelization (Calculating π in parallel) How to split a problem across multiple processors Broadcasting input to other nodes Using MPI_Reduce to accumulate partial sums Sharing Data Across Processors

More information

Using jupyter notebooks on Blue Waters. Roland Haas (NCSA / University of Illinois)

Using jupyter notebooks on Blue Waters.   Roland Haas (NCSA / University of Illinois) Using jupyter notebooks on Blue Waters https://goo.gl/4eb7qw Roland Haas (NCSA / University of Illinois) Email: rhaas@ncsa.illinois.edu Jupyter notebooks 2/18 interactive, browser based interface to Python

More information

High Performance Computing Course Notes Message Passing Programming I

High Performance Computing Course Notes Message Passing Programming I High Performance Computing Course Notes 2008-2009 2009 Message Passing Programming I Message Passing Programming Message Passing is the most widely used parallel programming model Message passing works

More information

AMath 483/583 Lecture 18 May 6, 2011

AMath 483/583 Lecture 18 May 6, 2011 AMath 483/583 Lecture 18 May 6, 2011 Today: MPI concepts Communicators, broadcast, reduce Next week: MPI send and receive Iterative methods Read: Class notes and references $CLASSHG/codes/mpi MPI Message

More information

Non-Blocking Communications

Non-Blocking Communications Non-Blocking Communications Deadlock 1 5 2 3 4 Communicator 0 2 Completion The mode of a communication determines when its constituent operations complete. - i.e. synchronous / asynchronous The form of

More information

Big Data Analytics. Lars Schmidt-Thieme

Big Data Analytics. Lars Schmidt-Thieme Big Data Analytics Lars Schmidt-Thieme Information Systems and Machine Learning Lab (ISMLL) Institute of Computer Science University of Hildesheim, Germany A. Parallel Computing / 2. Message Passing Interface

More information

Extending and Embedding Python

Extending and Embedding Python Extending and Embedding Python Release 3.4.3 Guido van Rossum and the Python development team February 25, 2015 Python Software Foundation Email: docs@python.org CONTENTS 1 Recommended third party tools

More information

High-Performance Computing: MPI (ctd)

High-Performance Computing: MPI (ctd) High-Performance Computing: MPI (ctd) Adrian F. Clark: alien@essex.ac.uk 2015 16 Adrian F. Clark: alien@essex.ac.uk High-Performance Computing: MPI (ctd) 2015 16 1 / 22 A reminder Last time, we started

More information

ECE 574 Cluster Computing Lecture 13

ECE 574 Cluster Computing Lecture 13 ECE 574 Cluster Computing Lecture 13 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 15 October 2015 Announcements Homework #3 and #4 Grades out soon Homework #5 will be posted

More information

What is Point-to-Point Comm.?

What is Point-to-Point Comm.? 0 What is Point-to-Point Comm.? Collective Communication MPI_Reduce, MPI_Scatter/Gather etc. Communications with all processes in the communicator Application Area BEM, Spectral Method, MD: global interactions

More information

High Performance Python Micha Gorelick and Ian Ozsvald

High Performance Python Micha Gorelick and Ian Ozsvald High Performance Python Micha Gorelick and Ian Ozsvald Beijing Cambridge Farnham Koln Sebastopol Tokyo O'REILLY 0 Table of Contents Preface ix 1. Understanding Performant Python 1 The Fundamental Computer

More information

Running Cython and Vectorization

Running Cython and Vectorization Running Cython and Vectorization 1 Getting Started with Cython overview hello world with Cython 2 Numerical Integration experimental setup adding type declarations cdef functions & calling external functions

More information

Python Scripting for Computational Science

Python Scripting for Computational Science Hans Petter Langtangen Python Scripting for Computational Science Third Edition With 62 Figures Sprin ger Table of Contents 1 Introduction 1 1.1 Scripting versus Traditional Programming 1 1.1.1 Why Scripting

More information

Introduction to MPI. HY555 Parallel Systems and Grids Fall 2003

Introduction to MPI. HY555 Parallel Systems and Grids Fall 2003 Introduction to MPI HY555 Parallel Systems and Grids Fall 2003 Outline MPI layout Sending and receiving messages Collective communication Datatypes An example Compiling and running Typical layout of an

More information

Holland Computing Center Kickstart MPI Intro

Holland Computing Center Kickstart MPI Intro Holland Computing Center Kickstart 2016 MPI Intro Message Passing Interface (MPI) MPI is a specification for message passing library that is standardized by MPI Forum Multiple vendor-specific implementations:

More information

Parallel Programming Assignment 3 Compiling and running MPI programs

Parallel Programming Assignment 3 Compiling and running MPI programs Parallel Programming Assignment 3 Compiling and running MPI programs Author: Clayton S. Ferner and B. Wilkinson Modification date: October 11a, 2013 This assignment uses the UNC-Wilmington cluster babbage.cis.uncw.edu.

More information

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

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI CS 470 Spring 2018 Mike Lam, Professor Distributed Programming & MPI MPI paradigm Single program, multiple data (SPMD) One program, multiple processes (ranks) Processes communicate via messages An MPI

More information

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

CS 470 Spring Mike Lam, Professor. Distributed Programming & MPI CS 470 Spring 2017 Mike Lam, Professor Distributed Programming & MPI MPI paradigm Single program, multiple data (SPMD) One program, multiple processes (ranks) Processes communicate via messages An MPI

More information

Guillimin HPC Users Meeting March 17, 2016

Guillimin HPC Users Meeting March 17, 2016 Guillimin HPC Users Meeting March 17, 2016 guillimin@calculquebec.ca McGill University / Calcul Québec / Compute Canada Montréal, QC Canada Outline Compute Canada News System Status Software Updates Training

More information

TH IRD EDITION. Python Cookbook. David Beazley and Brian K. Jones. O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo

TH IRD EDITION. Python Cookbook. David Beazley and Brian K. Jones. O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo TH IRD EDITION Python Cookbook David Beazley and Brian K. Jones O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Tokyo Table of Contents Preface xi 1. Data Structures and Algorithms 1 1.1. Unpacking

More information

Non-Blocking Communications

Non-Blocking Communications Non-Blocking Communications Reusing this material This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License. http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en_us

More information

CUDA GPGPU Workshop 2012

CUDA GPGPU Workshop 2012 CUDA GPGPU Workshop 2012 Parallel Programming: C thread, Open MP, and Open MPI Presenter: Nasrin Sultana Wichita State University 07/10/2012 Parallel Programming: Open MP, MPI, Open MPI & CUDA Outline

More information

Python Scripting for Computational Science

Python Scripting for Computational Science Hans Petter Langtangen Python Scripting for Computational Science Third Edition With 62 Figures 43 Springer Table of Contents 1 Introduction... 1 1.1 Scripting versus Traditional Programming... 1 1.1.1

More information

Agenda. MPI Application Example. Praktikum: Verteiltes Rechnen und Parallelprogrammierung Introduction to MPI. 1) Recap: MPI. 2) 2.

Agenda. MPI Application Example. Praktikum: Verteiltes Rechnen und Parallelprogrammierung Introduction to MPI. 1) Recap: MPI. 2) 2. Praktikum: Verteiltes Rechnen und Parallelprogrammierung Introduction to MPI Agenda 1) Recap: MPI 2) 2. Übungszettel 3) Projektpräferenzen? 4) Nächste Woche: 3. Übungszettel, Projektauswahl, Konzepte 5)

More information

L14 Supercomputing - Part 2

L14 Supercomputing - Part 2 Geophysical Computing L14-1 L14 Supercomputing - Part 2 1. MPI Code Structure Writing parallel code can be done in either C or Fortran. The Message Passing Interface (MPI) is just a set of subroutines

More information

The Message Passing Interface (MPI) TMA4280 Introduction to Supercomputing

The Message Passing Interface (MPI) TMA4280 Introduction to Supercomputing The Message Passing Interface (MPI) TMA4280 Introduction to Supercomputing NTNU, IMF January 16. 2017 1 Parallelism Decompose the execution into several tasks according to the work to be done: Function/Task

More information

Introduction to the Julia language. Marc Fuentes - SED Bordeaux

Introduction to the Julia language. Marc Fuentes - SED Bordeaux Introduction to the Julia language Marc Fuentes - SED Bordeaux Outline 1 motivations Outline 1 motivations 2 Julia as a numerical language Outline 1 motivations 2 Julia as a numerical language 3 types

More information

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

Introduction to MPI. Ekpe Okorafor. School of Parallel Programming & Parallel Architecture for HPC ICTP October, 2014 Introduction to MPI Ekpe Okorafor School of Parallel Programming & Parallel Architecture for HPC ICTP October, 2014 Topics Introduction MPI Model and Basic Calls MPI Communication Summary 2 Topics Introduction

More information

CS 426. Building and Running a Parallel Application

CS 426. Building and Running a Parallel Application CS 426 Building and Running a Parallel Application 1 Task/Channel Model Design Efficient Parallel Programs (or Algorithms) Mainly for distributed memory systems (e.g. Clusters) Break Parallel Computations

More information

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

MPI 2. CSCI 4850/5850 High-Performance Computing Spring 2018 MPI 2 CSCI 4850/5850 High-Performance Computing Spring 2018 Tae-Hyuk (Ted) Ahn Department of Computer Science Program of Bioinformatics and Computational Biology Saint Louis University Learning Objectives

More information

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

Message Passing Interface. most of the slides taken from Hanjun Kim Message Passing Interface most of the slides taken from Hanjun Kim Message Passing Pros Scalable, Flexible Cons Someone says it s more difficult than DSM MPI (Message Passing Interface) A standard message

More information

Introduction to Scientific Computing with Python, part two.

Introduction to Scientific Computing with Python, part two. Introduction to Scientific Computing with Python, part two. M. Emmett Department of Mathematics University of North Carolina at Chapel Hill June 20 2012 The Zen of Python zen of python... fire up python

More information

Parallel Programming

Parallel Programming Parallel Programming MPI Part 1 Prof. Paolo Bientinesi pauldj@aices.rwth-aachen.de WS17/18 Preliminaries Distributed-memory architecture Paolo Bientinesi MPI 2 Preliminaries Distributed-memory architecture

More information

CS 179: GPU Programming. Lecture 14: Inter-process Communication

CS 179: GPU Programming. Lecture 14: Inter-process Communication CS 179: GPU Programming Lecture 14: Inter-process Communication The Problem What if we want to use GPUs across a distributed system? GPU cluster, CSIRO Distributed System A collection of computers Each

More information

Programming Assignment 0

Programming Assignment 0 CMSC 17 Computer Networks Fall 017 Programming Assignment 0 Assigned: August 9 Due: September 7, 11:59:59 PM. 1 Description In this assignment, you will write both a TCP client and server. The client has

More information

Computing with the Moore Cluster

Computing with the Moore Cluster Computing with the Moore Cluster Edward Walter An overview of data management and job processing in the Moore compute cluster. Overview Getting access to the cluster Data management Submitting jobs (MPI

More information

Supercomputing environment TMA4280 Introduction to Supercomputing

Supercomputing environment TMA4280 Introduction to Supercomputing Supercomputing environment TMA4280 Introduction to Supercomputing NTNU, IMF February 21. 2018 1 Supercomputing environment Supercomputers use UNIX-type operating systems. Predominantly Linux. Using a shell

More information

Topics. Lecture 6. Point-to-point Communication. Point-to-point Communication. Broadcast. Basic Point-to-point communication. MPI Programming (III)

Topics. Lecture 6. Point-to-point Communication. Point-to-point Communication. Broadcast. Basic Point-to-point communication. MPI Programming (III) Topics Lecture 6 MPI Programming (III) Point-to-point communication Basic point-to-point communication Non-blocking point-to-point communication Four modes of blocking communication Manager-Worker Programming

More information

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

MPI Tutorial. Shao-Ching Huang. High Performance Computing Group UCLA Institute for Digital Research and Education MPI Tutorial Shao-Ching Huang High Performance Computing Group UCLA Institute for Digital Research and Education Center for Vision, Cognition, Learning and Art, UCLA July 15 22, 2013 A few words before

More information

Allinea DDT Debugger. Dan Mazur, McGill HPC March 5,

Allinea DDT Debugger. Dan Mazur, McGill HPC  March 5, Allinea DDT Debugger Dan Mazur, McGill HPC daniel.mazur@mcgill.ca guillimin@calculquebec.ca March 5, 2015 1 Outline Introduction and motivation Guillimin login and DDT configuration Compiling for a debugger

More information

Interfacing With Other Programming Languages Using Cython

Interfacing With Other Programming Languages Using Cython Lab 1 Interfacing With Other Programming Languages Using Cython Lab Objective: Learn to interface with object files using Cython. This lab should be worked through on a machine that has already been configured

More information

Message Passing Interface (MPI)

Message Passing Interface (MPI) CS 220: Introduction to Parallel Computing Message Passing Interface (MPI) Lecture 13 Today s Schedule Parallel Computing Background Diving in: MPI The Jetson cluster 3/7/18 CS 220: Parallel Computing

More information