Description
• Submit program to perforce in your student directory
o Sub directory called:
/PA2/…
o Fill out your PA2 Submission Report.pdf
Place it in the same directory as your solution
Enter the final Changelist number of your submission
Enter the number of test passed for Problem3
Save the output text files
• // problem 1
• // problem 2
• // problem 3 – debug & release
Write up a quick discussion in the report
• What you learned from this assignment
• Learn
o Data cache / Alignment
o Hot / Cold data structures
• Understand firsthand how alignment and data cache affects performance
1. Identifying data layout and alignment for supplied data structures and C++ classes
• Write a program to cleanly demonstrate the data alignment for any give data structure.
o Output should be printable to show padding
Number of padding bytes
Output should also return the size of the total alignment
o Clean output, nice formatting
o Save the Text file in that directory
Called: Output.txt
• Use test classes and structures supplied in perforce:
o /reference/Assignments/PA2/problem1/TestDataStruct.h
Optimized C++
Programming Assignment
1 CSC 461
Optimized C++ PA -2
2. Rework several data structures to reduce memory size
• Verify the before and after data size for each of the data structures supplied
o Clean output, nice formatting
o Should show padding
o Number of padding bytes
o Size of structure before/after
o Save the Text file in that directory
Called: Output.txt
• Use test classes and structures supplied in perforce:
o /reference/Assignments/PA2/problem2/TestDataStruct.h
3. Rework the supplied linked list data structure to a hot / cold data structure
• Refactoring the necessary insert/delete/find functions to the linked list
• Converting the existing data structure data to this new format
• Profile the before and after performance numbers of the linked list for the given input.
o Save the Text file in that directory
1. Called: output_Debug.txt
2. Called: output_Release.txt
• Use test system supplied in perforce:
o /reference/Assignments/PA2/problem3/…
General:
• Write all programs in cross-platform C++.
o Optimize for execution speed and robustness.
• Create a programming file for each problem, for example
o Student directory
/PA2/problem1/…
/PA2/problem2/…
/PA2/problem3/…
o Make sure that each problem can be compiled and run through the checked in
solution
• Do all your work by yourself
o Feel free to talk with others about ideas on Piazza
o You are 100% responsible for all code
o See syllabus about collaboration rules
• Check in the problems multiple times, at least 3 times per problem
o Have reasonable check-in comments
o Seriously, I’m checking
• Make sure that your program compiles and runs
o Warning level 4, some times that is not possible due to MS headers…
o Your code should be squeaky clean.
• More details for Problem 3: bloated problem
o You need to implement 3 functions:
Optimized C++
Programming Assignment
2 CSC 461
Optimized C++ PA -2
1) Convert the function from bloated to Hot/Cold data structures
2) Find a data node in the new Hot/Cold data structure
3) Verify that every original node is correctly represented in the Hot/Cold
structure.
o I included my timings in output_Keenan_release.txt and output_Keenan_debug.txt
o You can see my timings, for reference. Please leave the output file scheme alone, I
would like everyone to have similar format.
o Your timing will vary depending on your machine, but the ratios should indicate how
much you improved the performance.
o Interesting results:
My original timing to find the last data structure in the code is:
• 23.522184 ms
Hot Cold data structure:
• 1.456168 ms
16.153482 times faster!!!
• Cache does yield performance improvements.
o You might think this is not much, but most games are running at 30Hz, so you have
33.33ms to do your whole game per tick.
o If you are at 60 Hz, you have 16.66ms. Reducing timing from 23.5 ms to 1.45 ms is
quite significant.
Optimized C++
Programming Assignment
3 CSC 461
Optimized C++ PA -2
Simple check list to make sure that everything is checked in correctly
• Did you do all 3 problems?
• Do they compile and run without any errors?
• Warning level 4 free?
• Submitted it into /PA2 directory?
• Filled out the submission report?
• Can you delete you local drive, regrab the /PA2 directory?
o Is all the code there?
o Does it compile?
• Did you submit your text files?
Most assignments will have hints in a section like this.
• Do many little check-ins
o Iteration is easy and it helps.
o Perforce is good at it.
• Look at the lecture notes!
o A lot of good ideas in there.
o The code in the examples work.
Optimized C++
Programming Assignment
4 CSC 461