OpenMP Blue Waters Undergraduate Petascale Education Program May 29 – June 10 2011.

Slides:



Advertisements
Similar presentations
OpenMP.
Advertisements

Parallel Processing with OpenMP
Introduction to Openmp & openACC
May 2, 2015©2006 Craig Zilles1 (Easily) Exposing Thread-level Parallelism  Previously, we introduced Multi-Core Processors —and the (atomic) instructions.
1 Programming Explicit Thread-level Parallelism  As noted previously, the programmer must specify how to parallelize  But, want path of least effort.
PARALLEL PROGRAMMING WITH OPENMP Ing. Andrea Marongiu
Scientific Programming OpenM ulti- P rocessing M essage P assing I nterface.
1 Tuesday, November 07, 2006 “If anything can go wrong, it will.” -Murphy’s Law.
OpenMP Andrew Williams References Chandra et al, Parallel Programming in OpenMP, Morgan Kaufmann Publishers 1999 OpenMP home:
Computer Architecture II 1 Computer architecture II Programming: POSIX Threads OpenMP.
Parallel Programming by Tiago Sommer Damasceno Using OpenMP
Games at Bolton OpenMP Techniques Andrew Williams
1 ITCS4145/5145, Parallel Programming B. Wilkinson Feb 21, 2012 Programming with Shared Memory Introduction to OpenMP.
OpenMPI Majdi Baddourah
A Very Short Introduction to OpenMP Basile Schaeli EPFL – I&C – LSP Vincent Keller EPFL – STI – LIN.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
Introduction to OpenMP Introduction OpenMP basics OpenMP directives, clauses, and library routines.
High Performance Computation --- A Practical Introduction Chunlin Tian NAOC Beijing 2011.
1 Parallel Programming With OpenMP. 2 Contents  Overview of Parallel Programming & OpenMP  Difference between OpenMP & MPI  OpenMP Programming Model.
Budapest, November st ALADIN maintenance and phasing workshop Short introduction to OpenMP Jure Jerman, Environmental Agency of Slovenia.
Programming with Shared Memory Introduction to OpenMP
1 Copyright © 2010, Elsevier Inc. All rights Reserved Chapter 5 Shared Memory Programming with OpenMP An Introduction to Parallel Programming Peter Pacheco.
Executing OpenMP Programs Mitesh Meswani. Presentation Outline Introduction to OpenMP Machine Architectures Shared Memory (SMP) Distributed Memory MPI.
1 Datamation Sort 1 Million Record Sort using OpenMP and MPI Sammie Carter Department of Computer Science N.C. State University November 18, 2004.
Parallel Programming in Java with Shared Memory Directives.
Lecture 8: Caffe - CPU Optimization
Chapter 17 Shared-Memory Programming. Introduction OpenMP is an application programming interface (API) for parallel programming on multiprocessors. It.
OpenMP - Introduction Süha TUNA Bilişim Enstitüsü UHeM Yaz Çalıştayı
OpenMP: Open specifications for Multi-Processing What is OpenMP? Join\Fork model Join\Fork model Variables Variables Explicit parallelism Explicit parallelism.
O PEN MP (O PEN M ULTI -P ROCESSING ) David Valentine Computer Science Slippery Rock University.
OpenMP – Introduction* *UHEM yaz çalıştayı notlarından derlenmiştir. (uhem.itu.edu.tr)
S AN D IEGO S UPERCOMPUTER C ENTER N ATIONAL P ARTNERSHIP FOR A DVANCED C OMPUTATIONAL I NFRASTRUCTURE On pearls and perils of hybrid OpenMP/MPI programming.
Computer Organization David Monismith CS345 Notes to help with the in class assignment.
CS 838: Pervasive Parallelism Introduction to OpenMP Copyright 2005 Mark D. Hill University of Wisconsin-Madison Slides are derived from online references.
Work Replication with Parallel Region #pragma omp parallel { for ( j=0; j
OpenMP fundamentials Nikita Panov
High-Performance Parallel Scientific Computing 2008 Purdue University OpenMP Tutorial Seung-Jai Min School of Electrical and Computer.
Introduction to OpenMP
HPC1 OpenMP E. Bruce Pitman October, HPC1 Outline What is OpenMP Multi-threading How to use OpenMP Limitations OpenMP + MPI References.
9/22/2011CS4961 CS4961 Parallel Programming Lecture 9: Task Parallelism in OpenMP Mary Hall September 22,
Threaded Programming Lecture 2: Introduction to OpenMP.
Introduction to Pragnesh Patel 1 NICS CSURE th June 2015.
CS/EE 217 GPU Architecture and Parallel Programming Lecture 23: Introduction to OpenACC.
Heterogeneous Computing using openMP lecture 2 F21DP Distributed and Parallel Technology Sven-Bodo Scholz.
COMP7330/7336 Advanced Parallel and Distributed Computing OpenMP: Programming Model Dr. Xiao Qin Auburn University
Heterogeneous Computing using openMP lecture 1 F21DP Distributed and Parallel Technology Sven-Bodo Scholz.
1 ITCS4145 Parallel Programming B. Wilkinson March 23, hybrid-abw.ppt Hybrid Parallel Programming Introduction.
Introduction to OpenMP
SHARED MEMORY PROGRAMMING WITH OpenMP
CS427 Multicore Architecture and Parallel Computing
Introduction to OpenMP
Shared-Memory Programming
September 4, 1997 Parallel Processing (CS 667) Lecture 5: Shared Memory Parallel Programming with OpenMP* Jeremy R. Johnson Parallel Processing.
SHARED MEMORY PROGRAMMING WITH OpenMP
OpenMP Quiz B. Wilkinson January 22, 2016.
Multi-core CPU Computing Straightforward with OpenMP
September 4, 1997 Parallel Processing (CS 730) Lecture 5: Shared Memory Parallel Programming with OpenMP* Jeremy R. Johnson Wed. Jan. 31, 2001 *Parts.
Hybrid Parallel Programming
September 4, 1997 Parallel Processing (CS 730) Lecture 5: Shared Memory Parallel Programming with OpenMP* Jeremy R. Johnson *Parts of this lecture.
Programming with Shared Memory Introduction to OpenMP
Hybrid Parallel Programming
DNA microarrays. Infinite Mixture Model-Based Clustering of DNA Microarray Data Using openMP.
Hybrid Parallel Programming
Introduction to OpenMP
Multithreading Why & How.
OpenMP Quiz.
Parallel Computing Explained How to Parallelize a Code
OpenMP on HiHAT James Beyer, 18 Sep 2017.
Hybrid Parallel Programming
OpenMP Parallel Programming
Presentation transcript:

OpenMP Blue Waters Undergraduate Petascale Education Program May 29 – June

OpenMP BWUPEP2011, UIUC, May 29 - June Outline What is OpenMP? Why do we care about it? What does it take to write an OpenMP program? What does it take to compile an OpenMP program? What does it take to run an OpenMP program?

What is OpenMP? Shared Memory Parallelism Multithreaded code (what’s a thread?) OpenMP == “Open Multi Processing” Just like MPI, OpenMP is a standard. This one consists of: Compiler directives Functions Environment variables Since it’s only a standard, we must have an implementation Intel compilers, GNU compilers Only C/C++/Fortran OpenMP BWUPEP2011, UIUC, May 29 - June

Compiler Directives Hints to the compiler; Suggestions for it to do something special with your code. Is the compiler required to listen to you? (Hint: it’s not) These directives are called “pragmas” (i.e., pragmatic) The most common pragma looks like this: #pragma omp parallel for (We’ll get more into what it actually means later) They will control how our code gets parallelized OpenMP BWUPEP2011, UIUC, May 29 - June

Functions The OpenMP functions allow us to gather information about—and alter—the OpenMP runtime environment. Just like with MPI, we must include the OpenMP library: #include Then we can use OpenMP functions like: omp_get_thread_num(); These functions will let us get, and use, the OpenMP equivalent of MPI’s rank and size. OpenMP BWUPEP2011, UIUC, May 29 - June

Environment Variables The Environment Variables provide a way for us to dictate certain features of the OpenMP runtime. For example, the number of threads: setenv OMP_NUM_THREAD=8 This will tell the environment to run our program with 8 threads. Other options include: OMP_SCHEDULE OMP_STACKSIZE OpenMP BWUPEP2011, UIUC, May 29 - June

Why do we care? MPI is hard OpenMP is easy (you’ll see soon) No need to pass data around Avoid lots of concurrency issues and complications arising from complex MPI code “Instant” gratification Why might OpenMP/SharedMemory be “bad”? OpenMP BWUPEP2011, UIUC, May 29 - June

Write OpenMP Let’s start with the canonical “Hello World”: int main () { printf(“Hello World!\n”); } OpenMP BWUPEP2011, UIUC, May 29 - June

Write OpenMP Now with an OpenMP pragma: int main () { #pragma omp parallel { printf(“Hello World!\n”); } OpenMP BWUPEP2011, UIUC, May 29 - June

Better Example #include int main () { int i; #pragma omp parallel for for (i = 0; i < 10; i++) { printf(“i=%d\n”, i); } OpenMP BWUPEP2011, UIUC, May 29 - June

Compile (and Run) OpenMP DO THIS ON AL-SALAM cd./qsub-interactive-1-node cp -r ~fitz/BWUPEP2011_OpenMP. gcc -fopenmp -o for for.c./for What happened? OpenMP BWUPEP2011, UIUC, May 29 - June

Modifications What happens if you split up the printf inside the for loop? printf(“i=”); printf(“%d\n”, i); What does the output look like? Why is this happening? Do we want to “fix” it? OpenMP BWUPEP2011, UIUC, May 29 - June

Rank and size again #include #define WORKLOAD 1 int main () { int rank, size, i; #pragma omp parallel { rank = omp_get_thread_num(); for(i=1; i<WORKLOAD; ++i); printf("Hello World from thread %d\n", rank); if ( rank == 0 ) { size = omp_get_num_threads(); printf("There are %d threads\n",size); } return 0; } OpenMP BWUPEP2011, UIUC, May 29 - June

Rank and size again What does it do? (Hint: not what we want) Thoughts for improving? (Hint: SMP) OpenMP BWUPEP2011, UIUC, May 29 - June

Your turn… Take a look at the other code in the BWUPEP2011_OpenMP directory (timing.c). Read it, try to understand it, run it, see if you can change it to get different behavior. Take a look at your serial calculatePI code, try to add OpenMP to it (Hint: it should only take one pragma; think reduce too) Take a look at the serial NBody code. Remember the gprof’ing we did? Given that information, where do you think the best place for an OpenMP pragma is? Try it! OpenMP BWUPEP2011, UIUC, May 29 - June