An Introduction to OpenMP

Size: px
Start display at page:

Download "An Introduction to OpenMP"

Transcription

1 Dipartimento di Ingegneria Industriale e dell'informazione University of Pavia December 4, 2017

2 Recap Parallel machines are everywhere Many architectures, many programming model. Among them: multithreading. Multithreading is the natural programming model for multicore and SMP machines (desktop, server, embedded, cluster): All processors share the same memory Threads in a process see the same address space Multithreading is (correctly) perceived to be hard! Lots of expertise necessary, dependencies, granularity, balancing... Non-deterministic behavior makes it hard to debug

3 Outline 1 Introduction Motivation What is? 2 3 Complete Example Summary

4 Motivation What is? Outline 1 Introduction Motivation What is? 2 3 Complete Example Summary

5 Motivation What is? Ideal Parallel Programming Ideal Parallel Programming Paradigm 1 Start with any algorithm Embarrassing parallelism is helpful, but not necessary 2 Implement serially, ignoring: Data Races Threading Syntax 3 Test and Debug 4 Automatically (magically?) parallelize Expect linear speedup

6 Motivation What is? Threading Programming Paradigm Threading Programming Paradigm 1 Start with a parallel algorithm 2 Implement, keeping in mind: Data races Threading Syntax 3 Test & Debug 4 Debug 5 Debug

7 Motivation What is? Problem Parallelize the following code using threads: i n t main ( ) { f o r ( i n t i =0; i <16; i ++) p r i n t f ( " H e l l o, World! \ n" ) ; } A lot of work to do a simple thing Dierent threading APIs: Windows: CreateThread UNIX: pthread_create Problems with the code: Dierent code for serial and parallel version Is it possible to check for number of processors?

8 Motivation What is? Motivation - Threading Library v o i d S a y H e l l o ( v o i d f o o ) { p r i n t f ( " H e l l o, w o r l d! \ n" ) ; r e t u r n NULL ; } i n t main ( ) { pthread_attr_t a t t r ; pthread_t t h r e a d s [ 1 6 ] ; i n t tn ; p t h r e a d _ a t t r _ i n i t (& a t t r ) ; p t h r e a d _ a t t r _ s e t s c o p e (& a t t r, PTHREAD_SCOPE_SYSTEM) ; } f o r ( tn =0; tn <16; tn++) { p t h r e a d _ c r e a t e (& t h r e a d s [ tn ], &a t t r, SayHello, NULL) ; } f o r ( tn =0; tn <16 ; tn++) { p t h r e a d _ j o i n ( t h r e a d s [ tn ], NULL) ; } r e t u r n 0 ;

9 Motivation What is? Motivation - Threading Library II Thread libraries are hard to use PThreads has many library calls for initialization, synchronization, thread creation, condition variables, etc. Programmer must code with multiple threads in mind between threads introduces a new dimension of program correctness Wouldn't it be nice to write serial programs and somehow parallelize them automatically? can parallelize many serial programs with relatively few annotations that specify parallelism and independence is a small API that hides cumbersome threading calls with simpler directives

10 Motivation What is? Motivation - i n t main ( ) { // Do t h i s p a r t i n p a r a l l e l p r i n t f ( " H e l l o, World! \ n" ) ; } r e t u r n 0 ;

11 Motivation What is? Motivation - i n t main ( ) { omp_set_num_threads ( 1 6 ) ; // Do t h i s p a r t i n p a r a l l e l #pragma omp p a r a l l e l { p r i n t f ( " H e l l o, World! \ n" ) ; } } r e t u r n 0 ;

12 Motivation What is? Parallel Programming Programming Paradigm 1 Start with a parallelizable algorithm Embarrassing parallelism is good, loop-level parallelism is necessary 2 Implement serially, mostly ignoring: Data Races Threading Syntax 3 Test and Debug 4 Annotate the code with parallelization (and sync) directives Hope for linear speedup 5 Test and Debug

13 Motivation What is? Outline 1 Introduction Motivation What is? 2 3 Complete Example Summary

14 Motivation What is? What is? What is? Portable, threaded, shared-memory, standard programming specication with light syntax Talks, examples, forums, etc. Last release: 4.5 (November 2015) Requires compiler support (C or Fortran) Exact behavior depends on implementation! High-level API Preprocessor (compiler) directives ( ~ 80% ) Library Calls ( ~ 19% ) Environment Variables ( ~ 1% )

15 Motivation What is? A Programmer's View of will: Allow a programmer to separate a program into serial regions and parallel regions rather than T concurrent threads. Hide stack management Provide synchronization constructs will not: Parallelize (or detect!) dependencies Guarantee speedup Provide freedom from data races

16 Motivation What is? Methodology Parallelization with is an optimization process. Proceed with care: Start with a working program, then add parallelization Measure the changes after every step Remember Amdahl's law. Use the prolertools available

17 Outline Introduction 1 Introduction Motivation What is? 2 3 Complete Example Summary

18 Syntax Introduction Most of the constructs of are pragmas #pragma omp c o n s t r u c t [ c l a u s e [ c l a u s e ]... ] An construct applies to a structural block (open with {, close with }) In addition: Several omp_<something> function calls Several OMP_<something> environment variables

19 Controlling Behavior Function calls and similar environment variables omp_set_dynamic(int) omp_set_num_threads(int) omp_get_num_threads() omp_get_num_procs() omp_get_thread_num() omp_set_nested(int) omp_in_parallel() omp_get_wtime()

20 Programming Model Introduction Thread-like fork/join model Arbitrary number of logical thread creation/ destruction events Fork and join are implicit Serial regions by default, annotate to create parallel regions Using #pragmas Generic parallel regions, loops, sections

21 Thread Identication Introduction Master Thread Thread with ID=0 Only thread that exists in sequential regions Some special directives aect only the master thread (like master)

22 Nested Threading Introduction Fork/Join can be nested Nesting complication handled transparently at compile-time Independent of the number of threads actually running Avoid if possibile: possible performance problems

23 Data/Control Parallelism Data parallelism Threads perform similar functions, guided by thread identier Control parallelism Threads perform diering functions One thread for I/O, one for computation, etc...

24 Outline Introduction 1 Introduction Motivation What is? 2 3 Complete Example Summary

25 Parallel Regions I Introduction Main construct: #pragma omp parallel Denes a parallel region over structured block of code Threads are created as parallel pragma is crossed Threads block at end of region (implicit barrier)

26 Parallel Regions II Introduction double D[ ] ; #pragma omp p a r a l l e l { i n t i ; double sum = 0 ; f o r ( i =0; i <1000; i ++) sum += D[ i ] ; p r i n t f ( " Thread %d computes %f \n", omp_thread_num ( ), sum ) ; } Executes the same code as many times as there are threads How many threads do we have? omp_set_num_threads(n) What is the use of repeating the same work n times in parallel? Can use omp_thread_num() to distribute the work between threads. D is shared between the threads, i and sum are private

27 Implementing Work Sharing Sequential code f o r ( i n t i =0; i <N; i ++) { a [ i ]=b [ i ]+ c [ i ] ; } (Semi) manual parallelization #pragma omp p a r a l l e l { i n t i d = omp_get_thread_num ( ) ; i n t Nthr = omp_get_num_threads ( ) ; i n t i s t a r t = i d N/ Nthr ; i n t i e n d = ( i d +1) N/ Nthr ; f o r ( i n t i=i s t a r t ; i <i e n d ; i ++) { a [ i ]=b [ i ]+ c [ i ] ; } } Automatic parallelization #pragma omp p a r a l l e l f o r s c h e d u l e ( s t a t i c ) { f o r ( i n t i =0; i <N; i ++) { a [ i ]=b [ i ]+ c [ i ] ; } }

28 Work Sharing: For Introduction Used to assign each thread an independent set of iterations Threads must wait at the end Can combine the directives: #pragma omp parallel for Only simple kinds of for loops: Only one signed integer variable Initialization: var=init Comparison: var op last op: <, >, <=, >= Increment: var++, var--, var+=incr, var-=incr, etc.

29 Problems of #parallel for Load balancing If all the iterations execute at the same speed, the processors are used optimally If some iterations are faster than others, some processors may get idle, reducing the speedup We don't always know the distribution of work, may need to re-distribute dynamically Granularity Thread creation and synchronization takes time Assigning work to threads on per-iteration resolution may take more time than the execution itself! Need to coalesce the work to coarse chunks to overcome the threading overhead Trade-o between load balancing and granularity!

30 Controlling Granularity #pragma omp parallel if (expression) Can be used to disable parallelization in some cases (when the input is determined to be too small to be benecially multithreaded) #pragma omp num_threads (expression) Control the number of threads used in this parallel region

31 Schedule Clause: Controlling Work Distribution schedule(static [, chunksize]) Default: chunks of approximately equivalent size, one to each thread If more chunks than threads: assigned in round-robin to the threads Why might we want to use chunks of dierent size? schedule(dynamic [, chunksize]) Threads receive chunk assignments dynamically Default chunk size = 1 (why?) schedule(guided [, chunksize]) Start with large chunks Threads receive chunks dynamically Chunk size reduces exponentially, down to chunksize

32 Graphic Scheduling Introduction

33 Scheduling Example Introduction The function TestForPrime (usually) takes little time But can take long, if the number is a prime indeed #pragma omp p a r a l l e l f o r s c h e d u l e???? f o r ( i n t i = s t a r t ; i <= end ; i += 2 ) { i f ( TestForPrime ( i ) ) gprimesfound++; } Solution: use dynamic, but with chunks

34 Scheduling Example Introduction The function TestForPrime (usually) takes little time But can take long, if the number is a prime indeed #pragma omp p a r a l l e l f o r s c h e d u l e???? f o r ( i n t i = s t a r t ; i <= end ; i += 2 ) { i f ( TestForPrime ( i ) ) gprimesfound++; } Solution: use dynamic, but with chunks

35 Work Sharing: Sections answer1 = long_computation_1 ( ) ; answer2 = long_computation_2 ( ) ; i f ( answer1!= answer2 ) {... } How to parallelize? These are just two independent computations! #pragma omp s e c t i o n s { #pragma omp s e c t i o n answer1 = long_computation_1 ( ) ; #pragma omp s e c t i o n answer2 = long_computation_2 ( ) ; } i f ( answer1!= answer2 ) {... }

36 Outline Introduction 1 Introduction Motivation What is? 2 3 Complete Example Summary

37 Introduction Shared memory communication Threads cooperates by accessing shared variables Denition: Any variable that is seen by two or more threads is shared Any variable that is seen by one thread only is private Race conditions possible Use synchronization to protect from conicts Change how data is stored to minimize the synchronization

38 Data Visibility Introduction Shared Memory programming model Most variables (including locals) are shared by default { } i n t sum = 0 ; #pragma omp p a r a l l e l f o r f o r ( i n t i =0; i <N; i ++) sum += i ; Global variables are shared Some variables can be private Automatic variables inside the statement block Automatic variables in the called functions Variables can be explicitly declared as private. In that case, a local copy is created for each thread

39 Overriding Storage Attributes private: A copy of the variable is created for each thread. No connection between the original variable and the private copies Can achieve the same using variables inside { } i n t i ; #pragma omp p a r a l l e l f o r \ p r i v a t e ( i ) f o r ( i =0; i <n ; i ++) {... }

40 Overriding Storage Attributes II rstprivate: Same, but the initial value is copied from the main copy lastprivate: Same, but the last value is copied to the main copy i n t i d x =1; i n t x = 1 0 ; #pragma omp p a r a l l e l f o r \ f i r s p r i v a t e ( x ) \ l a s t p r i v a t e ( i d x ) f o r ( i =0; i <n ; i ++) { i f ( data [ i ]==x ) i d x = i ; }

41 Threadprivate Introduction Similar to private, but dened per variable Declaration immediately after variable denition. Must be visible in all translation units. Persistent between parallel sections Can be initialized from the master's copy with #pragma omp copyin More ecient than private, but a global variable! Example: i n t data [ ] ; #pragma omp t h r e a d p r i v a t e ( data )... #pragma omp p a r a l l e l f o r c o p y i n ( data ) f o r (... )

42 Outline Introduction 1 Introduction Motivation What is? 2 3 Complete Example Summary

43 Introduction X = 0 ; #pragma omp X = X+1; p a r a l l e l What should the result be (assuming 2 threads)? 2 is the expected answer But can be 1 with unfortunate interleaving assumes that the programmer knows what he is doing Regions of code that are marked to run in parallel are independent If access collisions are possible, it is the programmer's responsibility to insert protection

44 Mechanisms Many of the existing mechanisms for shared programming Nowait (turn synchronization o!) Single/Master execution Critical sections, Atomic updates Ordered Barriers Flush (memory subsystem synchronization) Reduction (special case)

45 Single/Master Introduction #pragma omp single Only one of the threads will execute the following block of code The rest will wait for it to complete Good for non-thread-safe regions of code (such as I/O) Must be used in a parallel region Applicable to parallel for sections

46 Single/Master II Introduction #pragma omp master The following block will be executed by the master thread No synchronization involved Applicable only to parallel sections #pragma omp p a r a l l e l { d o _ p r e p r o c e s s i n g ( ) ; #pragma omp s i n g l e read_input ( ) ; #pragma omp master notify_input_consumed ( ) ; } d o _ p r o c e s s i n g ( ) ;

47 Critical Sections Introduction #pragma omp critical [name] Standard critical section functionality Critical sections are global in the program Can be used to protect a single resource in dierent functions Critical sections are identied by the name All the unnamed critical sections are mutually exclusive throughout the program All the critical sections having the same name are mutually exclusive between themselves i n t x = 0 ; #pragma omp p a r a l l e l s h a r e d ( x ) { #pragma omp c r i t i c a l x++; }

48 Atomic Execution Introduction Critical sections on the cheap Protects a single variable update Can be much more ecient (a dedicated assembly instruction on some architectures) #pragma omp atomic update_statement Update statement is one of: var= var op expr, var op= expr, var++, var. The variable must be a scalar The operation op is one of: +, -, *, /, ^, &,, <<, >> The evaluation of expr is not atomic!

49 Ordered Introduction #pragma omp ordered statement Executes the statement in the sequential order of iterations Example: #pragma omp p a r a l l e l f o r f o r ( j =0; j <N; j ++) { i n t r e s u l t = heavy_computation ( j ) ; #pragma omp o r d e r e d p r i n t f ( " computation(%d ) = %d\n", j, r e s u l t ) ; }

50 Barrier synchronization #pragma omp barrier Performs a barrier synchronization between all the threads in a team at the given point. Example: #pragma omp p a r a l l e l { i n t r e s u l t = heavy_computation_part1 ( ) ; #pragma omp atomic sum += r e s u l t ; #pragma omp b a r r i e r heavy_computation_part2 ( sum ) ; }

51 Explicit Locking Introduction Can be used to pass lock variables around Can be used to implement more involved synchronization constructs Functions: omp_init_lock(), omp_destroy_lock(), omp_set_lock(), omp_unset_lock(), omp_test_lock() The usual semantics Use #pragma omp ush to synchronize memory Avoid it: very easy to screw up!

52 Reduction Introduction f o r ( j =0; j <N; j ++) { sum = sum+a [ j ] b [ j ] ; } How to parallelize this code? sum is not private, but accessing it atomically is too expensive Have a private copy of sum in each thread, then add them up Use the reduction clause! #pragma omp parallel for reduction(+: sum)any associative operator must be used: +, -,,, *, etc. The private value is initialized automatically (to 0, 1, ~0... )

53 Overhead Lost time waiting for locks Prefer to use structures that are as lock-free as possible! Use parallelization granularity which is as large as possible #pragma omp p a r a l l e l { #pragma omp c r i t i c a l {... }... }

54 Complete Example Summary Outline 1 Introduction Motivation What is? 2 3 Complete Example Summary

55 Complete Example Summary Numerical Integration Mathematically, we know that: (1 + x 2 ) dx = π We can approximate the integral as a sum of rectangles: N i=0 F (x i ) x π Where each rectangle has width x and height F (x i ) at the middle of interval i.

56 Complete Example Summary Serial Code s t a t i c long num_steps =100000; double step, p i ; v o i d main ( ) { i n t i ; double x, sum = 0. 0 ; } s t e p = 1. 0 / ( double ) num_steps ; f o r ( i =0; i < num_steps ; i ++){ x = ( i +0.5) s t e p ; sum = sum / ( x x ) ; } p i = s t e p sum ; p r i n t f ( " Pi = %f \n", p i ) ; Parallelize the numerical integration code using What variables can be shared? What variables need to be private? What variables should be set up for reductions?

57 Complete Example Summary Parallel Code s t a t i c long num_steps =100000; double step, p i ; v o i d main ( ) { i n t i ; double x, sum = 0. 0 ; s t e p = 1. 0 / ( double ) num_steps ; #pragma omp p a r a l l e l f o r \ p r i v a t e ( x ) r e d u c t i o n (+:sum ) } f o r ( i =0; i < num_steps ; i ++){ x = ( i +0.5) s t e p ; sum = sum / ( x x ) ; } p i = s t e p sum ; p r i n t f ( " Pi = %f \n", p i ) ; Parallelization code is a one-liner! sum is a reduction, hence shared, variable i is private since it is the loop variable

58 Complete Example Summary Outline 1 Introduction Motivation What is? 2 3 Complete Example Summary

59 Complete Example Summary Summary : A framework for code parallelization Available for C++ and FORTRAN Based on a standard Implementations from a wide selection of vendors Easy to use Write (and debug!) code rst, parallelize later Parallelization can be incremental Parallelization can be turned o at runtime or compile time Code is still correct for a serial machine

60 Complete Example Summary Limitations requires compiler support Sun, Intel, GCC... Embedded system? does not parallelize dependencies Often does not detect dependencies Nasty race conditions still exist! is not guaranteed to divide work optimally among threads Programmer-tweakable with scheduling clauses Still lots of rope available

61 Appendix For Further Reading For Further Reading I Clay Breshears The art of Concurrency O'Really, Blaise Barney Introduction to,

Introduction to OpenMP.

Introduction to OpenMP. Introduction to OpenMP www.openmp.org Motivation Parallelize the following code using threads: for (i=0; i

More information

Introduction to OpenMP. Motivation

Introduction to OpenMP.  Motivation Introduction to OpenMP www.openmp.org Motivation Parallel machines are abundant Servers are 2-8 way SMPs and more Upcoming processors are multicore parallel programming is beneficial and actually necessary

More information

Advanced C Programming Winter Term 2008/09. Guest Lecture by Markus Thiele

Advanced 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 information

Introduction to. Slides prepared by : Farzana Rahman 1

Introduction to. Slides prepared by : Farzana Rahman 1 Introduction to OpenMP Slides prepared by : Farzana Rahman 1 Definition of OpenMP Application Program Interface (API) for Shared Memory Parallel Programming Directive based approach with library support

More information

MPI 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 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 information

OpenMP C and C++ Application Program Interface Version 1.0 October Document Number

OpenMP C and C++ Application Program Interface Version 1.0 October Document Number OpenMP C and C++ Application Program Interface Version 1.0 October 1998 Document Number 004 2229 001 Contents Page v Introduction [1] 1 Scope............................. 1 Definition of Terms.........................

More information

Parallel Programming with OpenMP. CS240A, T. Yang

Parallel 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 information

Lecture 4: OpenMP Open Multi-Processing

Lecture 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 information

Parallel Computing Parallel Programming Languages Hwansoo Han

Parallel Computing Parallel Programming Languages Hwansoo Han Parallel Computing Parallel Programming Languages Hwansoo Han Parallel Programming Practice Current Start with a parallel algorithm Implement, keeping in mind Data races Synchronization Threading syntax

More information

Shared Memory Programming with OpenMP (3)

Shared Memory Programming with OpenMP (3) Shared Memory Programming with OpenMP (3) 2014 Spring Jinkyu Jeong (jinkyu@skku.edu) 1 SCHEDULING LOOPS 2 Scheduling Loops (2) parallel for directive Basic partitioning policy block partitioning Iteration

More information

Jukka Julku Multicore programming: Low-level libraries. Outline. Processes and threads TBB MPI UPC. Examples

Jukka Julku Multicore programming: Low-level libraries. Outline. Processes and threads TBB MPI UPC. Examples Multicore Jukka Julku 19.2.2009 1 2 3 4 5 6 Disclaimer There are several low-level, languages and directive based approaches But no silver bullets This presentation only covers some examples of them is

More information

Programming with Shared Memory PART II. HPC Fall 2012 Prof. Robert van Engelen

Programming with Shared Memory PART II. HPC Fall 2012 Prof. Robert van Engelen Programming with Shared Memory PART II HPC Fall 2012 Prof. Robert van Engelen Overview Sequential consistency Parallel programming constructs Dependence analysis OpenMP Autoparallelization Further reading

More information

OPENMP OPEN MULTI-PROCESSING

OPENMP OPEN MULTI-PROCESSING OPENMP OPEN MULTI-PROCESSING OpenMP OpenMP is a portable directive-based API that can be used with FORTRAN, C, and C++ for programming shared address space machines. OpenMP provides the programmer with

More information

Shared Memory Parallelism - OpenMP

Shared 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 information

Programming with Shared Memory PART II. HPC Fall 2007 Prof. Robert van Engelen

Programming with Shared Memory PART II. HPC Fall 2007 Prof. Robert van Engelen Programming with Shared Memory PART II HPC Fall 2007 Prof. Robert van Engelen Overview Parallel programming constructs Dependence analysis OpenMP Autoparallelization Further reading HPC Fall 2007 2 Parallel

More information

OpenMP - II. Diego Fabregat-Traver and Prof. Paolo Bientinesi WS15/16. HPAC, RWTH Aachen

OpenMP - 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 information

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

OpenMP 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 information

HPC Practical Course Part 3.1 Open Multi-Processing (OpenMP)

HPC 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 information

Parallel Programming. OpenMP Parallel programming for multiprocessors for loops

Parallel Programming. OpenMP Parallel programming for multiprocessors for loops Parallel Programming OpenMP Parallel programming for multiprocessors for loops OpenMP OpenMP An application programming interface (API) for parallel programming on multiprocessors Assumes shared memory

More information

Parallel Programming in C with MPI and OpenMP

Parallel 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 information

CMSC 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) 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 information

Parallel and Distributed Programming. OpenMP

Parallel and Distributed Programming. OpenMP Parallel and Distributed Programming OpenMP OpenMP Portability of software SPMD model Detailed versions (bindings) for different programming languages Components: directives for compiler library functions

More information

Shared memory programming model OpenMP TMA4280 Introduction to Supercomputing

Shared 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 information

Parallel Programming in C with MPI and OpenMP

Parallel 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 information

1 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 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 information

ECE 574 Cluster Computing Lecture 10

ECE 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 information

A brief introduction to OpenMP

A 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 information

Parallel Programming using OpenMP

Parallel 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 information

Session 4: Parallel Programming with OpenMP

Session 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 information

Multi-core Architecture and Programming

Multi-core Architecture and Programming Multi-core Architecture and Programming Yang Quansheng( 杨全胜 ) http://www.njyangqs.com School of Computer Science & Engineering 1 http://www.njyangqs.com Programming with OpenMP Content What is PpenMP Parallel

More information

Parallel Programming using OpenMP

Parallel 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 information

DPHPC: Introduction to OpenMP Recitation session

DPHPC: 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 information

OpenMP - III. Diego Fabregat-Traver and Prof. Paolo Bientinesi WS15/16. HPAC, RWTH Aachen

OpenMP - III. Diego Fabregat-Traver and Prof. Paolo Bientinesi WS15/16. HPAC, RWTH Aachen OpenMP - III 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 information

Parallel Programming in C with MPI and OpenMP

Parallel Programming in C with MPI and OpenMP Parallel Programming in C with MPI and OpenMP Michael J. Quinn Chapter 17 Shared-memory Programming Outline OpenMP Shared-memory model Parallel for loops Declaring private variables Critical sections Reductions

More information

COMP4300/8300: The OpenMP Programming Model. Alistair Rendell. Specifications maintained by OpenMP Architecture Review Board (ARB)

COMP4300/8300: The OpenMP Programming Model. Alistair Rendell. Specifications maintained by OpenMP Architecture Review Board (ARB) COMP4300/8300: The OpenMP Programming Model Alistair Rendell See: www.openmp.org Introduction to High Performance Computing for Scientists and Engineers, Hager and Wellein, Chapter 6 & 7 High Performance

More information

COMP4300/8300: The OpenMP Programming Model. Alistair Rendell

COMP4300/8300: The OpenMP Programming Model. Alistair Rendell COMP4300/8300: The OpenMP Programming Model Alistair Rendell See: www.openmp.org Introduction to High Performance Computing for Scientists and Engineers, Hager and Wellein, Chapter 6 & 7 High Performance

More information

DPHPC: Introduction to OpenMP Recitation session

DPHPC: 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 information

OpenMP Algoritmi e Calcolo Parallelo. Daniele Loiacono

OpenMP 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 information

OpenMP I. Diego Fabregat-Traver and Prof. Paolo Bientinesi WS16/17. HPAC, RWTH Aachen

OpenMP 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 information

Data Handling in OpenMP

Data Handling in OpenMP Data Handling in OpenMP Manipulate data by threads By private: a thread initializes and uses a variable alone Keep local copies, such as loop indices By firstprivate: a thread repeatedly reads a variable

More information

Parallel Programming. Exploring local computational resources OpenMP Parallel programming for multiprocessors for loops

Parallel Programming. Exploring local computational resources OpenMP Parallel programming for multiprocessors for loops Parallel Programming Exploring local computational resources OpenMP Parallel programming for multiprocessors for loops Single computers nowadays Several CPUs (cores) 4 to 8 cores on a single chip Hyper-threading

More information

Module 10: Open Multi-Processing Lecture 19: What is Parallelization? The Lecture Contains: What is Parallelization? Perfectly Load-Balanced Program

Module 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 information

Overview: The OpenMP Programming Model

Overview: 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 information

OpenMP Introduction. CS 590: High Performance Computing. OpenMP. A standard for shared-memory parallel programming. MP = multiprocessing

OpenMP 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 information

Allows program to be incrementally parallelized

Allows 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 information

Introduction to OpenMP. OpenMP basics OpenMP directives, clauses, and library routines

Introduction 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 information

Mango DSP Top manufacturer of multiprocessing video & imaging solutions.

Mango DSP Top manufacturer of multiprocessing video & imaging solutions. 1 of 11 3/3/2005 10:50 AM Linux Magazine February 2004 C++ Parallel Increase application performance without changing your source code. Mango DSP Top manufacturer of multiprocessing video & imaging solutions.

More information

Data Environment: Default storage attributes

Data Environment: Default storage attributes COSC 6374 Parallel Computation Introduction to OpenMP(II) Some slides based on material by Barbara Chapman (UH) and Tim Mattson (Intel) Edgar Gabriel Fall 2014 Data Environment: Default storage attributes

More information

Concurrent Programming with OpenMP

Concurrent Programming with OpenMP Concurrent Programming with OpenMP Parallel and Distributed Computing Department of Computer Science and Engineering (DEI) Instituto Superior Técnico March 7, 2016 CPD (DEI / IST) Parallel and Distributed

More information

Parallel Programming

Parallel 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 information

Parallel programming using OpenMP

Parallel programming using OpenMP Parallel programming using OpenMP Computer Architecture J. Daniel García Sánchez (coordinator) David Expósito Singh Francisco Javier García Blas ARCOS Group Computer Science and Engineering Department

More information

Introduction [1] 1. Directives [2] 7

Introduction [1] 1. Directives [2] 7 OpenMP Fortran Application Program Interface Version 2.0, November 2000 Contents Introduction [1] 1 Scope............................. 1 Glossary............................ 1 Execution Model.........................

More information

Parallel Programming with OpenMP. CS240A, T. Yang, 2013 Modified from Demmel/Yelick s and Mary Hall s Slides

Parallel Programming with OpenMP. CS240A, T. Yang, 2013 Modified from Demmel/Yelick s and Mary Hall s Slides Parallel Programming with OpenMP CS240A, T. Yang, 203 Modified from Demmel/Yelick s and Mary Hall s Slides Introduction to OpenMP What is OpenMP? Open specification for Multi-Processing Standard API for

More information

EPL372 Lab Exercise 5: Introduction to OpenMP

EPL372 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 information

CS691/SC791: Parallel & Distributed Computing

CS691/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 information

Distributed Systems + Middleware Concurrent Programming with OpenMP

Distributed 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 information

15-418, Spring 2008 OpenMP: A Short Introduction

15-418, Spring 2008 OpenMP: A Short Introduction 15-418, Spring 2008 OpenMP: A Short Introduction This is a short introduction to OpenMP, an API (Application Program Interface) that supports multithreaded, shared address space (aka shared memory) parallelism.

More information

Programming Shared Address Space Platforms using OpenMP

Programming Shared Address Space Platforms using OpenMP Programming Shared Address Space Platforms using OpenMP Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Topic Overview Introduction to OpenMP OpenMP

More information

CME 213 S PRING Eric Darve

CME 213 S PRING Eric Darve CME 213 S PRING 2017 Eric Darve PTHREADS pthread_create, pthread_exit, pthread_join Mutex: locked/unlocked; used to protect access to shared variables (read/write) Condition variables: used to allow threads

More information

Topics. Introduction. Shared Memory Parallelization. Example. Lecture 11. OpenMP Execution Model Fork-Join model 5/15/2012. Introduction OpenMP

Topics. 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 information

OpenMP Language Features

OpenMP Language Features OpenMP Language Features 1 Agenda The parallel construct Work-sharing Data-sharing Synchronization Interaction with the execution environment More OpenMP clauses Advanced OpenMP constructs 2 The fork/join

More information

EE/CSCI 451: Parallel and Distributed Computation

EE/CSCI 451: Parallel and Distributed Computation EE/CSCI 451: Parallel and Distributed Computation Lecture #7 2/5/2017 Xuehai Qian Xuehai.qian@usc.edu http://alchem.usc.edu/portal/xuehaiq.html University of Southern California 1 Outline From last class

More information

OpenMP. Diego Fabregat-Traver and Prof. Paolo Bientinesi WS16/17. HPAC, RWTH Aachen

OpenMP. Diego Fabregat-Traver and Prof. Paolo Bientinesi WS16/17. HPAC, RWTH Aachen OpenMP Diego Fabregat-Traver and Prof. Paolo Bientinesi HPAC, RWTH Aachen fabregat@aices.rwth-aachen.de WS16/17 Worksharing constructs To date: #pragma omp parallel created a team of threads We distributed

More information

OpenMP Application Program Interface

OpenMP Application Program Interface OpenMP Application Program Interface DRAFT Version.1.0-00a THIS IS A DRAFT AND NOT FOR PUBLICATION Copyright 1-0 OpenMP Architecture Review Board. Permission to copy without fee all or part of this material

More information

Shared Memory Parallelism using OpenMP

Shared 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 information

Shared Memory Programming with OpenMP

Shared 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 information

OpenMP. 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 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 information

OpenMP Overview. in 30 Minutes. Christian Terboven / Aachen, Germany Stand: Version 2.

OpenMP 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 information

Introduction to OpenMP

Introduction 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 information

Multithreading in C with OpenMP

Multithreading 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 information

OpenMP. 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 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 information

Shared Memory Programming Paradigm!

Shared 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 information

Shared memory parallel computing

Shared memory parallel computing Shared memory parallel computing OpenMP Sean Stijven Przemyslaw Klosiewicz Shared-mem. programming API for SMP machines Introduced in 1997 by the OpenMP Architecture Review Board! More high-level than

More information

Barbara Chapman, Gabriele Jost, Ruud van der Pas

Barbara 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 information

OpenMP. A parallel language standard that support both data and functional Parallelism on a shared memory system

OpenMP. A parallel language standard that support both data and functional Parallelism on a shared memory system OpenMP A parallel language standard that support both data and functional Parallelism on a shared memory system Use by system programmers more than application programmers Considered a low level primitives

More information

HPCSE - I. «OpenMP Programming Model - Part I» Panos Hadjidoukas

HPCSE - I. «OpenMP Programming Model - Part I» Panos Hadjidoukas HPCSE - I «OpenMP Programming Model - Part I» Panos Hadjidoukas 1 Schedule and Goals 13.10.2017: OpenMP - part 1 study the basic features of OpenMP able to understand and write OpenMP programs 20.10.2017:

More information

UvA-SARA High Performance Computing Course June Clemens Grelck, University of Amsterdam. Parallel Programming with Compiler Directives: OpenMP

UvA-SARA High Performance Computing Course June Clemens Grelck, University of Amsterdam. Parallel Programming with Compiler Directives: OpenMP Parallel Programming with Compiler Directives OpenMP Clemens Grelck University of Amsterdam UvA-SARA High Performance Computing Course June 2013 OpenMP at a Glance Loop Parallelization Scheduling Parallel

More information

CS 470 Spring Mike Lam, Professor. OpenMP

CS 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 information

Standard promoted by main manufacturers Fortran. Structure: Directives, clauses and run time calls

Standard promoted by main manufacturers   Fortran. Structure: Directives, clauses and run time calls OpenMP Introducción Directivas Regiones paralelas Worksharing sincronizaciones Visibilidad datos Implementación OpenMP: introduction Standard promoted by main manufacturers http://www.openmp.org, http://www.compunity.org

More information

Shared Memory Programming: Threads and OpenMP. Lecture 6

Shared Memory Programming: Threads and OpenMP. Lecture 6 Shared Memory Programming: Threads and OpenMP Lecture 6 James Demmel www.cs.berkeley.edu/~demmel/cs267_spr16/ CS267 Lecture 6 1 Outline Parallel Programming with Threads Parallel Programming with OpenMP

More information

Introduction 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 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 information

Standard promoted by main manufacturers Fortran

Standard promoted by main manufacturers  Fortran OpenMP Introducción Directivas Regiones paralelas Worksharing sincronizaciones Visibilidad datos Implementación OpenMP: introduction Standard promoted by main manufacturers http://www.openmp.org Fortran

More information

Programming with OpenMP*

Programming with OpenMP* Objectives At the completion of this module you will be able to Thread serial code with basic OpenMP pragmas Use OpenMP synchronization pragmas to coordinate thread execution and memory access 2 Agenda

More information

Parallel Computing. Prof. Marco Bertini

Parallel Computing. Prof. Marco Bertini Parallel Computing Prof. Marco Bertini Shared memory: OpenMP Implicit threads: motivations Implicit threading frameworks and libraries take care of much of the minutiae needed to create, manage, and (to

More information

OpenMP loops. Paolo Burgio.

OpenMP loops. Paolo Burgio. OpenMP loops Paolo Burgio paolo.burgio@unimore.it Outline Expressing parallelism Understanding parallel threads Memory Data management Data clauses Synchronization Barriers, locks, critical sections Work

More information

Parallel Programming/OpenMP

Parallel Programming/OpenMP Parallel Programming/OpenMP 1. Motivating Parallelism: Developing parallel software is considered time and effort intensive. This is largely because of inherent complexity in specifying and coordinating

More information

OpenMP Programming. Prof. Thomas Sterling. High Performance Computing: Concepts, Methods & Means

OpenMP 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 information

Introduction 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 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 information

An Introduction to OpenMP

An Introduction to OpenMP An Introduction to OpenMP U N C L A S S I F I E D Slide 1 What Is OpenMP? OpenMP Is: An Application Program Interface (API) that may be used to explicitly direct multi-threaded, shared memory parallelism

More information

CS 470 Spring Mike Lam, Professor. OpenMP

CS 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 information

Alfio Lazzaro: Introduction to OpenMP

Alfio Lazzaro: Introduction to OpenMP First INFN International School on Architectures, tools and methodologies for developing efficient large scale scientific computing applications Ce.U.B. Bertinoro Italy, 12 17 October 2009 Alfio Lazzaro:

More information

CS 470 Spring Mike Lam, Professor. Advanced OpenMP

CS 470 Spring Mike Lam, Professor. Advanced OpenMP CS 470 Spring 2018 Mike Lam, Professor Advanced OpenMP Atomics OpenMP provides access to highly-efficient hardware synchronization mechanisms Use the atomic pragma to annotate a single statement Statement

More information

OpenMP Fundamentals Fork-join model and data environment

OpenMP Fundamentals Fork-join model and data environment www.bsc.es OpenMP Fundamentals Fork-join model and data environment Xavier Teruel and Xavier Martorell Agenda: OpenMP Fundamentals OpenMP brief introduction The fork-join model Data environment OpenMP

More information

[Potentially] Your first parallel application

[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 information

OpenMP. Dr. William McDoniel and Prof. Paolo Bientinesi WS17/18. HPAC, RWTH Aachen

OpenMP. Dr. William McDoniel and Prof. Paolo Bientinesi WS17/18. HPAC, RWTH Aachen OpenMP Dr. William McDoniel and Prof. Paolo Bientinesi HPAC, RWTH Aachen mcdoniel@aices.rwth-aachen.de WS17/18 Loop construct - Clauses #pragma omp for [clause [, clause]...] The following clauses apply:

More information

OpenMP - Introduction

OpenMP - 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 information

OpenMP examples. Sergeev Efim. Singularis Lab, Ltd. Senior software engineer

OpenMP 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 information

OpenMP threading: parallel regions. Paolo Burgio

OpenMP 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 information

More Advanced OpenMP. Saturday, January 30, 16

More Advanced OpenMP. Saturday, January 30, 16 More Advanced OpenMP This is an abbreviated form of Tim Mattson s and Larry Meadow s (both at Intel) SC 08 tutorial located at http:// openmp.org/mp-documents/omp-hands-on-sc08.pdf All errors are my responsibility

More information

Shared memory programming

Shared memory programming CME342- Parallel Methods in Numerical Analysis Shared memory programming May 14, 2014 Lectures 13-14 Motivation Popularity of shared memory systems is increasing: Early on, DSM computers (SGI Origin 3000

More information