Docsity

Wrapup - Parallel Computing - Lecture Slides, Slides of Parallel Computing and Programming

Partial preview of the text

Download Wrapup - Parallel Computing - Lecture Slides and more Slides Parallel Computing and Programming in PDF only on Docsity!

Parallel Computing Wrapup

Topics for Today

**- Dissemination barrier

  • Fourier transform
  • Review
  • Some things we didn’t cover
  • Parallel programming top ten list**

Dissemination Barrier in Action

Round 2

Round 1 Round 3

Dissemination Pattern

- Strength —avoids reduction tree + broadcast tree - reduction + broadcast tree: critical path length = 2 log 2 P **—faster by a factor of two in practice for that reason

  • Also useful for idempotent reductions** —barrier —min, max —or, and

7 Productive Parallel 1D FFT (n = 2 k ) subroutine fft(c, n) implicit complex(c) dimension c(0:n-1), irev(0:n-1) !HPF$ processors p(number_of_processors()) !HPF$ template t(0:n-1) !HPF$ align c(i) with t(i) !HPF$ align irev(i) with t(i) !HPF$ distribute t(block) onto p two_pi = 2.0d0 * acos(-1.0d0) levels = number_of_bits(n) - 1 irev = (/ (bitreverse(i,levels), i= 0, n-1) /) forall (i=0:n-1) c(i) = c(irev(i)) do l = 1, levels! --- for each level in the FFT m = ishft(1, l) m2 = ishft(1, l - 1) do k = 0, n - 1, m! --- for each butterfly in a level do j = k, k + m2 - 1! --- for each point in a half bfly ce = exp(cmplx(0.0,(j - k) * -two_pi/real(m))) cr = ce * c(j + m2) cl = c(j) c(j) = cl + cr c(j + m2) = cl - cr end do end do enddo end subroutine fft Two stages: —bit reversal permutation —butterfly pattern of element combinations

8 1D FFT Support Code pure function number_of_bits(i) number_of_bits = 0 i_tmp = i do while (i_tmp .gt. 0) number_of_bits = number_of_bits + 1 i_tmp = ishft(i_tmp, -1) end do end function number_of_bits pure function bitreverse(i, n) interchange_bits(ival,imask,ishift) = & ior(ishft(iand(ival, imask), -ishift), & ishft(iand(ival, not(imask)), ishift)) parameter (mask32 = Z'FFFFFFFF00000000') parameter (mask16 = Z'FFFF0000FFFF0000') parameter (mask8 = Z'FF00FF00FF00FF00') parameter (mask4 = Z'F0F0F0F0F0F0F0F0') parameter (mask2 = Z'CCCCCCCCCCCCCCCC') parameter (mask1 = Z'AAAAAAAAAAAAAAAA') integer bitreverse itmp = interchange_bits(i, mask32, 32) itmp = interchange_bits(itmp, mask16, 16) itmp = interchange_bits(itmp, mask8, 8) itmp = interchange_bits(itmp, mask4, 4) itmp = interchange_bits(itmp, mask2, 2) itmp = interchange_bits(itmp, mask1, 1) bitreverse = ishft(itmp, n - 64) end function bitreverse bit level parallelism

**- Radix 2 FFT implementation

  • Block distribution of coarray “c” across all processors
  • Sketch in CAF 2.0:**

complex, allocatable :: c(:,2)[], spare(:)[]

! permute data to bit-reversed indices (uses team_alltoall)

call bitreverse(c, n_world_size, world_size, spare)

! local FFT computation for levels that fit in the memory of an image

do l = 1, loc_comm- ...

! transpose from block to cyclic data distribution (uses team_alltoall)

call transpose(c, n_world_size, world_size, spare)

! local FFT computation for remaining levels

do l = loc_comm, levels ...

! transpose back from cyclic to block data distribution (uses team_alltoall)

call transpose(c, n_world_size, n_local_size/world_size,spare)

SPMD Implementation of FFT in CAF 2.

SPMD Element-wise Bitreverse in CAF Each processor performs reversal of a block [ rank * n / npe ... (rank + 1) * n/npe -1] local_n = n / npe global_j = rank * local_n do local_j = 0, local_n - 1 jrev = bitreverse(global_j, n_bits) processor = ishft(jrev, -local_n_bits) index = iand(jrev, local_mask) crev(index)[processor] = c(local_j) global_j = global_j + 1 enddo 11 log n - log p bits log P bits

FFT Performance 13

CAF 2.0 FFT Relative Parallel Efficiency

number of cores

relative parallel efficiency

FFT

Course Objectives

- Learn fundamentals of parallel computing —principles of parallel algorithm design —programming models and methods —parallel computer architectures —modeling and analysis of parallel programs and systems **—parallel algorithms

  • Develop skill writing parallel programs** **—programming assignments employing a variety of models
  • Develop skill analyzing parallel computing problems** —develop parallelizations for different styles of computations

Principles of Parallel Algorithm Design

- Algorithm models —data-parallel, task graph, work pool **—master slave, pipeline, hybrid

  • Decomposition techniques** —recursive —data driven: input data, output data, intermediate data —hybrid decomposition —exploratory decomposition **—speculative decomposition
  • Task generation** —static vs. dynamic assignment 4 assignment 2 assignment 3 assignment 1 4 1, 2, assignment 1

Programming Models

- Shared-memory parallel programming —Cilk/Cilk++ —OpenMP **—Pthreads

  • Global address space programming models** **—Unified Parallel C (UPC)
  • Message passing and MPI
  • GPU programming with CUDA
  • MapReduce**

Parallel Architectures

- Control structure and communication models —control structure: SIMD, MIMD —communication models - shared address space - **message passing platforms

  • Network topologies** —static/direct vs. dynamic/indirect networks —bus, crossbar, omega, hypercube, fat tree, mesh, Kautz graph —hybrid interconnects —evaluation metrics - **degree, diameter, bisection width, channel width & rate, cost
  • Coherence, routing, and network embeddings** —blocking vs. non-blocking networks —routing techniques: store & forward, packet, wormhole —cache coherence: protocols, snoopy caches, directories, SCI —embeddings: dilation, congestion