Introduction to Parallel Computing - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Introduction to Parallel Computing

Description:

SIMD - single instruction multiple data. MIMD multiple instruction multiple data. ... C/C - int MPI_Init(int argv, char* argc[]) Fortran - MPI_Init(INTEGER ierr) ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 31
Provided by: chpc4
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Parallel Computing


1
Introduction to Parallel Computing
Presentation
Martin CumaCenter for High Performance Computing
University of Utah mcuma_at_chpc.utah.edu
April 12, 2007
http//www.chpc.utah.edu
2
Overview
  • Types of parallel computers.
  • Parallel programming options.
  • How to write parallel applications.
  • How to compile.
  • How to debug/profile.
  • Summary, future expansion.

3
Parallel architectures
  • Single processor
  • SISD single instruction single data.
  • Multiple processors
  • SIMD - single instruction multiple data.
  • MIMD multiple instruction multiple data.
  • Shared Memory
  • Distributed Memory

4
Shared memory
  • All processors have access to local memory
  • Simpler programming
  • Concurrent memory access
  • More specialized hardware
  • CHPC Arches dual and quad CPU nodes

5
Distributed memory
  • Process has access only to its local memory
  • Data between processes must be communicated
  • More complex programming
  • Cheap commodity hardware
  • CHPC Linux clusters (Arches)

6
Parallel programming options
  • Shared Memory
  • Threads POSIX Pthreads, OpenMP
  • Message passing
  • Distributed Memory
  • Message passing libraries
  • Vendor specific non portable
  • General MPI, PVM

7
OpenMP basics
  • Compiler directives to parallelize
  • Fortran source code comments
  • !omp parallel/!omp end parallel
  • C/C - pragmas
  • pragma omp parallel
  • Small set of subroutines
  • Degree of parallelism specification
  • OMP_NUM_THREADS or omp_set_num_threads(INTEGER n)

8
MPI Basics
  • Communication library
  • Language bindings
  • C/C - int MPI_Init(int argv, char argc)
  • Fortran - MPI_Init(INTEGER ierr)
  • Quite complex (100 subroutines)
  • but only small number used frequently
  • Fixed number of parallel nodes

9
MPI vs. OpenMP
  • Easy to code
  • Fast data exchange
  • Memory access (thread safety)
  • Limited usability
  • Limited users influence on parallel execution
  • Complex to code
  • Slow data communication
  • Ported to many architectures
  • Many tune-up options for parallel execution

10
Program example
  • saxpy vector addition
  • simple loop, no cross-dependence, easy to
    parallelize
  • subroutine saxpy_serial(z, a, x, y, n)
  • integer i, n
  • real z(n), a, x(n), y(n)
  • do i1, n
  • z(i) ax(i) y(i)
  • enddo
  • return

11
OpenMP program example
  • subroutine saxpy_parallel_omp(z, a, x, y, n)
  • integer i, n
  • real z(n), a, x(n), y(n)
  • !omp parallel do
  • do i1, n
  • z(i) ax(i) y(i)
  • enddo
  • return
  • setenv OMP_NUM_THREADS 4

12
MPI program example
  • subroutine saxpy_parallel_mpi(z, a, x, y, n)
  • integer i, n, ierr, my_rank, nodes, i_st, i_end
  • real z(n), a, x(n), y(n)
  • call MPI_Init(ierr)
  • call MPI_Comm_rank(MPI_COMM_WORLD,my_rank,ierr)
  • call MPI_Comm_size(MPI_COMM_WORLD,nodes,ierr)
  • i_st n/nodesmy_rank1
  • i_end n/nodes(my_rank1)
  • do ii_st, i_end
  • z(i) ax(i) y(i)
  • enddo
  • call MPI_Finalize(ierr)
  • return

z(i) operation on 4 nodes
z(1 n/4)
z(n/41 2n/4)
z(2n/41 3n/4)
z(3n/41 n)
13
MPI program example
  • Result on the first node
  • include "mpif.h"
  • integer status(MPI_STATUS_SIZE)
  • if (my_rank .eq. 0 ) then
  • do j 1, nodes-1
  • do i n/nodesj1, n/nodes(j1)
  • call MPI_Recv(z(i),1,MPI_REAL,j,0,MPI_COMM_W
    ORLD,
  • status,ierr)
  • enddo
  • enddo
  • else
  • do ii_st, i_end
  • call MPI_Send(z(i),1,MPI_REAL,0,0,MPI_COMM_WORL
    D,ierr)
  • enddo
  • endif

14
MPI program example
zi(i)
Node 1
  • Collective communication
  • real zi(n)
  • j 1
  • do ii_st, i_endzi(j) ax(i) y(i)j j 1
  • enddo
  • call MPI_Gather(zi,n/nodes,MPI_REAL,z,n/nodes,MPI_
    REAL,
  • 0,MPI_COMM_WORLD,ierr)
  • Result on all nodes
  • call MPI_AllGather(zi,n/nodes,MPI_REAL,z,n/nodes,
  • MPI_REAL,MPI_COMM_WORLD,ierr)

zi(i)
Node 2
zi(i)
Node 3
zi(i)
Node 4
z(i)
Receive data
Send data
No root process
15
Arches - login
  • First log into Arches
  • ssh delicatearch.chpc.utah.edu - Myrinet
  • ssh marchingmen.chpc.utah.edu - Ethernet
  • ssh tunnelarch.chpc.utah.edu - Ethernet
  • ssh landscapearch.chpc.utah.edu Ethernet,
    Myrinet
  • ssh sanddunearch.chpc.utah.edu - InfiniBand
  • Then submit a job to get compute nodes
  • qsub I l nodes2ppn4,walltime10000
  • qsub script.pbs
  • Useful scheduler commands
  • qsub submit a job
  • qdel delete a job
  • showq show job queue

16
Security Policies
  • No clear text passwords use ssh and scp
  • You may not share your account under any
    circumstances
  • Dont leave your terminal unattended while logged
    into your account
  • Do not introduce classified or sensitive work
    onto CHPC systems
  • Use a good password and protect it

17
Security Policies
  • Do not try to break passwords, tamper with files
    etc.
  • Do not distribute or copy privileged data or
    software
  • Report suspicians to CHPC (security_at_chpc.utah.edu)
  • Please see http//www.chpc.utah.edu/docs/policies/
    security.html for more details

18
Compilation - OpenMP
  • Arches
  • Supported by Portland Group and Pathscale
    compilers, mp switch
  • e.g. pgf77 mp source.f o program.exe
  • Dual-processor and quad-processor (Sanddunearch)
    nodes
  • Further references
  • CHPC website
  • Portland Group website
  • http//www.pgroup.com/doc/index.htm
  • Pathscale website
  • http//www.pathscale.com/docs.html

19
Compilation - MPI
  • Different implementations on different machines
  • MPI code is portable on all CHPC systems

20
Compilation - MPI
  • Arches MPICH, MPICH2, MVAPICH, MVAPICH2
  • /MPI-path/bin/mpixx source.x o program.exe
  • MPI-path location of the distribution
  • /uufs/arches/sys/pkg/mpich/std TCP-IP
  • /uufs/UUFSCELL/sys/pkg/mpich-mx/std Myrinet
  • /uufs/arches/sys/pkg/mpich2/std MPICH2 TCP-IP
  • /uufs/sanddunearch.arches/sys/pkg/mvapich/std
    MVAPICH InfiniBand
  • /uufs/sanddunearch.arches/sys/pkg/mvapich2/std
    MVAPICH2 InfiniBand
  • must specify full path to mpixx
    (/MPI-path/bin) or add this path to PATH
    environment variable

21
Running a parallel job Arches
  • MPICH Interactive batch
  • qsub I l nodes2ppn2,walltime10000
  • wait for prompt
  • /MPI-path/bin/mpirun np 4 machinefile
    PBS_NODEFILE program.exe
  • /MPI-path/bin/mpirun_rsh rsh np 4
    machinefile PBS_NODEFILE program.exe
  • MPICH Batch
  • PBS l nodes2ppn2,walltime10000
  • OpenMP Batch
  • PBS l nodes1ppn2,walltime10000
  • setenv OMP_NUM_THREADS 2
  • program.exe

22
Running a parallel job Arches
  • MPICH2, MVAPICH2 Interactive batch
  • qsub I l nodes2ppn2,walltime10000
  • wait for prompt
  • mpdboot n 2 r /usr/bin/rsh f PBS_NODEFILE
  • mpdtrace
  • da001
  • da002
  • mpiexec n 4 ./program.exe
  • NOTE on sanddunearch, use ppn4

23
Debuggers vendor supplied
  • Arches, desktops
  • gdb pgdbg pathdb, idb
  • How to use
  • http//www.chpc.utah.edu/docs/manuals/software/par
    _devel.html

24
Debuggers - parallel
  • Totalview
  • Arches, desktops
  • Graphical, multi-process debugger
  • How to run it
  • compile with g flag
  • Details
  • http//www.chpc.utah.edu/docs/manuals/software/to
    talview.html
  • Further information
  • http//www.totalviewtech.com/alltvdocs.htm

25
Debuggers parallel cont.
Process view
Source code view
Data inspection
26
Profilers - parallel
  • Arches
  • serial gprof, pgprof
  • parallel TAU/Vampir

27
Profilers - parallel
28
Parallel libraries
  • Arches
  • ScaLAPACK, PETSc, NAG, FFTW
  • http//www.chpc.utah.edu/docs/manuals/software/mat
    _l.html

29
Summary
  • Shared vs. Distributed memory
  • OpenMP
  • limited on Arches
  • Simple parallelization
  • MPI
  • Arches
  • Must use communication
  • http//www.chpc.utah.edu/docs/presentations/intro_
    par

30
References
  • OpenMP
  • http//www.openmp.org/
  • Chandra, Dagum, Kohr, - Parallel Programming in
    OpenMP
  • MPI
  • http//www-unix.mcs.anl.gov/mpi/
  • Pacheco - Parallel Programming with MPI
  • Gropp, Lusk, Skjellum - Using MPI 1, 2

31
Future Presentations
  • Introduction to MPI
  • Introduction to OpenMP
  • Debugging with Totalview
  • Profiling with TAU/Vampir
  • Intermediate MPI and MPI-IO
  • Mathematical Libraries at the CHPC
Write a Comment
User Comments (0)
About PowerShow.com