暨南大学2021计组实验4.docVIP

  • 0
  • 0
  • 约4.79千字
  • 约 7页
  • 2022-12-26 发布于广东
  • 举报
Lab 4: Performance Lab 1 Introduction The assembly language in Lab 3 is one of the most effective means for gaining an understanding how the code will run in high performance. In this lab, students should optimize the performance of an application kernel function such as convolution or matrix transposition. It provides a clear demonstration of the properties of cache memories and gives them experience with low-level program optimization. 2 Type This is a team project (up to three students) which will be completed in two weeks. 3 Instructions 3.1 Image processing problem This lab deals with optimizing memory intensive code. Image processing offers many examples of functions that can benefit from optimization. In this lab, we will consider two image processing operations: rotate, which rotates an image counter-clockwise by 90。, and smooth, which “smooths” or “blurs” an image. For this lab, we will consider an image to be represented as a two-dimensional matrix M, where Mi,j denotes the value of (i, j)th pixel of M. Pixel values are triples of red, green, and blue (RGB) values. We will only consider square images. Let N denote the number of rows (or columns) of an image. Rows and columns are numbered, in C-style, from 0 to N-1. Given this representation, the rotate operation can be implemented quite simply as the combination of the following two matrix operations: ? Transpose: For each (i, j) pair, Mi,j and Mj,i are interchanged. ? Exchange rows: Row i is exchanged with row N-1-i. This combination is illustrated in Figure 1. Figure 1 Rotation of an image by 90。counterclockwise The smooth operation is implemented by replacing every pixel value with the average of all the pixels around it (in a maximum of 3×3 window centered at that pixel). Consider Figure 2. The values of pixels M2[1][1] and M2[N-1][N-1] are given below: Figure 2 Smoothing an image 3.2 Source code The only file you will be modifying is kernels.c. Looking at the file kernels.c, you’ll notice a C structu

文档评论(0)

1亿VIP精品文档

相关文档