cs8803sc_lecture4

cs8803sc_lecture4 - CS8803SC Software and Hardware...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS8803SC Software and Hardware Cooperative Computing Introduction to OpenMP Prof. Hyesoon Kim School of Computer Science Georgia Institute of Technology Today’s Goal • Review OpenMP – OpenMP? – Directives and clauses – Work-sharing – Data sharing – Synchronization – Orphaned work-sharing – More directives and clauses – API
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 OpenMP Open standard for scientific parallel programming on symmetric multiprocessor (SMP) system Extensions for Fortran, C and c++ for portable SMP programming – Bases on threads, but – Higher-level than POSIX threads (Pthreads) Implemented by – Compiler Directives – Runtime Library (an API) – Environment Variables Embedded directives specify – Parallelism – Data sharing semantics – Work sharing semantics Compiler option required to detect code directives Increasingly popular OpenMP History • Primary OpenMP participates – Compaq, HP, IBM, Intel, KAI, SGI, SUN • U.S. Dept. of Energy ASCI Program • OpenMP Fortran API, Version 1.0, published Oct. 1997 • OpenMP C API, Version 1.0, published Oct. 1998 • OpenMP 2.0 API for Fortran, published in 2000 • OpenMP 2.0 API for C/C++, published in 2002 • OpenMP 2.5 API for C/C++ & F90 published in 2005 • OpenMP 3.0 draft version
Background image of page 2
3 Motivation: Why Should I Use OpenMP? www.sdsc.edu/~al ans/cs260/ Prof. Allan Snavely’s lecture slide Where Should I Use OpenMP? www.sdsc.edu/~al ans/cs260/ Prof. Allan Snavely’s lecture slide
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Programming Model • Compiler directives via pragmas (C, C++) or comments (Fortran) • Compiler replaces directives with calls to runtime library (libgomp (gcc)) • Runtime controls available via library API and environment variables • Environment variables control parallelism – OMP_NUM_THREADS - OMP_SCHEDULE – OMP_DYNAMIC - OMP_NESTED http://people.redhat.com/dnovil o/Papers/rhs2006.pdf Programming Model • Explicit sharing and synchronization • Threads interact via shared variables – Several ways for specifying shared data – Sharing always at the variable level • Programmer responsible for synchronization – Unintended sharing leads to “data races” – Use synchronization directives and library API – Synchronization is expensive http://people.redhat.com/dnovil o/Papers/rhs2006.pdf
Background image of page 4
5 OpenMP Architecture application user compiler directives environment variables runtime library Threads in operating system OpenMP Parallel Directive C/C++ directives begin with: # pragma omp #include<stdio.h> #include “omp.h” int main() { #pragma omp parallel { int ii; ii = omp_get_thread_num(); printf (“Atlanta is a great city! %d \n”, ii); } } Atlanta is a great city! 0 Atlanta is a great city! 3 Atlanta is a great city! 2 Atlanta is a great city! 6 Atlanta is a great city! 1 Atlanta is a great city! 4 Atlanta is a great city! 7 Atlanta is a great city! 8 The master thread
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Directives and Clauses • Directives are the main OpenMP construct • Clauses provide modifiers and attributes to
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

cs8803sc_lecture4 - CS8803SC Software and Hardware...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online