Openmp* in Action

Total Page:16

File Type:pdf, Size:1020Kb

Openmp* in Action SC’05 OpenMP Tutorial OpenMP* in Action Tim Mattson Barbara Chapman Intel Corporation University of Houston Acknowledgements: Rudi Eigenmann of Purdue, Sanjiv Shah of Intel and others too numerous to name have contributed content for this tutorial. 1 * The name “OpenMP” is the property of the OpenMP Architecture Review Board. Agenda • Parallel computing, threads, and OpenMP • The core elements of OpenMP – Thread creation – Workshare constructs – Managing the data environment – Synchronization – The runtime library and environment variables – Recapitulation • The OpenMP compiler • OpenMP usage: common design patterns • Case studies and examples • Background information and extra details 2 The OpenMP API for Multithreaded Programming 1 SC’05 OpenMP Tutorial OpenMP* Overview: C$OMP FLUSH #pragma omp critical C$OMP THREADPRIVATE(/ABC/) CALL OMP_SET_NUM_THREADS(10) OpenMP: An API for Writing Multithreaded C$OMP parallel do shared(a, b, c) call omp_test_lock(jlok) Applications call OMP_INIT_LOCK (ilok) C$OMP ATOMIC C$OMP MASTER C$OMP SINGLEA setPRIVATE(X) of compilersetenv directives OMP_SCHEDULE and library “dynamic” routines for parallel application programmers C$OMP PARALLEL DO ORDERED PRIVATE (A, B, C) C$OMP ORDERED Greatly simplifies writing multi-threaded (MT) C$OMP PARALLELprograms REDUCTION in Fortran, (+: A, C andB) C++ C$OMP SECTIONS #pragma ompStandardizes parallel for lastprivate(A, 20 years B) of !$OMPSMP practice BARRIER C$OMP PARALLEL COPYIN(/blk/) C$OMP DO lastprivate(XX) Nthrds = OMP_GET_NUM_PROCS() omp_set_lock(lck) 3 * The name “OpenMP” is the property of the OpenMP Architecture Review Board. What are Threads? • Thread: an independent flow of control – Runtime entity created to execute sequence of instructions • Threads require: – A program counter – A register state – An area in memory, including a call stack – A thread id • A process is executed by one or more threads that share: – Address space – Attributes such as UserID, open files, working directory, 4 etc. The OpenMP API for Multithreaded Programming 2 SC’05 OpenMP Tutorial A Shared Memory Architecture Shared memory cache1 cache2 cache3 cacheN proc1 proc2 proc3 procN 5 How Can We Exploit Threads? • A thread programming model must provide (at least) the means to: – Create and destroy threads – Distribute the computation among threads – Coordinate actions of threads on shared data – (usually) specify which data is shared and which is private to a thread 6 The OpenMP API for Multithreaded Programming 3 SC’05 OpenMP Tutorial How Does OpenMP Enable Us to Exploit Threads? • OpenMP provides thread programming model at a “high level”. – The user does not need to specify all the details • Especially with respect to the assignment of work to threads • Creation of threads • User makes strategic decisions • Compiler figures out details • Alternatives: –MPI – POSIX thread library is lower level – Automatic parallelization is even higher level (user does nothing) • But usually successful on simple codes only 7 Where Does OpenMP Run? Hardware OpenMP Platforms support CPU CPU CPU CPU Shared Memory Available Systems cache cache cache cache Distributed Shared Available Memory Systems (ccNUMA) Shared bus Distributed Memory Available Systems via Software Shared Memory DSM Machines with Chip Available Shared memory architecture MultiThreading 8 The OpenMP API for Multithreaded Programming 4 SC’05 OpenMP Tutorial OpenMP Overview: How do threads interact? • OpenMP is a shared memory model. • Threads communicate by sharing variables. • Unintended sharing of data causes race conditions: • race condition: when the program’s outcome changes as the threads are scheduled differently. • To control race conditions: • Use synchronization to protect data conflicts. • Synchronization is expensive so: • Change how data is accessed to minimize the need for synchronization. 9 Agenda • Parallel computing, threads, and OpenMP • The core elements of OpenMP – Thread creation – Workshare constructs – Managing the data environment – Synchronization – The runtime library and environment variables – Recapitulation • The OpenMP compiler • OpenMP usage: common design patterns • Case studies and examples • Background information and extra details 10 The OpenMP API for Multithreaded Programming 5 The OpenMP API forMultithreaded Programming Prog. Layer System layer User layer • arecompiler oftheconstructsinOpenMP Most • and the OpenMPlibmodule Include file (OpenMP API) OpenMP ParallelComputingSolutionStack Some syntaxdetailstogetusstarted directives. Directives, – For CandC++,thedirect – Fortran,thedirectives arecommentsandtake For Compiler SC’05 OpenMP Tutorial form: one oftheforms: #pragma omp use omp_lib #include <omp.h> •(but works fixedformtoo) for form Free • Fixed form OS/system supportforsharedmemory. OS/system !$OMP *$OMP C$OMP construct [clause[clause] construct [clause[clause] construct [clause[clause] construct [clause[clause]…] construct Application OpenMP: OpenMP library Runtime library End User ives arepragmas withthe … … … ] ] ] Environment variables 12 11 6 SC’05 OpenMP Tutorial OpenMP: Structured blocks (C/C++) • Most OpenMP* constructs apply to structured blocks. • Structured block: a block with one point of entry at the top and one point of exit at the bottom. • The only “branches” allowed are STOP statements in Fortran and exit() in C/C++. #pragma omp parallel if(go_now()) goto more; { #pragma omp parallel int id = omp_get_thread_num(); { more: res[id] = do_big_job(id); int id = omp_get_thread_num(); if(!conv(res[id]) goto more; more: res[id] = do_big_job(id); } if(conv(res[id]) goto done; printf(“ All done \n”); go to more; } done: if(!really_done()) goto more; 13 A structured block Not A structured block OpenMP: Structured blocks (Fortran) – Most OpenMP constructs apply to structured blocks. • Structured block: a block of code with one point of entry at the top and one point of exit at the bottom. • The only “branches” allowed are STOP statements in Fortran and exit() in C/C++. C$OMP PARALLEL C$OMP PARALLEL 10 wrk(id) = garbage(id) 10 wrk(id) = garbage(id) res(id) = wrk(id)**2 30 res(id)=wrk(id)**2 if(.not.conv(res(id)) goto 10 if(conv(res(id))goto 20 C$OMP END PARALLEL go to 10 print *,id C$OMP END PARALLEL if(not_DONE) goto 30 20 print *, id 14 A structured block Not A structured block The OpenMP API for Multithreaded Programming 7 SC’05 OpenMP Tutorial OpenMP: Structured Block Boundaries • In C/C++: a block is a single statement or a group of statements between brackets {} #pragma omp parallel #pragma omp for { for(I=0;I<N;I++){ id = omp_thread_num(); res[I] = big_calc(I); res(id) = lots_of_work(id); A[I] = B[I] + res[I]; } } • In Fortran: a block is a single statement or a group of statements between directive/end-directive pairs. C$OMP PARALLEL DO C$OMP PARALLEL do I=1,N 10 wrk(id) = garbage(id) res(I)=bigComp(I) res(id) = wrk(id)**2 end do if(.not.conv(res(id)) goto 10 C$OMP END PARALLEL DO 15 C$OMP END PARALLEL OpenMP Definitions: “Constructs” vs. “Regions” in OpenMP OpenMP constructs occupy a single compilation unit while a region can span multiple source files. poo.f bar.f call whoami C$OMP PARALLEL subroutine whoami call whoami + external omp_get_thread_num C$OMP END PARALLEL integer iam, omp_get_thread_num iam = omp_get_thread_num() C$OMP CRITICAL A Parallel The Parallel print*,’Hello from ‘, iam construct region is the C$OMP END CRITICAL Orphan constructs text of the return can execute outside a construct plus end parallel region any code called inside the 16 construct The OpenMP API for Multithreaded Programming 8 SC’05 OpenMP Tutorial Agenda • Parallel computing, threads, and OpenMP • The core elements of OpenMP – Thread creation – Workshare constructs – Managing the data environment – Synchronization – The runtime library and environment variables – Recapitulation • The OpenMP compiler • OpenMP usage: common design patterns • Case studies and examples • Background information and extra details 17 The OpenMP* API Parallel Regions • You create threads in OpenMP* with the “omp parallel” pragma. • For example, To create a 4 thread Parallel region: double A[1000]; Runtime function to Each thread omp_set_num_threads(4); request a certain executes a number of threads copy of the #pragma omp parallel code within { the int ID = omp_get_thread_num(); structured pooh(ID,A); Runtime function block } returning a thread ID z Each thread calls pooh(ID,A) for ID = 0 to 3 18 * The name “OpenMP” is the property of the OpenMP Architecture Review Board The OpenMP API for Multithreaded Programming 9 SC’05 OpenMP Tutorial The OpenMP* API Parallel Regions • You create threads in OpenMP* with the “omp parallel” pragma. • For example, To create a 4 thread Parallel region: clause to request a certain double A[1000]; number of threads Each thread executes a copy of the #pragma omp parallel num_threads(4) code within { the int ID = omp_get_thread_num(); structured pooh(ID,A); Runtime function block } returning a thread ID z Each thread calls pooh(ID,A) for ID = 0 to 3 19 * The name “OpenMP” is the property of the OpenMP Architecture Review Board The OpenMP* API Parallel Regions double A[1000]; • Each thread executes omp_set_num_threads(4); the same code #pragma omp parallel redundantly. { int ID = omp_get_thread_num(); double A[1000]; pooh(ID, A); } omp_set_num_threads(4) printf(“all done\n”); A single copy of A pooh(0,A) pooh(1,A) pooh(2,A) pooh(3,A) is shared between all threads. printf(“all done\n”); Threads wait here for all threads to finish before proceeding (i.e. a barrier20) * The
Recommended publications
  • Heterogeneous Task Scheduling for Accelerated Openmp
    Heterogeneous Task Scheduling for Accelerated OpenMP ? ? Thomas R. W. Scogland Barry Rountree† Wu-chun Feng Bronis R. de Supinski† ? Department of Computer Science, Virginia Tech, Blacksburg, VA 24060 USA † Center for Applied Scientific Computing, Lawrence Livermore National Laboratory, Livermore, CA 94551 USA [email protected] [email protected] [email protected] [email protected] Abstract—Heterogeneous systems with CPUs and computa- currently requires a programmer either to program in at tional accelerators such as GPUs, FPGAs or the upcoming least two different parallel programming models, or to use Intel MIC are becoming mainstream. In these systems, peak one of the two that support both GPUs and CPUs. Multiple performance includes the performance of not just the CPUs but also all available accelerators. In spite of this fact, the models however require code replication, and maintaining majority of programming models for heterogeneous computing two completely distinct implementations of a computational focus on only one of these. With the development of Accelerated kernel is a difficult and error-prone proposition. That leaves OpenMP for GPUs, both from PGI and Cray, we have a clear us with using either OpenCL or accelerated OpenMP to path to extend traditional OpenMP applications incrementally complete the task. to use GPUs. The extensions are geared toward switching from CPU parallelism to GPU parallelism. However they OpenCL’s greatest strength lies in its broad hardware do not preserve the former while adding the latter. Thus support. In a way, though, that is also its greatest weak- computational potential is wasted since either the CPU cores ness. To enable one to program this disparate hardware or the GPU cores are left idle.
    [Show full text]
  • Benchmarking the Intel FPGA SDK for Opencl Memory Interface
    The Memory Controller Wall: Benchmarking the Intel FPGA SDK for OpenCL Memory Interface Hamid Reza Zohouri*†1, Satoshi Matsuoka*‡ *Tokyo Institute of Technology, †Edgecortix Inc. Japan, ‡RIKEN Center for Computational Science (R-CCS) {zohour.h.aa@m, matsu@is}.titech.ac.jp Abstract—Supported by their high power efficiency and efficiency on Intel FPGAs with different configurations recent advancements in High Level Synthesis (HLS), FPGAs are for input/output arrays, vector size, interleaving, kernel quickly finding their way into HPC and cloud systems. Large programming model, on-chip channels, operating amounts of work have been done so far on loop and area frequency, padding, and multiple types of blocking. optimizations for different applications on FPGAs using HLS. However, a comprehensive analysis of the behavior and • We outline one performance bug in Intel’s compiler, and efficiency of the memory controller of FPGAs is missing in multiple deficiencies in the memory controller, leading literature, which becomes even more crucial when the limited to significant loss of memory performance for typical memory bandwidth of modern FPGAs compared to their GPU applications. In some of these cases, we provide work- counterparts is taken into account. In this work, we will analyze arounds to improve the memory performance. the memory interface generated by Intel FPGA SDK for OpenCL with different configurations for input/output arrays, II. METHODOLOGY vector size, interleaving, kernel programming model, on-chip channels, operating frequency, padding, and multiple types of A. Memory Benchmark Suite overlapped blocking. Our results point to multiple shortcomings For our evaluation, we develop an open-source benchmark in the memory controller of Intel FPGAs, especially with respect suite called FPGAMemBench, available at https://github.com/ to memory access alignment, that can hinder the programmer’s zohourih/FPGAMemBench.
    [Show full text]
  • Parallel Programming
    Parallel Programming Libraries and implementations Outline • MPI – distributed memory de-facto standard • Using MPI • OpenMP – shared memory de-facto standard • Using OpenMP • CUDA – GPGPU de-facto standard • Using CUDA • Others • Hybrid programming • Xeon Phi Programming • SHMEM • PGAS MPI Library Distributed, message-passing programming Message-passing concepts Explicit Parallelism • In message-passing all the parallelism is explicit • The program includes specific instructions for each communication • What to send or receive • When to send or receive • Synchronisation • It is up to the developer to design the parallel decomposition and implement it • How will you divide up the problem? • When will you need to communicate between processes? Message Passing Interface (MPI) • MPI is a portable library used for writing parallel programs using the message passing model • You can expect MPI to be available on any HPC platform you use • Based on a number of processes running independently in parallel • HPC resource provides a command to launch multiple processes simultaneously (e.g. mpiexec, aprun) • There are a number of different implementations but all should support the MPI 2 standard • As with different compilers, there will be variations between implementations but all the features specified in the standard should work. • Examples: MPICH2, OpenMPI Point-to-point communications • A message sent by one process and received by another • Both processes are actively involved in the communication – not necessarily at the same time • Wide variety of semantics provided: • Blocking vs. non-blocking • Ready vs. synchronous vs. buffered • Tags, communicators, wild-cards • Built-in and custom data-types • Can be used to implement any communication pattern • Collective operations, if applicable, can be more efficient Collective communications • A communication that involves all processes • “all” within a communicator, i.e.
    [Show full text]
  • Openmp API 5.1 Specification
    OpenMP Application Programming Interface Version 5.1 November 2020 Copyright c 1997-2020 OpenMP Architecture Review Board. Permission to copy without fee all or part of this material is granted, provided the OpenMP Architecture Review Board copyright notice and the title of this document appear. Notice is given that copying is by permission of the OpenMP Architecture Review Board. This page intentionally left blank in published version. Contents 1 Overview of the OpenMP API1 1.1 Scope . .1 1.2 Glossary . .2 1.2.1 Threading Concepts . .2 1.2.2 OpenMP Language Terminology . .2 1.2.3 Loop Terminology . .9 1.2.4 Synchronization Terminology . 10 1.2.5 Tasking Terminology . 12 1.2.6 Data Terminology . 14 1.2.7 Implementation Terminology . 18 1.2.8 Tool Terminology . 19 1.3 Execution Model . 22 1.4 Memory Model . 25 1.4.1 Structure of the OpenMP Memory Model . 25 1.4.2 Device Data Environments . 26 1.4.3 Memory Management . 27 1.4.4 The Flush Operation . 27 1.4.5 Flush Synchronization and Happens Before .................. 29 1.4.6 OpenMP Memory Consistency . 30 1.5 Tool Interfaces . 31 1.5.1 OMPT . 32 1.5.2 OMPD . 32 1.6 OpenMP Compliance . 33 1.7 Normative References . 33 1.8 Organization of this Document . 35 i 2 Directives 37 2.1 Directive Format . 38 2.1.1 Fixed Source Form Directives . 43 2.1.2 Free Source Form Directives . 44 2.1.3 Stand-Alone Directives . 45 2.1.4 Array Shaping . 45 2.1.5 Array Sections .
    [Show full text]
  • BCL: a Cross-Platform Distributed Data Structures Library
    BCL: A Cross-Platform Distributed Data Structures Library Benjamin Brock, Aydın Buluç, Katherine Yelick University of California, Berkeley Lawrence Berkeley National Laboratory {brock,abuluc,yelick}@cs.berkeley.edu ABSTRACT high-performance computing, including several using the Parti- One-sided communication is a useful paradigm for irregular paral- tioned Global Address Space (PGAS) model: Titanium, UPC, Coarray lel applications, but most one-sided programming environments, Fortran, X10, and Chapel [9, 11, 12, 25, 29, 30]. These languages are including MPI’s one-sided interface and PGAS programming lan- especially well-suited to problems that require asynchronous one- guages, lack application-level libraries to support these applica- sided communication, or communication that takes place without tions. We present the Berkeley Container Library, a set of generic, a matching receive operation or outside of a global collective. How- cross-platform, high-performance data structures for irregular ap- ever, PGAS languages lack the kind of high level libraries that exist plications, including queues, hash tables, Bloom filters and more. in other popular programming environments. For example, high- BCL is written in C++ using an internal DSL called the BCL Core performance scientific simulations written in MPI can leverage a that provides one-sided communication primitives such as remote broad set of numerical libraries for dense or sparse matrices, or get and remote put operations. The BCL Core has backends for for structured, unstructured, or adaptive meshes. PGAS languages MPI, OpenSHMEM, GASNet-EX, and UPC++, allowing BCL data can sometimes use those numerical libraries, but are missing the structures to be used natively in programs written using any of data structures that are important in some of the most irregular these programming environments.
    [Show full text]
  • Advances, Applications and Performance of The
    1 Introduction The two predominant classes of programming models for MIMD concurrent computing are distributed memory and ADVANCES, APPLICATIONS AND shared memory. Both shared memory and distributed mem- PERFORMANCE OF THE GLOBAL ory models have advantages and shortcomings. Shared ARRAYS SHARED MEMORY memory model is much easier to use but it ignores data PROGRAMMING TOOLKIT locality/placement. Given the hierarchical nature of the memory subsystems in modern computers this character- istic can have a negative impact on performance and scal- Jarek Nieplocha1 1 ability. Careful code restructuring to increase data reuse Bruce Palmer and replacing fine grain load/stores with block access to Vinod Tipparaju1 1 shared data can address the problem and yield perform- Manojkumar Krishnan ance for shared memory that is competitive with mes- Harold Trease1 2 sage-passing (Shan and Singh 2000). However, this Edoardo Aprà performance comes at the cost of compromising the ease of use that the shared memory model advertises. Distrib- uted memory models, such as message-passing or one- Abstract sided communication, offer performance and scalability This paper describes capabilities, evolution, performance, but they are difficult to program. and applications of the Global Arrays (GA) toolkit. GA was The Global Arrays toolkit (Nieplocha, Harrison, and created to provide application programmers with an inter- Littlefield 1994, 1996; Nieplocha et al. 2002a) attempts to face that allows them to distribute data while maintaining offer the best features of both models. It implements a the type of global index space and programming syntax shared-memory programming model in which data local- similar to that available when programming on a single ity is managed by the programmer.
    [Show full text]
  • Openmp Made Easy with INTEL® ADVISOR
    OpenMP made easy with INTEL® ADVISOR Zakhar Matveev, PhD, Intel CVCG, November 2018, SC’18 OpenMP booth Why do we care? Ai Bi Ai Bi Ai Bi Ai Bi Vector + Processing Ci Ci Ci Ci VL Motivation (instead of Agenda) • Starting from 4.x, OpenMP introduces support for both levels of parallelism: • Multi-Core (think of “pragma/directive omp parallel for”) • SIMD (think of “pragma/directive omp simd”) • 2 pillars of OpenMP SIMD programming model • Hardware with Intel ® AVX-512 support gives you theoretically 8x speed- up over SSE baseline (less or even more in practice) • Intel® Advisor is here to assist you in: • Enabling SIMD parallelism with OpenMP (if not yet) • Improving performance of already vectorized OpenMP SIMD code • And will also help to optimize for Memory Sub-system (Advisor Roofline) 3 Don’t use a single Vector lane! Un-vectorized and un-threaded software will under perform 4 Permission to Design for All Lanes Threading and Vectorization needed to fully utilize modern hardware 5 A Vector parallelism in x86 AVX-512VL AVX-512BW B AVX-512DQ AVX-512CD AVX-512F C AVX2 AVX2 AVX AVX AVX SSE SSE SSE SSE Intel® microarchitecture code name … NHM SNB HSW SKL 6 (theoretically) 8x more SIMD FLOP/S compared to your (–O2) optimized baseline x - Significant leap to 512-bit SIMD support for processors - Intel® Compilers and Intel® Math Kernel Library include AVX-512 support x - Strong compatibility with AVX - Added EVEX prefix enables additional x functionality Don’t leave it on the table! 7 Two level parallelism decomposition with OpenMP: image processing example B #pragma omp parallel for for (int y = 0; y < ImageHeight; ++y){ #pragma omp simd C for (int x = 0; x < ImageWidth; ++x){ count[y][x] = mandel(in_vals[y][x]); } } 8 Two level parallelism decomposition with OpenMP: fluid dynamics processing example B #pragma omp parallel for for (int i = 0; i < X_Dim; ++i){ #pragma omp simd C for (int m = 0; x < n_velocities; ++m){ next_i = f(i, velocities(m)); X[i] = next_i; } } 9 Key components of Intel® Advisor What’s new in “2019” release Step 1.
    [Show full text]
  • Introduction to Openmp Paul Edmon ITC Research Computing Associate
    Introduction to OpenMP Paul Edmon ITC Research Computing Associate FAS Research Computing Overview • Threaded Parallelism • OpenMP Basics • OpenMP Programming • Benchmarking FAS Research Computing Threaded Parallelism • Shared Memory • Single Node • Non-uniform Memory Access (NUMA) • One thread per core FAS Research Computing Threaded Languages • PThreads • Python • Perl • OpenCL/CUDA • OpenACC • OpenMP FAS Research Computing OpenMP Basics FAS Research Computing What is OpenMP? • OpenMP (Open Multi-Processing) – Application Program Interface (API) – Governed by OpenMP Architecture Review Board • OpenMP provides a portable, scalable model for developers of shared memory parallel applications • The API supports C/C++ and Fortran on a wide variety of architectures FAS Research Computing Goals of OpenMP • Standardization – Provide a standard among a variety shared memory architectures / platforms – Jointly defined and endorsed by a group of major computer hardware and software vendors • Lean and Mean – Establish a simple and limited set of directives for programming shared memory machines – Significant parallelism can be implemented by just a few directives • Ease of Use – Provide the capability to incrementally parallelize a serial program • Portability – Specified for C/C++ and Fortran – Most majors platforms have been implemented including Unix/Linux and Windows – Implemented for all major compilers FAS Research Computing OpenMP Programming Model Shared Memory Model: OpenMP is designed for multi-processor/core, shared memory machines Thread Based Parallelism: OpenMP programs accomplish parallelism exclusively through the use of threads Explicit Parallelism: OpenMP provides explicit (not automatic) parallelism, offering the programmer full control over parallelization Compiler Directive Based: Parallelism is specified through the use of compiler directives embedded in the C/C++ or Fortran code I/O: OpenMP specifies nothing about parallel I/O.
    [Show full text]
  • Enabling Efficient Use of UPC and Openshmem PGAS Models on GPU Clusters
    Enabling Efficient Use of UPC and OpenSHMEM PGAS Models on GPU Clusters Presented at GTC ’15 Presented by Dhabaleswar K. (DK) Panda The Ohio State University E-mail: [email protected] hCp://www.cse.ohio-state.edu/~panda Accelerator Era GTC ’15 • Accelerators are becominG common in hiGh-end system architectures Top 100 – Nov 2014 (28% use Accelerators) 57% use NVIDIA GPUs 57% 28% • IncreasinG number of workloads are beinG ported to take advantage of NVIDIA GPUs • As they scale to larGe GPU clusters with hiGh compute density – hiGher the synchronizaon and communicaon overheads – hiGher the penalty • CriPcal to minimize these overheads to achieve maximum performance 3 Parallel ProGramminG Models Overview GTC ’15 P1 P2 P3 P1 P2 P3 P1 P2 P3 LoGical shared memory Shared Memory Memory Memory Memory Memory Memory Memory Shared Memory Model Distributed Memory Model ParPPoned Global Address Space (PGAS) DSM MPI (Message PassinG Interface) Global Arrays, UPC, Chapel, X10, CAF, … • ProGramminG models provide abstract machine models • Models can be mapped on different types of systems - e.G. Distributed Shared Memory (DSM), MPI within a node, etc. • Each model has strenGths and drawbacks - suite different problems or applicaons 4 Outline GTC ’15 • Overview of PGAS models (UPC and OpenSHMEM) • Limitaons in PGAS models for GPU compuPnG • Proposed DesiGns and Alternaves • Performance Evaluaon • ExploiPnG GPUDirect RDMA 5 ParPPoned Global Address Space (PGAS) Models GTC ’15 • PGAS models, an aracPve alternave to tradiPonal message passinG - Simple
    [Show full text]
  • Automatic Handling of Global Variables for Multi-Threaded MPI Programs
    Automatic Handling of Global Variables for Multi-threaded MPI Programs Gengbin Zheng, Stas Negara, Celso L. Mendes, Laxmikant V. Kale´ Eduardo R. Rodrigues Department of Computer Science Institute of Informatics University of Illinois at Urbana-Champaign Federal University of Rio Grande do Sul Urbana, IL 61801, USA Porto Alegre, Brazil fgzheng,snegara2,cmendes,[email protected] [email protected] Abstract— necessary to privatize global and static variables to ensure Hybrid programming models, such as MPI combined with the thread-safety of an application. threads, are one of the most efficient ways to write parallel ap- In high-performance computing, one way to exploit multi- plications for current machines comprising multi-socket/multi- core nodes and an interconnection network. Global variables in core platforms is to adopt hybrid programming models that legacy MPI applications, however, present a challenge because combine MPI with threads, where different programming they may be accessed by multiple MPI threads simultaneously. models are used to address issues such as multiple threads Thus, transforming legacy MPI applications to be thread-safe per core, decreasing amount of memory per core, load in order to exploit multi-core architectures requires proper imbalance, etc. When porting legacy MPI applications to handling of global variables. In this paper, we present three approaches to eliminate these hybrid models that involve multiple threads, thread- global variables to ensure thread-safety for an MPI program. safety of the applications needs to be addressed again. These approaches include: (a) a compiler-based refactoring Global variables cause no problem with traditional MPI technique, using a Photran-based tool as an example, which implementations, since each process image contains a sep- automates the source-to-source transformation for programs arate instance of the variable.
    [Show full text]
  • Parallel Programming with Openmp
    Parallel Programming with OpenMP OpenMP Parallel Programming Introduction: OpenMP Programming Model Thread-based parallelism utilized on shared-memory platforms Parallelization is either explicit, where programmer has full control over parallelization or through using compiler directives, existing in the source code. Thread is a process of a code is being executed. A thread of execution is the smallest unit of processing. Multiple threads can exist within the same process and share resources such as memory OpenMP Parallel Programming Introduction: OpenMP Programming Model Master thread is a single thread that runs sequentially; parallel execution occurs inside parallel regions and between two parallel regions, only the master thread executes the code. This is called the fork-join model: OpenMP Parallel Programming OpenMP Parallel Computing Hardware Shared memory allows immediate access to all data from all processors without explicit communication. Shared memory: multiple cpus are attached to the BUS all processors share the same primary memory the same memory address on different CPU's refer to the same memory location CPU-to-memory connection becomes a bottleneck: shared memory computers cannot scale very well OpenMP Parallel Programming OpenMP versus MPI OpenMP (Open Multi-Processing): easy to use; loop-level parallelism non-loop-level parallelism is more difficult limited to shared memory computers cannot handle very large problems An alternative is MPI (Message Passing Interface): require low-level programming; more difficult programming
    [Show full text]
  • Overview of the Global Arrays Parallel Software Development Toolkit: Introduction to Global Address Space Programming Models
    Overview of the Global Arrays Parallel Software Development Toolkit: Introduction to Global Address Space Programming Models P. Saddayappan2, Bruce Palmer1, Manojkumar Krishnan1, Sriram Krishnamoorthy1, Abhinav Vishnu1, Daniel Chavarría1, Patrick Nichols1, Jeff Daily1 1Pacific Northwest National Laboratory 2Ohio State University Outline of the Tutorial ! " Parallel programming models ! " Global Arrays (GA) programming model ! " GA Operations ! " Writing, compiling and running GA programs ! " Basic, intermediate, and advanced calls ! " With C and Fortran examples ! " GA Hands-on session 2 Performance vs. Abstraction and Generality Domain Specific “Holy Grail” Systems GA CAF MPI OpenMP Scalability Autoparallelized C/Fortran90 Generality 3 Parallel Programming Models ! " Single Threaded ! " Data Parallel, e.g. HPF ! " Multiple Processes ! " Partitioned-Local Data Access ! " MPI ! " Uniform-Global-Shared Data Access ! " OpenMP ! " Partitioned-Global-Shared Data Access ! " Co-Array Fortran ! " Uniform-Global-Shared + Partitioned Data Access ! " UPC, Global Arrays, X10 4 High Performance Fortran ! " Single-threaded view of computation ! " Data parallelism and parallel loops ! " User-specified data distributions for arrays ! " Compiler transforms HPF program to SPMD program ! " Communication optimization critical to performance ! " Programmer may not be conscious of communication implications of parallel program HPF$ Independent HPF$ Independent s=s+1 DO I = 1,N DO I = 1,N A(1:100) = B(0:99)+B(2:101) HPF$ Independent HPF$ Independent HPF$ Independent
    [Show full text]