























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























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
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
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
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
Θ [ 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