ECE 4122/6122 Lab 4: CUDA-based John Conway’s Game of Life (100 pts)Category: CUDA
Due: Tuesday November 8th , 2024 by 11:59 PM
Objective: Implement a C++ CUDA program to run the Game of Life.
Game Description: The Game of Life (an example of a cellular automaton) is played on an infinite two-dimensionalrectangular grid of cells. Each cell can be either alive or dead. The status of each cell changeseach turn of the game (also called a generation) depending on the statuses of that cell's neighbors. Neighbors of a cell are cells that touch that cell, either horizontal,vertical, or diagonalfrom that cell.The initial pattern is the first generation. The second generation evolves from applying the rulessimultaneously to every cell on the game board, i.e. births and deaths happen simultaneously.Afterwards, the rules are iteratively applied to create future generations. For each generationof the game, a cell's status in the next generation is determined by a set of rules. These simplerules are as follows:•If the cell is alive, then it stays alive if it has either 2 or 3 live neighborsIf the cell is dead, then it springs to life only in the case that it has 3 live neighborsThere are, of course, as many variations to these rules as there are different combinations ofnumbers to use for determining when cells live or die. Conway tried many of these differentvariants before settling on these specific rules. Some of these variations causethe populationsto quickly die out, and others expand without limit to fill up the entire universe, or some largeportion thereof.
Assignment:
- 1) Write a C++ application that takes up to 5 command line arguments to dynamically change thenumber of processing threads ( >= 2), cell size, the image size and the type of memory allocation.Below is an example ./Lab2 -c 5 -x 800 -y 600 -t NORMALThe flags-n is the number of threads per block (must be a multiple of 32),-c is used to denote the “cell size” with cells being square (c >=1),-x is the window width,-y is the window height-t is either NORMAL, PINNED, or MANAGED. This is the type of memory to use either normalpinned, or managedThe grid size used for calculations and display is the (window size)/(cell size).If one of the flags above is missing then automatically use the defaults:-n defaults to 32-c defaults to 5-x and -y default to 800 by 600 respectively.t defaults to NORMAL
- 2) Write your code using three functions: one for the normal memory allocation, one for pinnedmemory allocation, and one for managed memory allocation.
- 3) Your code needs to use a random number generator to initially set the individual grid element toeither “alive” or “dead”.
- 4) Your code then runs continuously generating new results until either the window is closed or the“Esc” key is pressed. 5) While your code is running you need to display to a graphics window the current state of the Lifegame. Cells that are alive are white and deadcellsare black. You don’t need to draw the deadcells.
- 6) While your code is running you need to constantly output to the console window the processing
time in microseconds of the last 100 generations of the 代写ECE 4122/6122 CUDA program game and the type of memory allocation.Do not include the time it takes to display the results.For example:100 generations took ??? microsecs with 32 threads per block using Normal memory allocation.100 generations took ??? microsecs with 64 threads per block using Pinned memory allocation.100 generations took ??? microsecs with 1024 threads per block using Managed memory allocation.Turn-In InstructionsZip up your file(s) into Lab4.zip and upload this zip file on the assignment section of Canvas.Grading Rubric: If a student’s program runs correctly and produces the desired output, the student has the potential to get a 100on his or her homework; however, TA’s will look through your code for other elements needed to meet the labrequirements. The table below shows typical deductions that could occur.AUTOMATIC GRADING POINT DEDUCTIONS PER PROBLEM: Element
PercentageDeductionDetails
Does Not Compile40%Code does not compile on PACE-ICE! Not Match OutputUp to 90%The code compiles but does not produce correct outputs. and efficiency ofcode setupUp to 10%extra creditTop quartile 10 pts, Second quartile 5 pts, Third quartile 2 pts.Clear Self-DocumentingCoding StylesUp to 25%
This can include incorrect indentation, using unclear variable names,unclear/missing comments, or compiling with warnings. (SeeAppendix A)
LATE POLICY
Element Percentage Deduction Details Late Deduction Function score – 0.5 * HH = number of hours (ceiling function) passeddeadline Appendix A: Coding StandardsIndentation: When using if/for/while statements, make sure you indent 4 spaces for the content inside those. Also makesure that you use spaces to make thecode more readable.For example:If you have nested statements, you should use multiple indentions. Each { should be on its own line (like thefor loop) If you have else or else if statements after your if statement, they should be on their own line.for (int i; i < 10; i++)
Camel Case: This naming convention has the first letter of the variable be lower case, and the first letter in each new wordbe capitalized (e.g. firstSecondThird).This applies for functions and member functions as well!The main exception to this is class names, where the first letter should also be capitalized.
Variable and Function Names: Your variable and function names should be clear about what that variable or function represents. Do not useone letter variables, but use abbreviations when it isappropriate (for example: “imag" instead of“imaginary”). The more descriptive your variable and function names are, the more readable your code will
- This is the idea behind self-documenting code. File Headers:Every file should have the following header at the top
/*Author: your nameClass: ECE4122 or ECE6122 (section)Last Date Modified: dateDescription:What is the purpose of this file?*/Code Comments:
- Every function must have a comment section describing the purpose of the function, the input andoutput parameters, the return value (if any).
- Every class must have a comment section to describe the purpose of the class.
- Comments need to be placed inside of functions/loops to assist in the understanding of the flow of
the code.
标签:ECE,code,4122,use,cell,program,CUDA,memory,your From: https://www.cnblogs.com/comp9321/p/18538097