TMS4013 Parallel Processing Lecture 04 PDF
Document Details
Uploaded by MeaningfulLearning3987
Universiti Malaysia Sarawak
Tags
Summary
This lecture provides an overview of parallel processing concepts, focusing on embarrassingly parallel computations. It discusses various applications like image processing and geometrical transformations, and examines different computation methods including Monte Carlo techniques. The lecture also explores the data partitioning strategies used in parallel programming.
Full Transcript
TMS4013 Parallel Processing Chapter 3: Embarrassingly Parallel Computations Ideal Parallel Computation An ideal parallel computation is one that can be immediately divided into a number of completely independent parts each of which can be executed by a separate processor...
TMS4013 Parallel Processing Chapter 3: Embarrassingly Parallel Computations Ideal Parallel Computation An ideal parallel computation is one that can be immediately divided into a number of completely independent parts each of which can be executed by a separate processor simultaneously. No communication or very little communication between processes. Each process can do its tasks without any interaction with other processes. 2 Graphical Representation 3 Practical nearly embarrassingly parallel computation with static process creation and master-slave approach 4 Practical nearly embarrassingly parallel computation with dynamic process creation and master-slave approach: 5 Examples (i) Low level image processing (ii) Mandelbrot set (a.k.a. Fractals) (iii) Monte Carlo Calculations (iv) Rendering in Computer graphics (v) Large scale face recognition that involves comparing thousands of arbitrary acquired faces. 6 Images Basic way to store a two-dimensional image is a bitmap/pixmap, in which each pixel (picture element) is stored as a binary number in a two-dimensional array. For monochrome, a single binary bit (0 or 1) is sufficient to represent each pixel (2 states/colors). 0 -> black 1 -> white (bitmap) 7 Geometrical Transformations Can be done on each pixel using the embarrassingly parallel computations as it is totally independent for each pixel. Require mathematical operation to be performed on the coordinates of each pixel to move the positions of the pixel without affecting its values The result of a transformation is simply an updated bitmap (images stored in binary as an array of pixels. 8 Some common geometrical transformations: (i) Shifting of images in the displayed space (ii) Increasing or decreasing the size of images (iii) Rotation of images in two or three dimensions. 9 Shifting: Object shifted by ∆x in the x-dimension and ∆y in the y-dimension: x’ = x + ∆x y’ = y + ∆y where x and y are the original and x’ and y’ are the new coordinates. 10 Scaling : Object scaled by a factor Sx in x-direction and Sy in y-direction: x' = xSx y' = ySy Rotation : Object rotated through an angle θ about the origin of the coordinate system: x' = x cosθ + y sinθ y' = -x sinθ + y cosθ 11 Clipping : Define rectangular boundaries and delete those points outside the defined area of an image. Lowest and highest values are xl, yl and xh, yh respectively then: xl ≤ x’ ≤ xh yl ≤ y’ ≤ yh 12 Data Partitioning The main parallel programming concern is the division of bitmap into groups of pixels for each processor as the number of pixels is many more than the number of processes/processors. Two methods of grouping can be applied : (a) By square / rectangular regions (b) By rows / columns Assign one process / processor to one area of the image. 13 Example 640 X 480 image and 48 processors Image (let’s say, grayscale) can be divided according to the following two methods: (a) 48 rectangular of 80×80 pixels (b) 48 rows of 640×10 pixels Each processor will handle one unit (i.e., a rectangular or a row) 14 One square region for each process 15 One strip for each process One strip has 10 rows. 16 16 Pseudocode: Perform Image Shifting 48 slave processes, groups of 10 rows Master for (i =0, row = 0; i < 48; i++,row = row + 10) send(row, Pi); for (i = 0; i < 480; i++) for (j =0; j < 640; j++) temp_map[i][j] = 0; for (i = 0; i < (640*480); i ++) { recv(oldrow, oldcol, newrow,newcol, Pany); if !((newrow =480) || (newcol < 0) || (newcol >=640)) temp_map[newrow][newcol] = map [oldrow][oldcol]; } for(i = 0; i < 480; i++) for (j=0; j