Docsity

CMSC Final Old Material Test Quizzes with complete solutions., Exams of Advanced Education

Toggle sidebar
bg1
CMSC Final Old Material Test Quizzes with
complete solutions.
serial or sequential computing
doing a task in a sequence on 1 processes
paraellel computing
breaking up a task into subtasks and doing them concurrently on a set of processes
parallel architecture
set of nodes or processing connected by network
interconnection neworks
different topologies of connecting nodes together
system software
parallel programming model
core
single execution unit that has a private LI cache and can execute instructions independentley
processor
several cores on a single integrated circuit or chip are multi core processors
socket
physical connection into which chip or processor is inserted
node
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f

Partial preview of the text

Download CMSC Final Old Material Test Quizzes with complete solutions. and more Exams Advanced Education in PDF only on Docsity!

CMSC Final Old Material Test Quizzes with

complete solutions.

serial or sequential computing doing a task in a sequence on 1 processes paraellel computing breaking up a task into subtasks and doing them concurrently on a set of processes parallel architecture set of nodes or processing connected by network interconnection neworks different topologies of connecting nodes together system software parallel programming model core single execution unit that has a private LI cache and can execute instructions independentley processor several cores on a single integrated circuit or chip are multi core processors socket physical connection into which chip or processor is inserted node

packaging of sockets job scheduling each user submits parallel program for execution to job scheduler and that decides what job to schedule next and how many nodes to allocate compute nodes dedicate nodes for running each job (only accessed when allocated to the user) login nodes shared by all users to compile programs, submit, etc cluster cluster of nodes, typically put together with commodity hardware thread thread/path of execution managed by OS (share same memory address space) process heavy-weight, don't share resources such as memory, file descriptor, etc strong scaling fixed total problem size but run on more processes ex. sort n numbers on 1, 2, 4 ... processes weak scaling

Single Instruction Single Data (SISD) A uniprocessor data --> processeor <--- instructions Single Instruction Multiple Data (SIMD) Same operation is carried out on multiple pieces of data at once Multiple Instruction Multiple Data (MIMD) Different instructions carried out on different data at the same time single instruction multiple threads threads execute lock in step (GPUs) Single Program Multiple Data (SPMD) all processes execute the same program/instructions but act on different data -- MIMD parallelization all processes start from the same executable, each process has a unique rank, processes mak take different branches and operate on different data based on their rank steps to writing a parallel program

  1. find serial algo
  2. how to distribute data among threads/processese while minimizing data movement
  1. computation (how to divide work)
  2. how communication is needed 1D vs 2D Stencil Decomposition 1D: devidie rows OR columns among process and just communicate with the 2 neighbours 2D: divide BOTH rows and columns among processes and communication with 4 neighbors prefix sum aka scan calculate the sums of prefixes/running total of elements in the array (taking value at index and adding it to the current running total) parallel prefix sum
  3. look at number of processes and do ⌈ log base 2 p ⌉ strides/steps -- stride increase by power of 2 (1, 2, 4, 8...)
  4. at the stride number use the previous array (starting with the original) and add the current index with STRIDE # index values back parallel prefix sum implementation in practice n numbers and p processes and assign n/p blocks to each process

shared memory programming all threads have access to the entire address space so they communicate by accessing shared variables programmer must manage data conflicts Fork-Join Model of Parallelization used by open MP single flow of control where a primary thread spawns worker threads race conditions can occur when sharing data/variables and depends on scheduling order of threads when more than 1 thread accesses a memory location and 1 of them tries to write to it how to prevent race conditions synchronoization (expsensive) and change how data is accessed what is a pragma and syntax compiler directive #pragma omp construct [clause [, clause]...] parallel for loop

directs compilar that IMMEADIATE for loop is in parallel. the primary thread will create worker threads and iterations of the loop will be distrubted to different threads and then synch. #pragma omp parallel for private clause each threads gets its own copy of variables in list unitialized when threads start and after parallelizing the value of the private value isn't avaiable to the primary thread private clause consequences cannot rely on value assigned before parallel region cannot rely on updates inside the region being reflected after default clause data sharing attribute (can be shared or None) firstprivate clause initializes each threads private copy to the value of the primary thread copy when initializing last private clause writes value from the thread that executed the last iteration to the primary thread reduction clause

critical directive used to help with synch. issues code is only executed 1 thread at a time atomic directive used to help with synch. issues update memory location atomically (one update at a time) message passing each process runs its own address space and only accessese their memory parallel message passing program consists of independent processes each process runs same executable but potentially on different part of program and on different data MPI_Send blocking message int MPI_send(buf, count, datatype, dest, tag, comm) returns once sender can reuse the buffer

internally, MPI may copy the data into a system buffer or wait for matching recieve MPI_Recv blocking message int MPI_Recv(buf, count, datatype, source, tag, comm, status) returns once data from recv is in buffer how does blocking messaging work recieve matces a send if certain argument is matched if the sender sends 2 messages to a destination and both match the sam recieve, the 2nd can't recieve if the the 1st is still pending non blocking messaging parts/process

  1. posing: post nonblocking operation
  2. completion: wait for its results @ a later point (wait/test) helps overlap computation with communication MPI_Isend will return immediately and only start operation after Isend you can't modify buffer until the request is complete

sending message protocol redexvous message only sent after recieving ack. with destination larger messages sending message protocol short data sent with envelope very small messages cutoff between eager and rendezvous increasing eager limit treats more messages as small may improve latency but can increase memory usage and buffer contention sending message protocol synch MPI_SSend not return until the rec. posted performance analysis process of studying code's performance LogP model performance analysis LogP can capture effects such as network contention and limited buffering more accurately than the simple α-β model, but it is also more complex.

Analysis parallel communication on inter node network with: L: latency/delay o: overhead g: gap (1/g = bandwidth) p: # processes alpha + n * beta model T(n) = α + βn a (latency) n (size of message) β (β is the per-byte time (inverse bandwidth); 1/B = bandwidth) isoefficiency relationship between problem size and the number of processes to maintain a certain level efficiency. what rate should we increase the problem size with respect to the # processes to keep efficiency constant total time in all processes total time in all processes = useful computation + overhead (extra comp, communication, idle time) P T_P = T_1 + T_O

computation: n / p communication: 4√n / √p (4 neighbors) ration = comm / comp --> 4√p / √n more efficient because it's growing as √p instead of p P empiricial analysis add timers in the code to measure and analysis tracing tools capture entire execution trace (instrumentation) & record all events in program with timestampts (HPC) profiling tools provide aggregate information and ignore specific times when event occur instead provide info about time spent in regions hatchet calling context/call path sequence of function invocations leading the current statement calling context tree

dynamic prefix of all call paths in the execution unique node per calling context call graph condensed calling context tree; unique node per function merge nodes in the calling context tree with the same name into a single node per function but keep same relationships flat profile listing of all invoked functions, counts, times basic parallel matrix multiple store A and B in a distrubted manner, communicate between processes to get the right sub matrices to each process each process computes a portion of C (C_ij is a row of A and a column of B) cannon matrix multiplication process

  1. processes = number elements

  2. steps = √p starting at 0

  3. step 0: circular shift row i of matrix A, i positions to the left & circular shift column j of matrix B, j positions up 3i) step 0 pt 2: P i,j will locally update matrix blocks in Ci,j in parallel (multiply the same

arrange processes in 3D virtual grid, assign sub blocks of A and B to each process (multiple copies & increase memory) and each process computes a partial C move data once before and once after comp (reduce communication) Agarwal 3D Matrix Multiplication Process p_i p_j p_k = row column grid A holds i k and B holds j k

  1. copy A to all i-k planes and B to all j-k plane Note: when we say all look at the number value of j (A) and i (B) to determine have many planes to create
  2. each process will hold one A_ik and one B_kj
  3. do a local multiply: C_ij = Sum (A_ik * B_ik) overall all k
  4. reduction: C_ij = Sum of P_ij (k) from 0 to P_k - 1 Agarwal 3D Matrix Mult. Computation O(n^3 / p) per process Each process does one block multiply Matrix Multiply -- n/p_i n/p_k n/p_j = O(n^3 / p) Agarwal 3D Matrix Mult. Communication

Θ [ n^2 / p^(2/3) ] 3 main steps (broadcast A, broadcast B, reduce partial C) per process: (n^2/p_i p_k + n^2/p_j p_k + n^2/p_i*p_j) Θ [ n^2 / p^(2/3) ] scalar reducation every process contributes 1 number (commutative associative operation) combines into single value at root vector reduction every process gives an array of numbers applied to element-wise array parallelizing reduction use a spanning tree start at the leaves and send to parents, while intermediate nodes wait to recieve data from all children all to all reduction each process sends a distinct message to every other process 2D Mesh Virtual Topology