Practical Introduction to
|
|
- Jemima Boyd
- 5 years ago
- Views:
Transcription
1 Outline of the workshop Practical Introduction to Bart Oldeman, Calcul Québec McGill HPC Theoretical / practical introduction Parallelizing your serial code What is OpenMP? Why do we need it? How do we run OpenMP codes (on the Guillimin cluster)? How to program with OpenMP? Program structure Basic functions Examples 1 2 Outline of the workshop Practical exercises on Guillimin Login, setup environment, launch OpenMP code Analyzing and running examples Modifying and tuning OpenMP codes 3 Parallelizing your serial code Models for parallel computing (as an ordinary user sees it...) Implicit Parallelization minimum work for you Threaded libraries (MKL, ACML, GOTO, etc...) Compiler directives (OpenMP) Good for desktops and shared memory machines Explicit Parallelization work is required! You tell what should be done on what CPU Low-level option for shared memory machines: POSIX Threads (pthreads) Solution for distributed clusters (MPI: shared nothing!) 4
2 OpenMP Shared Memory API Open Multi-Processing: An Application Program Interface for multi-threaded programs in a shared-memory environment. Consists of Compiler directives Runtime library routines Environment variables Allows for relatively simple incremental parallelization. Not distributed, but can be combined with MPI (hybrid). 5 Shared memory approach Thread 0 Private memory Shared memory Thread 1 Private memory Most memory is shared by all threads. Each thread also has some private memory: variables explicitly declared private, local variables in functions and subroutines. 6 OpenMP: fork/join model Master Thread Serial Region Parallel Region Serial Region Parallel Region Serial Region Worker Threads Fork Join Fork Join Master + Workers = Team Implementations use thread pools so worker threads sleep from join to fork. 7 What is OpenMP for a user? What is OpenMP for a user? OpenMP is NOT a language! OpenMP is NOT a compiler or specific product OpenMP is a de-facto industry standard, a specification for an Application Program Interface (API). You use its directives, routines, and environment variables. You compile and link your code with specific flags. History: version 1.0 (1997), 2.5 (2005), 3.0 (2008), 3.1 (2011), 4.0 (2013). Different implementations : GCC (since version 4.2), Intel, PGI, Visual C++, Solaris Studio,... 8
3 Basic features of OpenMP program Include basic definitions (#include <omp.h>, INCLUDE omp lib.h, or USE omp lib). Parallel region declared by a directive of the form #pragma omp parallel (C) or!$omp PARALLEL (Fortran), declaring which variables are private. Optional: code only compiled for OpenMP: use OPENMP preprocessor symbol (C) or!$ prefix (Fortran). 9 Fortran PROGRAM hello!$ USE omp lib IMPLICIT NONE INTEGER rank, size rank = 0 size = 1 Example: Hello from N cores!$omp PARALLEL PRIVATE(rank, size)!$ size = omp get num threads()!$ rank = omp get thread num() WRITE(*,*) Hello from processor,& rank, of, size!$omp END PARALLEL END PROGRAM hello C #include <stdio.h> #ifdef OPENMP #include <omp.h> #endif int main (int argc, char * argv[]) int rank = 0, size = 1; #ifdef OPENMP #pragma omp parallel private(rank, size) #endif #ifdef OPENMP rank = omp get thread num(); size = omp get num threads(); #endif printf("hello from processor %d" " of %d\n", rank, size ); return 0; 10 POSIX Threads Hello from N cores // pthreads.c #include <stdio.h> #include <pthread.h> #define SIZE 4 void *hello(void *arg) printf( "Hello from processor %d of %d\n", *(int *)arg, SIZE ); return NULL; int main(int argc, char* argv[]) int i, p[size]; pthread t threads[size]; for (i = 1; i < SIZE; i++) /* Fork threads */ p[i] = i; pthread create(&threads[i], NULL, hello, &p[i]); p[0] = 0; hello(&p[0]); /* thread 0 greets as well */ for (i = 1; i < SIZE; i++) /* Join threads. */ pthread join(threads[i], NULL); return 0; 11 Compiling your OpenMP code NOT defined by the standard A special compilation flag must be used. On the Guillimin cluster: module add gcc gcc -fopenmp hello.c -o hello gfortran -fopenmp hello.f90 -o hello module add ifort icc icc -openmp hello.c -o hello ifort -openmp hello.f90 -o hello module add pgi pgcc -mp hello.c -o hello pgfortran -mp hello.f90 -o hello 12
4 Running your OpenMP code Important: environment variable OMP NUM THREADS. export OMP NUM THREADS=4./hello Hello from processor 2 of 4 Hello from processor 0 of 4 Hello from processor 3 of 4 Hello from processor 1 of 4 unset OMP NUM THREADS pgcc -mp hello.c -o hello./hello Hello from processor 0 of 1 gcc -fopenmp hello.c -o hello./hello Hello from processor 3 of 8 (...) 13 Running your OpenMP code On your laptop or desktop, just compile and run your code as above. On Guillimin cluster, use batch system to submit non-trivial OpenMP jobs! Example: hello.pbs: #!/bin/bash #PBS -l nodes=1:ppn=2 #PBS -l walltime=00:05:00 #PBS -V #PBS -N hello cd $PBS O WORKDIR export OMP NUM THREADS=2./hello > hello.out Submit your job: guillimin> msub -q class hello.pbs 14 Exercise 1: Log in to Guillimin, setting up the environment 1) Log in to Guillimin: ssh username@guillimin.clumeq.ca 2) Check for loaded software modules: guillimin> module list 3) See all available modules: guillimin> module av 4) Load necessary modules: guillimin> module add ifort icc 5) Check loaded modules again 15 Exercise 2: Hello program, compilation 1) Copy all files to your home directory: guillimin> cp /software/workshop/openmp/*. 2) Compile your code: guillimin> ifort -openmp hello.f90 -o hello guillimin> icc -openmp hello.c -o hello 16
5 Exercise 2: Hello, submitting your job 3) View the file hello.pbs : #!/bin/bash #PBS -l nodes=1:ppn=2 #PBS -l walltime=00:05:00 #PBS -V #PBS -N hello cd $PBS O WORKDIR export OMP NUM THREADS=2./hello > hello.out Exercise 2: Hello, submitting your job 4) Submit your job: guillimin> msub -q class hello.pbs 5) Check the job status: guillimin> showq -u <username> 6) Check the output (hello.out) Exercise 2: Hello, compile and run Alternatively, using interactive msub, or on your own Mac/Linux/Cygwin/MSYS computer: 1) Interactive login: msub -q class -I -l nodes=1:ppn=2,walltime=3:00:00 or create and then copy all files to a directory: yourlaptop> scp username@guillimin.clumeq.ca:/software/workshop/openmp/*. 2) Compile your code: > gfortran -fopenmp hello.f90 -o hello > gcc -fopenmp hello.c -o hello 3) Run your code: > # can use any value here > # defaults to number of cores > export OMP NUM THREADS=2 >./hello 19 OpenMP directives Format: sentinel directive [clause,] where sentinel is #pragma omp or!$omp. Examples: #pragma omp parallel (C),!$OMP PARALLEL,!$OMP END PARALLEL (Fortran): Parallel region construct. #pragma omp for: A workshare construct that makes a loop parallel (!$OMP DO in Fortran). #pragma omp parallel for: A combined construct: defines a parallel region that only contains the loop. #pragma omp barrier: A synchronization directive: all threads wait for each other here. 20
6 OpenMP clauses Examples: Data scope: private and shared.!$omp parallel private(i) shared(x) The variable i is private to the thread but the variable x is shared with all other threads. Default: all variables shared except loop variables (C: outer, Fortran:all), and variables declared inside block.!$omp parallel default(shared) private(i) All variables are shared except i. nowait in #pragma omp for nowait A loop where threads do not wait for each other upon completion. 21 OpenMP important library routines int omp get max threads(void); Get maximum number of threads used here. void omp set num threads(int); Set number of threads for next parallel region. int omp get thread num(void); Get current thread number in parallel region. int omp get num threads(void); Get number of threads in parallel region. double omp get wtime(void); Portable wall clock timing routine. More exist, for example for locks and nested regions. 22 OpenMP important environment variables OMP NUM THREADS Sets the maximum number of threads used. OMP SCHEDULE Used for run-time scheduling. More exist, for example to control nested parallelism. 23 parallel for void addvectors(const int *a, const int *b, int *c, int n) int i; #pragma omp parallel for for (i = 0; i < n; i++) Here i is automatically made private because it is the loop variable. All other variables are shared. Loop split between threads, for example with two threads, for n=10, thread 0 does index 0 to 4 and thread 1 does index 5 to 9. 24
7 parallel for Eliminate overhead from fork and join (in practise: synchronization) by using just one parallel region for two vector additions: void addvectors(const int *a, const int *b, int *c, int n) int i; #pragma omp for for (i = 0; i < n; i++)... #pragma omp parallel addvectors(a, b, c, n); addvectors(b, c, d, n); 25 parallel for, nowait and barrier void addvectors(const int *a, const int *b, int *c, int n) int i; #pragma omp for nowait for (i = 0; i < n; i++)... #pragma omp parallel addvectors(a, b, c, n); #pragma omp barrier addvectors(b, c, d, n/2); addvectors(e, f, g, n); omp for by default implies a barrier where all threads wait at the end of the loop. Eliminate synchronization overhead using nowait But need to add explicit barrier (dependency)! 26 parallel for: if clause The if clause allows conditional parallel regions: if n is too small, the overhead is not worth it: void addvectors(const int *a, const int *b, int *c, int n) int i; #pragma omp for for (i = 0; i < n; i++)... #pragma omp parallel if (n > 10000) addvectors(a, b, c, n); 27 parallel for: scheduling parallel for: scheduling schedule(static, 10000) allocates chunks of loop iterations to every thread: void addvectors(const int *a, const int *b, int *c, int n) int i; #pragma omp for schedule(static, 10000) for (i = 0; i < n; i++) Use dynamic instead of static to dynamically assign threads, if one finishes it is assigned the next chunk. Useful for unequal work within iterations. guided instead of dynamic: chunk sizes decrease as less work is left to do. runtime: use OMP SCHEDULE environment variable.28
8 parallel: manual scheduling (SPMD style) SPMD=Single Program Multiple Data, like in MPI. void addvectors(const int *a, const int *b, int *c, int n) for (i = 0; i < n; i++)... int tid, nthreads, low, high; #pragma omp parallel default(shared) private(tid, nthreads,\ low, high) tid = omp get thread num(); nthreads = omp get num threads(); low = (n * tid) / nthreads; high = (n * (tid + 1)) / nthreads; addvectors(&a[low], &b[low], &c[low], high-low); Calculate which thread does which loop iterations. Note: no barrier. 29 SPMD vs. worksharing Worksharing (omp for/omp do) is easiest to implement. SPMD (do work based on thread ID) may give better performance but is harder to implement. SPMD like in MPI: Instead of using large shared arrays, use smaller arrays private to threads: mark all (non-read-only) global and persistent (static/save) variables threadprivate, and communicate using buffers and barriers. Fewer cache misses using more private data may give better performance. More advanced topic: see Advanced OpenMP workshop in June. 30 sections (SPMD construct) #pragma omp parallel sections #pragma omp section addvectors(a, b, c, n); #pragma omp section printf("hello world!\n"); #pragma omp section printf("i may or may not be the third thread\n"); The sections are individual code blocks that are distributed over the threads. More flexible alternative (OpenMP 3.0): omp task, useful when traversing dynamic data structures (lists, trees, etc.). 31 workshare (Fortran) integer a(10000), b(10000), c(10000), d(10000)!$omp PARALLEL!$OMP WORKSHARE c(:) = a(:) + b(:)!$omp END WORKSHARE NOWAIT!$OMP WORKSHARE d(:) = a(:)!$omp END WORKSHARE NOWAIT!$OMP END PARALLEL Array assignments in Fortran are distributed among threads like loops. Note that nowait in Fortran comes at the end. 32
9 Exercise 3: Modifying Hello Let s ask each CPU to do its own computation... IF (rank == 0) THEN a=sqrt(2.0) b=0.0 WRITE(*,*) a,b=,a,b, on proc,rank END IF IF (rank == 1) THEN a=0.0 b=sqrt(3.0) WRITE(*,*) a,b=,a,b, on proc,rank END IF Exercise 4: Modifying Hello Do the same thing, now using omp sections Recompile as before and submit to the queue... Recompile as before and submit to the queue Race conditions (Data races) innerprod.c, innerprod.f90 #pragma omp parallel for private(i) shared(ip,a,b) ip += a[i] * b[i]; Problem: could be internally run as: int register = ip; register += a[i] * b[i]; ip = register; Threads may sum to their private CPU registers at the same time and overwrite ip, losing the addition from the other threads! 35 Race conditions a=1,2, b=3,4, inner product 1*3+2*4=11, two threads. ip register0 register1 tid=0 int register = ip; 0 0 unknown tid=1 int register = ip; tid=0 register += a[0] * b[0]; tid=1 register += a[1] * b[1]; tid=0 ip = register; tid=1 ip = register; Wrong result: ip=8. But may just as well be: ip=3: non-deterministic. 36
10 Solution: critical section Solution: atomic section #pragma omp parallel for private(i) shared(ip,a,b) #pragma omp critical ip += a[i] * b[i]; critical makes sure only one thread can run the (compound) statement at a time Problem: slow! #pragma omp parallel for private(i) shared(ip,a,b) #pragma omp atomic ip += a[i] * b[i]; atomic is like critical but can only apply to a specific memory location. Less general but less overhead Solution: local summing #pragma omp parallel private(i,localip) shared(ip,a,b) local #pragma omp for nowait localip += a[i] * b[i]; #pragma omp atomic ip += localip; Still needs atomic but only times the number of threads, not times N, greatly reducing overhead and improving performance. 39 Solution: local summing using array int *localips = malloc(omp get max threads()*sizeof(*localips)); #pragma omp parallel private(i,tid) shared(ip,a,b,localips) tid = omp get thread num(); localips[tid] = 0; #pragma omp for localips[tid] += a[i] * b[i]; #pragma omp single for (i = 0; i < omp get num threads(); i++) ip += localips[i]; One single thread does the final summing. Could also use omp master here, to force the master thread to do the final summing. omp master works like if (tid==0). 40
11 Solution: local summing using array int *localips = malloc(omp get max threads()*sizeof(*localips)); #pragma omp parallel private(i,tid) shared(ip,a,b,localips) tid = omp get thread num(); localips[tid] = 0; #pragma omp for localips[tid] += a[i] * b[i]; #pragma omp single for (i = 0; i < omp get num threads(); i++) ip += localips[i]; master and single are especially useful for I/O. Problem here: false cache sharing of the array localips. 41 Solution: local summing using array int *localips = malloc(omp get max threads()*sizeof(*localips)); #pragma omp parallel private(i,tid,localip) shared(ip,a,b,localips) tid = omp get thread num(); local #pragma omp for nowait localip += a[i] * b[i]; #pragma omp barrier localips[tid] = localip; #pragma omp single for (i = 0; i < omp get num threads(); i++) ip += localips[i]; Minimizes false sharing, moving it outside the loop. Could also use padding in localips, but need to know size of L1 cache (e.g. 64 bytes). 42 Easiest solution: use reduction #pragma omp parallel for reduction(+:ip) ip += a[i] * b[i]; Reduction is the most straightforward solution. Caveat: only works on scalars, and cannot control rounding errors caused by floating point calculations. For vectors use one of the other methods. 43 Exercise 5: Compilation error See omp bug.c or omp bug.f90, courtesy of Blaise Barney, Lawrence Livermore National Laboratory and find the compilation error in: #pragma omp parallel for \ shared(a,b,c,chunk) \ private(i,tid) \ schedule(static,chunk) tid = omp get thread num(); for (i=0; i < N; i++) printf("tid= %d i= %d c[i]= %f\n", tid, i, c[i]); /* end of parallel for construct */ 44
12 Exercise 6: Computing π Consider pi collect.c(f90), π = 4 arctan 1 = 4 Let s add timings: i=0 ( 1) i 1 2i + 1 = double t1, t2 t1 = omp get wtime();... t2 = omp get wtime(); printf("time = %.16f\n", t2-t1); Try some of the other alternatives (atomic, critical) to a reduction and measure the performance. 45 Exercise 7: Matrix multiplication See the file mm.c or mm.f90. Make the initialization and multiplication parallel and measure the speedup. 46 Further information: The standard itself, news, development, links to tutorials: Intel tutorial on YouTube (from Tim Mattson): New: OpenMP 4.0: thread affinity, SIMD, accelerators (GPUs, coprocessors), in Intel compilers 14.0, future GCC 4.9. Questions? Write the guillimin support team at guillimin@calculquebec.ca 47
Advanced. By: Bart Oldeman, Calcul Québec McGill HPC
1 Advanced http://tinyurl.com/cq-adv-openmp-20160428 By: Bart Oldeman, Calcul Québec McGill HPC Bart.Oldeman@calculquebec.ca, Bart.Oldeman@mcgill.ca Partners and Sponsors 2 Outline of the workshop Theoretical
More informationPractical 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 informationLecture 4: OpenMP Open Multi-Processing
CS 4230: Parallel Programming Lecture 4: OpenMP Open Multi-Processing January 23, 2017 01/23/2017 CS4230 1 Outline OpenMP another approach for thread parallel programming Fork-Join execution model OpenMP
More informationEE/CSCI 451 Introduction to Parallel and Distributed Computation. Discussion #4 2/3/2017 University of Southern California
EE/CSCI 451 Introduction to Parallel and Distributed Computation Discussion #4 2/3/2017 University of Southern California 1 USC HPCC Access Compile Submit job OpenMP Today s topic What is OpenMP OpenMP
More informationAdvanced Message-Passing Interface (MPI)
Outline of the workshop 2 Advanced Message-Passing Interface (MPI) Bart Oldeman, Calcul Québec McGill HPC Bart.Oldeman@mcgill.ca Morning: Advanced MPI Revision More on Collectives More on Point-to-Point
More informationECE 574 Cluster Computing Lecture 10
ECE 574 Cluster Computing Lecture 10 Vince Weaver http://www.eece.maine.edu/~vweaver vincent.weaver@maine.edu 1 October 2015 Announcements Homework #4 will be posted eventually 1 HW#4 Notes How granular
More informationShared Memory programming paradigm: openmp
IPM School of Physics Workshop on High Performance Computing - HPC08 Shared Memory programming paradigm: openmp Luca Heltai Stefano Cozzini SISSA - Democritos/INFM
More informationOverview: The OpenMP Programming Model
Overview: The OpenMP Programming Model motivation and overview the parallel directive: clauses, equivalent pthread code, examples the for directive and scheduling of loop iterations Pi example in OpenMP
More informationModule 11: The lastprivate Clause Lecture 21: Clause and Routines. The Lecture Contains: The lastprivate Clause. Data Scope Attribute Clauses
The Lecture Contains: The lastprivate Clause Data Scope Attribute Clauses Reduction Loop Work-sharing Construct: Schedule Clause Environment Variables List of Variables References: file:///d /...ary,%20dr.%20sanjeev%20k%20aggrwal%20&%20dr.%20rajat%20moona/multi-core_architecture/lecture%2021/21_1.htm[6/14/2012
More informationShared memory programming model OpenMP TMA4280 Introduction to Supercomputing
Shared memory programming model OpenMP TMA4280 Introduction to Supercomputing NTNU, IMF February 16. 2018 1 Recap: Distributed memory programming model Parallelism with MPI. An MPI execution is started
More informationModule 10: Open Multi-Processing Lecture 19: What is Parallelization? The Lecture Contains: What is Parallelization? Perfectly Load-Balanced Program
The Lecture Contains: What is Parallelization? Perfectly Load-Balanced Program Amdahl's Law About Data What is Data Race? Overview to OpenMP Components of OpenMP OpenMP Programming Model OpenMP Directives
More informationOpenMP. António Abreu. Instituto Politécnico de Setúbal. 1 de Março de 2013
OpenMP António Abreu Instituto Politécnico de Setúbal 1 de Março de 2013 António Abreu (Instituto Politécnico de Setúbal) OpenMP 1 de Março de 2013 1 / 37 openmp what? It s an Application Program Interface
More informationIntroduction to OpenMP
Introduction to OpenMP Ricardo Fonseca https://sites.google.com/view/rafonseca2017/ Outline Shared Memory Programming OpenMP Fork-Join Model Compiler Directives / Run time library routines Compiling and
More informationPractical Introduction to
1 2 Outline of the workshop Practical Introduction to What is ScaleMP? When do we need it? How do we run codes on the ScaleMP node on the ScaleMP Guillimin cluster? How to run programs efficiently on ScaleMP?
More informationOur new HPC-Cluster An overview
Our new HPC-Cluster An overview Christian Hagen Universität Regensburg Regensburg, 15.05.2009 Outline 1 Layout 2 Hardware 3 Software 4 Getting an account 5 Compiling 6 Queueing system 7 Parallelization
More informationShared Memory Programming Model
Shared Memory Programming Model Ahmed El-Mahdy and Waleed Lotfy What is a shared memory system? Activity! Consider the board as a shared memory Consider a sheet of paper in front of you as a local cache
More informationOpenMP Algoritmi e Calcolo Parallelo. Daniele Loiacono
OpenMP Algoritmi e Calcolo Parallelo References Useful references Using OpenMP: Portable Shared Memory Parallel Programming, Barbara Chapman, Gabriele Jost and Ruud van der Pas OpenMP.org http://openmp.org/
More informationOpenMP 2. CSCI 4850/5850 High-Performance Computing Spring 2018
OpenMP 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 informationTopics. Introduction. Shared Memory Parallelization. Example. Lecture 11. OpenMP Execution Model Fork-Join model 5/15/2012. Introduction OpenMP
Topics Lecture 11 Introduction OpenMP Some Examples Library functions Environment variables 1 2 Introduction Shared Memory Parallelization OpenMP is: a standard for parallel programming in C, C++, and
More informationOpenMP Programming. Prof. Thomas Sterling. High Performance Computing: Concepts, Methods & Means
High Performance Computing: Concepts, Methods & Means OpenMP Programming Prof. Thomas Sterling Department of Computer Science Louisiana State University February 8 th, 2007 Topics Introduction Overview
More informationIntroduction to OpenMP
Introduction to OpenMP Ekpe Okorafor School of Parallel Programming & Parallel Architecture for HPC ICTP October, 2014 A little about me! PhD Computer Engineering Texas A&M University Computer Science
More informationOpenMP I. Diego Fabregat-Traver and Prof. Paolo Bientinesi WS16/17. HPAC, RWTH Aachen
OpenMP I Diego Fabregat-Traver and Prof. Paolo Bientinesi HPAC, RWTH Aachen fabregat@aices.rwth-aachen.de WS16/17 OpenMP References Using OpenMP: Portable Shared Memory Parallel Programming. The MIT Press,
More informationOpenMP examples. Sergeev Efim. Singularis Lab, Ltd. Senior software engineer
OpenMP examples Sergeev Efim Senior software engineer Singularis Lab, Ltd. OpenMP Is: An Application Program Interface (API) that may be used to explicitly direct multi-threaded, shared memory parallelism.
More informationCOMP4510 Introduction to Parallel Computation. Shared Memory and OpenMP. Outline (cont d) Shared Memory and OpenMP
COMP4510 Introduction to Parallel Computation Shared Memory and OpenMP Thanks to Jon Aronsson (UofM HPC consultant) for some of the material in these notes. Outline (cont d) Shared Memory and OpenMP Including
More informationOpenMP - II. Diego Fabregat-Traver and Prof. Paolo Bientinesi WS15/16. HPAC, RWTH Aachen
OpenMP - II Diego Fabregat-Traver and Prof. Paolo Bientinesi HPAC, RWTH Aachen fabregat@aices.rwth-aachen.de WS15/16 OpenMP References Using OpenMP: Portable Shared Memory Parallel Programming. The MIT
More informationParallelising Scientific Codes Using OpenMP. Wadud Miah Research Computing Group
Parallelising Scientific Codes Using OpenMP Wadud Miah Research Computing Group Software Performance Lifecycle Scientific Programming Early scientific codes were mainly sequential and were executed on
More informationOpenMP, Part 2. EAS 520 High Performance Scientific Computing. University of Massachusetts Dartmouth. Spring 2015
OpenMP, Part 2 EAS 520 High Performance Scientific Computing University of Massachusetts Dartmouth Spring 2015 References This presentation is almost an exact copy of Dartmouth College's openmp tutorial.
More informationShared Memory Parallelism - OpenMP
Shared Memory Parallelism - OpenMP Sathish Vadhiyar Credits/Sources: OpenMP C/C++ standard (openmp.org) OpenMP tutorial (http://www.llnl.gov/computing/tutorials/openmp/#introduction) OpenMP sc99 tutorial
More informationAssignment 1 OpenMP Tutorial Assignment
Assignment 1 OpenMP Tutorial Assignment B. Wilkinson and C Ferner: Modification date Aug 5, 2014 Overview In this assignment, you will write and execute run some simple OpenMP programs as a tutorial. First
More informationCS691/SC791: Parallel & Distributed Computing
CS691/SC791: Parallel & Distributed Computing Introduction to OpenMP 1 Contents Introduction OpenMP Programming Model and Examples OpenMP programming examples Task parallelism. Explicit thread synchronization.
More informationCS 470 Spring Mike Lam, Professor. OpenMP
CS 470 Spring 2018 Mike Lam, Professor OpenMP OpenMP Programming language extension Compiler support required "Open Multi-Processing" (open standard; latest version is 4.5) Automatic thread-level parallelism
More informationIntroduction to OpenMP
Introduction to OpenMP Le Yan Scientific computing consultant User services group High Performance Computing @ LSU Goals Acquaint users with the concept of shared memory parallelism Acquaint users with
More informationCS 470 Spring Mike Lam, Professor. OpenMP
CS 470 Spring 2017 Mike Lam, Professor OpenMP OpenMP Programming language extension Compiler support required "Open Multi-Processing" (open standard; latest version is 4.5) Automatic thread-level parallelism
More informationEPL372 Lab Exercise 5: Introduction to OpenMP
EPL372 Lab Exercise 5: Introduction to OpenMP References: https://computing.llnl.gov/tutorials/openmp/ http://openmp.org/wp/openmp-specifications/ http://openmp.org/mp-documents/openmp-4.0-c.pdf http://openmp.org/mp-documents/openmp4.0.0.examples.pdf
More informationIntroduction to OpenMP
Introduction to OpenMP Xiaoxu Guan High Performance Computing, LSU April 6, 2016 LSU HPC Training Series, Spring 2016 p. 1/44 Overview Overview of Parallel Computing LSU HPC Training Series, Spring 2016
More informationIntroduction to OpenMP
Christian Terboven, Dirk Schmidl IT Center, RWTH Aachen University Member of the HPC Group terboven,schmidl@itc.rwth-aachen.de IT Center der RWTH Aachen University History De-facto standard for Shared-Memory
More informationParallel Programming with OpenMP. CS240A, T. Yang
Parallel Programming with OpenMP CS240A, T. Yang 1 A Programmer s View of OpenMP What is OpenMP? Open specification for Multi-Processing Standard API for defining multi-threaded shared-memory programs
More informationOpenMP 4. CSCI 4850/5850 High-Performance Computing Spring 2018
OpenMP 4 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 informationMPI and OpenMP (Lecture 25, cs262a) Ion Stoica, UC Berkeley November 19, 2016
MPI and OpenMP (Lecture 25, cs262a) Ion Stoica, UC Berkeley November 19, 2016 Message passing vs. Shared memory Client Client Client Client send(msg) recv(msg) send(msg) recv(msg) MSG MSG MSG IPC Shared
More informationOpenMP Shared Memory Programming
OpenMP Shared Memory Programming John Burkardt, Information Technology Department, Virginia Tech.... Mathematics Department, Ajou University, Suwon, Korea, 13 May 2009.... http://people.sc.fsu.edu/ jburkardt/presentations/
More informationShared Memory Parallelism using OpenMP
Indian Institute of Science Bangalore, India भ रत य व ज ञ न स स थ न ब गल र, भ रत SE 292: High Performance Computing [3:0][Aug:2014] Shared Memory Parallelism using OpenMP Yogesh Simmhan Adapted from: o
More informationParallel Programming
Parallel Programming OpenMP Dr. Hyrum D. Carroll November 22, 2016 Parallel Programming in a Nutshell Load balancing vs Communication This is the eternal problem in parallel computing. The basic approaches
More informationOpen Multi-Processing: Basic Course
HPC2N, UmeåUniversity, 901 87, Sweden. May 26, 2015 Table of contents Overview of Paralellism 1 Overview of Paralellism Parallelism Importance Partitioning Data Distributed Memory Working on Abisko 2 Pragmas/Sentinels
More informationMultithreading in C with OpenMP
Multithreading in C with OpenMP ICS432 - Spring 2017 Concurrent and High-Performance Programming Henri Casanova (henric@hawaii.edu) Pthreads are good and bad! Multi-threaded programming in C with Pthreads
More informationParallel Programming: OpenMP
Parallel Programming: OpenMP Xianyi Zeng xzeng@utep.edu Department of Mathematical Sciences The University of Texas at El Paso. November 10, 2016. An Overview of OpenMP OpenMP: Open Multi-Processing An
More informationOpenMP threading: parallel regions. Paolo Burgio
OpenMP threading: parallel regions Paolo Burgio paolo.burgio@unimore.it Outline Expressing parallelism Understanding parallel threads Memory Data management Data clauses Synchronization Barriers, locks,
More informationHPC Practical Course Part 3.1 Open Multi-Processing (OpenMP)
HPC Practical Course Part 3.1 Open Multi-Processing (OpenMP) V. Akishina, I. Kisel, G. Kozlov, I. Kulakov, M. Pugach, M. Zyzak Goethe University of Frankfurt am Main 2015 Task Parallelism Parallelization
More informationOpenMP - Introduction
OpenMP - Introduction Süha TUNA Bilişim Enstitüsü UHeM Yaz Çalıştayı - 21.06.2012 Outline What is OpenMP? Introduction (Code Structure, Directives, Threads etc.) Limitations Data Scope Clauses Shared,
More informationOpenMP Overview. in 30 Minutes. Christian Terboven / Aachen, Germany Stand: Version 2.
OpenMP Overview in 30 Minutes Christian Terboven 06.12.2010 / Aachen, Germany Stand: 03.12.2010 Version 2.3 Rechen- und Kommunikationszentrum (RZ) Agenda OpenMP: Parallel Regions,
More informationSession 4: Parallel Programming with OpenMP
Session 4: Parallel Programming with OpenMP Xavier Martorell Barcelona Supercomputing Center Agenda Agenda 10:00-11:00 OpenMP fundamentals, parallel regions 11:00-11:30 Worksharing constructs 11:30-12:00
More informationParallel Programming Libraries and implementations
Parallel Programming Libraries and implementations Partners Funding Reusing this material This work is licensed under a Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International License.
More informationOpenMP programming. Thomas Hauser Director Research Computing Research CU-Boulder
OpenMP programming Thomas Hauser Director Research Computing thomas.hauser@colorado.edu CU meetup 1 Outline OpenMP Shared-memory model Parallel for loops Declaring private variables Critical sections Reductions
More informationCMSC 714 Lecture 4 OpenMP and UPC. Chau-Wen Tseng (from A. Sussman)
CMSC 714 Lecture 4 OpenMP and UPC Chau-Wen Tseng (from A. Sussman) Programming Model Overview Message passing (MPI, PVM) Separate address spaces Explicit messages to access shared data Send / receive (MPI
More informationcp r /global/scratch/workshop/openmp-wg-oct2017 cd openmp-wg-oct2017 && ls Current directory
$ ssh username@grex.westgrid.ca username@tatanka ~ username@bison ~ cp r /global/scratch/workshop/openmp-wg-oct2017 cd openmp-wg-oct2017 && ls Current directory sh get_node_workshop.sh [ username@n139
More informationOpenMP on Ranger and Stampede (with Labs)
OpenMP on Ranger and Stampede (with Labs) Steve Lantz Senior Research Associate Cornell CAC Parallel Computing at TACC: Ranger to Stampede Transition November 6, 2012 Based on materials developed by Kent
More informationHPC Workshop University of Kentucky May 9, 2007 May 10, 2007
HPC Workshop University of Kentucky May 9, 2007 May 10, 2007 Part 3 Parallel Programming Parallel Programming Concepts Amdahl s Law Parallel Programming Models Tools Compiler (Intel) Math Libraries (Intel)
More informationIntroduction to HPC and Optimization Tutorial VI
Felix Eckhofer Institut für numerische Mathematik und Optimierung Introduction to HPC and Optimization Tutorial VI January 8, 2013 TU Bergakademie Freiberg Going parallel HPC cluster in Freiberg 144 nodes,
More informationINTRODUCTION TO OPENMP (PART II)
INTRODUCTION TO OPENMP (PART II) Hossein Pourreza hossein.pourreza@umanitoba.ca March 9, 2016 Acknowledgement: Some of examples used in this presentation are courtesy of SciNet. 2 Logistics of this webinar
More informationShared Memory Programming with OpenMP
Shared Memory Programming with OpenMP (An UHeM Training) Süha Tuna Informatics Institute, Istanbul Technical University February 12th, 2016 2 Outline - I Shared Memory Systems Threaded Programming Model
More informationParallel Programming. Libraries and Implementations
Parallel Programming Libraries and Implementations 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 informationOpenMP. Application Program Interface. CINECA, 14 May 2012 OpenMP Marco Comparato
OpenMP Application Program Interface Introduction Shared-memory parallelism in C, C++ and Fortran compiler directives library routines environment variables Directives single program multiple data (SPMD)
More informationAllows program to be incrementally parallelized
Basic OpenMP What is OpenMP An open standard for shared memory programming in C/C+ + and Fortran supported by Intel, Gnu, Microsoft, Apple, IBM, HP and others Compiler directives and library support OpenMP
More informationBarbara Chapman, Gabriele Jost, Ruud van der Pas
Using OpenMP Portable Shared Memory Parallel Programming Barbara Chapman, Gabriele Jost, Ruud van der Pas The MIT Press Cambridge, Massachusetts London, England c 2008 Massachusetts Institute of Technology
More informationA brief introduction to OpenMP
A brief introduction to OpenMP Alejandro Duran Barcelona Supercomputing Center Outline 1 Introduction 2 Writing OpenMP programs 3 Data-sharing attributes 4 Synchronization 5 Worksharings 6 Task parallelism
More informationParallel Programming
Parallel Programming OpenMP Nils Moschüring PhD Student (LMU) Nils Moschüring PhD Student (LMU), OpenMP 1 1 Overview What is parallel software development Why do we need parallel computation? Problems
More informationParallel Programming in C with MPI and OpenMP
Parallel Programming in C with MPI and OpenMP Michael J. Quinn Chapter 17 Shared-memory Programming 1 Outline n OpenMP n Shared-memory model n Parallel for loops n Declaring private variables n Critical
More informationParallel Programming in C with MPI and OpenMP
Parallel Programming in C with MPI and OpenMP Michael J. Quinn Chapter 17 Shared-memory Programming 1 Outline n OpenMP n Shared-memory model n Parallel for loops n Declaring private variables n Critical
More informationParallel Programming using OpenMP
1 Parallel Programming using OpenMP Mike Bailey mjb@cs.oregonstate.edu openmp.pptx OpenMP Multithreaded Programming 2 OpenMP stands for Open Multi-Processing OpenMP is a multi-vendor (see next page) standard
More informationParallel Programming using OpenMP
1 OpenMP Multithreaded Programming 2 Parallel Programming using OpenMP OpenMP stands for Open Multi-Processing OpenMP is a multi-vendor (see next page) standard to perform shared-memory multithreading
More informationShared Memory Programming Paradigm!
Shared Memory Programming Paradigm! Ivan Girotto igirotto@ictp.it Information & Communication Technology Section (ICTS) International Centre for Theoretical Physics (ICTP) 1 Multi-CPUs & Multi-cores NUMA
More informationHigh Performance Computing: Tools and Applications
High Performance Computing: Tools and Applications Edmond Chow School of Computational Science and Engineering Georgia Institute of Technology Lecture 2 OpenMP Shared address space programming High-level
More informationIntroduction to OpenMP.
Introduction to OpenMP www.openmp.org Motivation Parallelize the following code using threads: for (i=0; i
More informationCOMP Parallel Computing. SMM (2) OpenMP Programming Model
COMP 633 - Parallel Computing Lecture 7 September 12, 2017 SMM (2) OpenMP Programming Model Reading for next time look through sections 7-9 of the Open MP tutorial Topics OpenMP shared-memory parallel
More informationGCC Developers Summit Ottawa, Canada, June 2006
OpenMP Implementation in GCC Diego Novillo dnovillo@redhat.com Red Hat Canada GCC Developers Summit Ottawa, Canada, June 2006 OpenMP Language extensions for shared memory concurrency (C, C++ and Fortran)
More informationIntroduction to OpenMP. OpenMP basics OpenMP directives, clauses, and library routines
Introduction to OpenMP Introduction OpenMP basics OpenMP directives, clauses, and library routines What is OpenMP? What does OpenMP stands for? What does OpenMP stands for? Open specifications for Multi
More informationIntroduction to Standard OpenMP 3.1
Introduction to Standard OpenMP 3.1 Massimiliano Culpo - m.culpo@cineca.it Gian Franco Marras - g.marras@cineca.it CINECA - SuperComputing Applications and Innovation Department 1 / 59 Outline 1 Introduction
More informationAdvanced C Programming Winter Term 2008/09. Guest Lecture by Markus Thiele
Advanced C Programming Winter Term 2008/09 Guest Lecture by Markus Thiele Lecture 14: Parallel Programming with OpenMP Motivation: Why parallelize? The free lunch is over. Herb
More informationOpenMP Exercises. These exercises will introduce you to using OpenMP for parallel programming. There are four exercises:
OpenMP Exercises These exercises will introduce you to using OpenMP for parallel programming. There are four exercises: 1. OMP Hello World 2. Worksharing Loop 3. OMP Functions 4. Hand-coding vs. MKL To
More information[Potentially] Your first parallel application
[Potentially] Your first parallel application Compute the smallest element in an array as fast as possible small = array[0]; for( i = 0; i < N; i++) if( array[i] < small ) ) small = array[i] 64-bit Intel
More informationParallel Processing Top manufacturer of multiprocessing video & imaging solutions.
1 of 10 3/3/2005 10:51 AM Linux Magazine March 2004 C++ Parallel Increase application performance without changing your source code. Parallel Processing Top manufacturer of multiprocessing video & imaging
More informationOpenMP 4.0/4.5: New Features and Protocols. Jemmy Hu
OpenMP 4.0/4.5: New Features and Protocols Jemmy Hu SHARCNET HPC Consultant University of Waterloo May 10, 2017 General Interest Seminar Outline OpenMP overview Task constructs in OpenMP SIMP constructs
More informationINTRODUCTION TO OPENMP
INTRODUCTION TO OPENMP Hossein Pourreza hossein.pourreza@umanitoba.ca February 25, 2016 Acknowledgement: Examples used in this presentation are courtesy of SciNet. What is High Performance Computing (HPC)
More informationDPHPC: Introduction to OpenMP Recitation session
SALVATORE DI GIROLAMO DPHPC: Introduction to OpenMP Recitation session Based on http://openmp.org/mp-documents/intro_to_openmp_mattson.pdf OpenMP An Introduction What is it? A set of compiler directives
More informationParallel Computing: Overview
Parallel Computing: Overview Jemmy Hu SHARCNET University of Waterloo March 1, 2007 Contents What is Parallel Computing? Why use Parallel Computing? Flynn's Classical Taxonomy Parallel Computer Memory
More informationDPHPC: Introduction to OpenMP Recitation session
SALVATORE DI GIROLAMO DPHPC: Introduction to OpenMP Recitation session Based on http://openmp.org/mp-documents/intro_to_openmp_mattson.pdf OpenMP An Introduction What is it? A set
More informationDistributed Systems + Middleware Concurrent Programming with OpenMP
Distributed Systems + Middleware Concurrent Programming with OpenMP Gianpaolo Cugola Dipartimento di Elettronica e Informazione Politecnico, Italy cugola@elet.polimi.it http://home.dei.polimi.it/cugola
More informationPOSIX Threads and OpenMP tasks
POSIX Threads and OpenMP tasks Jimmy Aguilar Mena February 16, 2018 Introduction Pthreads Tasks Two simple schemas Independent functions # include # include void f u n c t i
More informationParallel Programming. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Parallel Programming Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Challenges Difficult to write parallel programs Most programmers think sequentially
More informationIntroduction to OpenMP
Introduction to OpenMP Christian Terboven 10.04.2013 / Darmstadt, Germany Stand: 06.03.2013 Version 2.3 Rechen- und Kommunikationszentrum (RZ) History De-facto standard for
More informationOpenMP. OpenMP. Portable programming of shared memory systems. It is a quasi-standard. OpenMP-Forum API for Fortran and C/C++
OpenMP OpenMP Portable programming of shared memory systems. It is a quasi-standard. OpenMP-Forum 1997-2002 API for Fortran and C/C++ directives runtime routines environment variables www.openmp.org 1
More informationUsing OpenMP. Rebecca Hartman-Baker Oak Ridge National Laboratory
Using OpenMP Rebecca Hartman-Baker Oak Ridge National Laboratory hartmanbakrj@ornl.gov 2004-2009 Rebecca Hartman-Baker. Reproduction permitted for non-commercial, educational use only. Outline I. About
More informationIntroduction to OpenMP. Martin Čuma Center for High Performance Computing University of Utah
Introduction to OpenMP Martin Čuma Center for High Performance Computing University of Utah mcuma@chpc.utah.edu Overview Quick introduction. Parallel loops. Parallel loop directives. Parallel sections.
More informationOpenMP Introduction. CS 590: High Performance Computing. OpenMP. A standard for shared-memory parallel programming. MP = multiprocessing
CS 590: High Performance Computing OpenMP Introduction Fengguang Song Department of Computer Science IUPUI OpenMP A standard for shared-memory parallel programming. MP = multiprocessing Designed for systems
More informationShared Memory Programming With OpenMP Computer Lab Exercises
Shared Memory Programming With OpenMP Computer Lab Exercises Advanced Computational Science II John Burkardt Department of Scientific Computing Florida State University http://people.sc.fsu.edu/ jburkardt/presentations/fsu
More information1 of 6 Lecture 7: March 4. CISC 879 Software Support for Multicore Architectures Spring Lecture 7: March 4, 2008
1 of 6 Lecture 7: March 4 CISC 879 Software Support for Multicore Architectures Spring 2008 Lecture 7: March 4, 2008 Lecturer: Lori Pollock Scribe: Navreet Virk Open MP Programming Topics covered 1. Introduction
More informationOpenMP Programming. Aiichiro Nakano
OpenMP Programming Aiichiro Nakano Collaboratory for Advanced Computing & Simulations Department of Computer Science Department of Physics & Astronomy Department of Chemical Engineering & Materials Science
More informationIntroduction to OpenMP
Introduction to OpenMP Le Yan HPC Consultant User Services Goals Acquaint users with the concept of shared memory parallelism Acquaint users with the basics of programming with OpenMP Discuss briefly the
More informationOpenMP 4.5: Threading, vectorization & offloading
OpenMP 4.5: Threading, vectorization & offloading Michal Merta michal.merta@vsb.cz 2nd of March 2018 Agenda Introduction The Basics OpenMP Tasks Vectorization with OpenMP 4.x Offloading to Accelerators
More informationScientific Programming in C XIV. Parallel programming
Scientific Programming in C XIV. Parallel programming Susi Lehtola 11 December 2012 Introduction The development of microchips will soon reach the fundamental physical limits of operation quantum coherence
More informationA Short Introduction to OpenMP. Mark Bull, EPCC, University of Edinburgh
A Short Introduction to OpenMP Mark Bull, EPCC, University of Edinburgh Overview Shared memory systems Basic Concepts in Threaded Programming Basics of OpenMP Parallel regions Parallel loops 2 Shared memory
More information