ECE 486/586 ComPuter architecture PSU
HM Hw 2
HomeWork 2, Heat Transfer Function, 100 Points (1/25/2017)
Due Date: February 1st 2017, by the start of class, via email to the TA, cc Herb
Subject: Write a C program computing temperature changes over time in a 2D area
Answer 6 questions about parallel computation
Total Points: 70+30 = 100
General Rule: Implement your homework in C or C++. Write well-structured, readable, source programs. Use helpful comments and apply them liberally, expressing ideas not immediately visible from the source code. E.g. articulate solution ideas, list sources of algorithms, note caveats, explain goals. Only individual work counts. Submit via email by the due date before the start of class, using subject line: ECE 486 HW2, or ECE 586 HW2 –with the 2 alluding to homework 2. Include in your email the source, output, and if applicable input files; preferred for simple assignments is a single source file, and single output file. For full credit, send only raw ASCII form, not processed files; i.e. do not send Windows ZIP files, do not use Unix tar files, no shar utilities, or makefiles.
Summary: Homework 2 consists of 2 parts. In Part 1 you simulate heat flow in a metal plate over time; it is worth 70 points. In part 2 you research, to answer questions related to parallel computing; it is worth 30 points.
Part 1: The temperature distribution in a thin, square, metal plate with isothermal temperatures on each side can be modeled using a two-dimensional grid, as shown in Figure 1. Compute temperature changes over time across the surface area, after the 4 sides suddenly get set to a different, defined temperature. Discuss whether and how parallel processing can be used to speed up this compute model. We’ll use a simple 5 * 5 interior grid-point pattern.
Part 1 Detail (70 of 100 points): A thin, square heat conductive plate is embedded on all 4 sides in a medium with fixed temperatures. The 4 sides are called Top, Bottom, Left, and Right. All interior points have initial temperature of 0 oC but may change over time as heat flows. At the start of program execution you enter and must check all temperatures of the 4 sides within reasonable physical limits (i.e. >= -273 oC and <= 1538 oC). Yet all points on any one side have the same, constant temperature. Time change is coarsely simulated via a loop, that progresses in discrete time steps. Each interior point receives its temperature purely as a function of the average of its 4 adjacent neighbors up, down, left, and right; you don't need to consider the 4 diagonal points, nor its old temperature. When two successive iterations of temperature change at grid point [1][1] show no more than a predefined difference of temperatures ΔT the simulation stops. Selecting grid points like [1][1] for temperature change measurement is arbitrary and imprecise yet is allowed for easy implementation.
Figure 1: Metal Plate with defined, constant temperatures on each of the 4 sides
If all points are initially at 0 oC, and if at least one side’s temperature is not zero, then the system is in a non-equilibrium state. Heat will flow from areas of higher to areas of lower temperature until thermal equilibrium is achieved and the temperature of all points becomes constant.
Programming hint: two separate 2D arrays could be used. One array contains the current iteration's grid temperatures, while the other array holds the next iteration’s grid temperatures, which are computed using the data from the current iteration. After the new state has been calculated, it will become the current state for the next iteration.
Table 1: Required Test Cases, Temperatures in oC
Case / Top / Bottom / Left / Right1 / 100 / 10 / 100 / 200
2 / 75 / 0 / 10 / -25
3 / 50 / 50 / 50 / 50
4 / Your data / Your data / Your data / Your data
Write a C program to model the temperature distribution for a plate with 5×5 interior grid points:
· Prompt the user to enter the temperature (in degrees Celsius) of each of the 4 sides; these must be >= -273 oC, and <= 1,538 oC. Check for correctness of plausible range.
· All grid points along any one side have the same, constant temperature.
· Each side can have a temperature that is different from any of the other 3 sides, provided it is within legal range, but they may also be the same.
· Use ΔT = 10-2 ºC as the limit to stop further iterations.
· At each iteration display the iteration number and the current temperature state in an easily readable, formatted table.
· Show ºC temperatures to accuracy of 2 decimal places.
· The output should include both the side- and interior temperatures of the plate.
Part 1, Quality and Resulting Points: Only homework that works correctly receives a passing grade. Proper commenting is crucial for a good solution. Describe in a brief paragraph each library you included. Also, for each function of a library you used, provide a single paragraph synopsis. If you did not include any library, explain, e.g. why <stdio.h> for example was not needed! Run your simulation as long as the required precision (delta ΔT of temperature differences) has not yet been reached. The output sample below shows all 5 * 5 interior grid points, but also displays the neighboring rows and columns 0 and 6 for the sake of completeness; yet points [0][0], [0][6] etc. are never recomputed as a simplification.
Table 2: Plausible input / Output of Part 1
Enter temperatures (-273 oC .. 1538 oC) for all 4 sides of a plate below.
Enter Top temperature: 100
You entered 100.00 for Top side.
Enter Bottom temperature: 50
You entered 50.00 for Bottom side.
Enter Left temperature: 10
You entered 10.00 for Left side.
Enter Right temperature: 20
You entered 20.00 for Right side.
Iteration # 0
0 1 2 3 4 5 6
0: 0.00 100.00 100.00 100.00 100.00 100.00 0.00
1: 10.00 27.50 25.00 25.00 25.00 30.00 20.00
2: 10.00 2.50 0.00 0.00 0.00 5.00 20.00
3: 10.00 2.50 0.00 0.00 0.00 5.00 20.00
4: 10.00 2.50 0.00 0.00 0.00 5.00 20.00
5: 10.00 15.00 12.50 12.50 12.50 17.50 20.00
6: 0.00 50.00 50.00 50.00 50.00 50.00 0.00
Iteration # 1
0 1 2 3 4 5 6
0: 0.00 100.00 100.00 100.00 100.00 100.00 0.00
1: 10.00 34.38 38.12 37.50 38.75 37.50 20.00
2: 10.00 10.00 6.88 6.25 7.50 13.75 20.00
3: 10.00 3.75 0.62 0.00 1.25 7.50 20.00
4: 10.00 6.88 3.75 3.12 4.38 10.62 20.00
5: 10.00 18.75 19.38 18.75 20.00 21.88 20.00
6: 0.00 50.00 50.00 50.00 50.00 50.00 0.00
Iteration # 2
0 1 2 3 4 5 6
0: 0.00 100.00 100.00 100.00 100.00 100.00 0.00
1: 10.00 39.53 44.69 45.78 45.62 43.12 20.00
2: 10.00 13.75 13.75 12.97 15.00 18.12 20.00
3: 10.00 6.88 3.59 2.81 4.84 11.41 20.00
4: 10.00 9.06 7.50 6.72 8.75 13.44 20.00
5: 10.00 21.56 22.81 23.12 23.75 25.16 20.00
6: 0.00 50.00 50.00 50.00 50.00 50.00 0.00
Iteration # 3
0 1 2 3 4 5 6
0: 0.00 100.00 100.00 100.00 100.00 100.00 0.00
1: 10.00 42.11 49.77 50.82 50.98 45.94 20.00
2: 10.00 17.54 18.75 19.34 20.39 22.38 20.00
3: 10.00 9.10 7.73 7.03 9.49 14.10 20.00
4: 10.00 11.48 10.55 10.55 12.19 16.33 20.00
5: 10.00 22.97 25.55 25.82 26.76 26.80 20.00
6: 0.00 50.00 50.00 50.00 50.00 50.00 0.00
Iteration # 4
0 1 2 3 4 5 6
0: 0.00 100.00 100.00 100.00 100.00 100.00 0.00
1: 10.00 44.33 52.92 55.02 54.29 48.34 20.00
2: 10.00 19.99 23.59 24.25 25.55 25.11 20.00
. . . . more
Part 2, Questions related to Parallel Computing: Research Scientific textbooks or the Internet to briefly address the 6 questions below. Each is worth 5 points. Answer each question briefly and clearly, and cite, what you did and found to compose your answer. Limit your answers to one page each, or less, where applicable. For some questions relating to parallelism, distinguish clearly between temporal and spatial dependencies.
Part 2, Question 1 (5 points of 100): What is parallel computing? Describe what is essential; cite sources, where you found your information; qualify the type of problem that lends itself to parallel computing; what prevents parallel computing?
Part 2, Question 2 (5 points of 100): Name, cite parallel computer industry products. List computer companies that build parallel computers. What are these computers; chips, desktops, mainframes? How successful? Which microprocessors are parallel computers?
Part 2, Question 3 (5 points of 100): Summarize, cite, describe Amdahl’s Law. Where did you find a description? Summarize it. Give an example for almost no parallelism. Cite one example of a problem type that enables very high level of parallelism in computing.
Part 2, Question 4 (5 points of 100): What is essential to parallel computing? State what enables parallelism. Explain what prevents parallel computing. When you manage a microprocessor technology corporation, will you push for a higher degree of parallelism in computing? If so, why; if not, why not?
Part 2, Question 5 (5 points of 100): Assess the data dependence of 1 grid point from a neighboring grid point in the Heat Transfer Problem above, just focusing on any one identical iteration. E.g. during iteration n, is point grid[ row ][ col ] dependent on grid[ row+1 ][ col ] or on grid[ row ][ col-1 ] during the same identical iteration? If so, why? If not, why not?
Part 2, Question 6 (5 points of 100): Assess the data dependence of 1 grid point of the same grid point in an earlier iteration. E.g. during iteration n, is point grid[ row ][ col ] dependent on grid[ row ][ col ] from a previous iteration n-1? If so, why? If not, why not?
Table 3: Distribution of points
Number / Credit / Points1 / Part 1: Hand in only C source programs as text files, no executable files, no binary files, no .zip, no .shar, not compressed, not massaged in any way; ideally with .c or .cpp or .txt suffix / 10
2 / Part 1: Suitable commenting; do not practice redundant commenting; use only comments for ideas not immediately visible from the source; include your name, term, class, date, school / 10
3 / Part 1: Properly prompt for input of 4 side temperatures / 10
4 / Part 1: Describe inside a C comment the design, how you compute a new matrix of temperatures, but know the old value, so the temperature delta can be measured / 10
5 / Part 1: Argue convincingly that you have practiced an effective design methodology; perhaps top-down, rapid programming, or other. / 10
6 / Part 1: Use a readable programming style; that style requires proper naming of objects, use of symbolic constants (macros); use typedefs where applicable, group logically connected areas of code together / 10
7 / Part 1: Program runs correctly, input processed correctly, output well formatted, until correct temperature delta Δt is achieved / 10
Q1 / What is parallel computing? / 5
Q2 / Name, cite parallel computer industry products / 5
Q3 / Summarize, cite, describe Amdahl’s Law / 5
Q4 / What is essential to parallel computing / 5
Q5 / Assess the data dependence of 1 grid point from a neighboring grid point in the Heat Transfer Problem above, just focusing on any one identical iteration / 5
Q6 / Assess the data dependence of 1 grid point of the same grid point in an earlier iteration / 5
Total / 100
1 HW 2