Originally released in April 2016. This video is the first in a series of SourceCrunch videos on software optimisation fundamentals. While this series is now discontinued, it has been released for free here on YouTube.
== VIDEO NOTES ==
In this video we discuss the role of the CPU (Central Processing Unit) in program execution on modern general purpose computer architectures.
== QUIZ ==
1. Typically, software is optimised to meet a specific goal - such as a performance target, memory quota, or energy allowance. Software running on mobile devices, for example, often has a heavy focus on energy costs. What characteristics do you suspect may be a primary focus for optimisation in single-player games development for desktop computers?
A. Network usage
B. Energy consumption
C. Performance and memory usage
2. The following quote regarding software optimisation is extremely famous:
We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
Yet we should not pass up our opportunities in that critical 3%.
-- Donald Knuth
Why is benchmarking and profiling code important to the optimisation process?
A. It's not, it should be obvious which parts of the code should be optimised.
B. It's not, we should optimise code based on guesswork about its characteristics.
C. To determine which parts of the code should be optimised with what priority.
D. To determine whether the software works correctly.
3. Inside the CPU there are typically units to manage the execution of instructions, perform arithmetic and logical calculations, and store data (usually, for internal CPU calculations). In the order they were listed in the previous sentence, what are these units called?
A. Control Unit, Memory, ALU(s)
B. Control Unit, ALU(s), Memory
C. Control Unit, Registers, ALU(s)
D. Control Unit, ALU(s), Registers
4. The clock rate of a CPU measures how fast synchronised pulses of electricity flow through the processor, and is typically measured in Hz (cycles per second). Fundamentally, if I'm optimising for performance on a single CPU, which of the following outcomes am I trying to achieve?
A. Using less CPU cycles.
B. Occupying fewer registers.
C. Maximising communication between the ALU and Control Unit.
5. CPUs perform operations based on the instructions that they are given. Say we had an imaginary processor called the SC-100 with a single general purpose register, which has the following instruction set:
00000000 = Halt the processor (stop any further execution)
00000001 = Store the value 1 in register #1
00000010 = Add 1 to the value in register #1
00000011 = Multiply the value in register #1 by 2
00000100 = Output the value in register #1 to the monitor
Assuming that the SC-100 can only execute one instruction at a time (in order) and that all instructions take the same amount of time to execute, which of the following SC-100 programs would output the value '12' quickest?
A. 00000001 00000010 00000010 00000010 00000010 00000010 00000011 00000100 00000000
B. 00000001 00000010 00000010 00000011 00000011 00000100 00000000
C. 00000001 00000010 00000011 00000011 00000100 00000000
6. Writing programs in raw binary is a little tiresome, so we decide to create a set of textual representations for each SC-100 instruction (e.g. "HALT" = 00000000). A series of these textual representations can be written and then translated into binary machine code to make writing programs easier. What is this type of programming language called?
A. A high-level language
B. A processor language
C. An assembly language
7. Unfortunately, the programs above (whether they were coded in raw binary or textual representations) will only execute correctly on in-order processors that support the SC-100 instruction set. Why might this be an issue?
A. If we upgrade to the SC-101 processor (which uses the same instruction set), the programs will fail to work.
B. Many processors don't support the SC-100 instruction set, and thus won't be able to execute the programs.
== ANSWERS ==
1. C
2. C
3. D
4. A
5. B
6. C
7. B
Ещё видео!