Week 9: Lab 6 - Algorithm Selection Lab

Hello everyone and welcome to my blog!

During this week we are going to work on algorithm selection lab and investigate the impact of different algorithms which produce the same effect. You will test and select one of three algorithms for adjusting the volume of PCM audio samples based on benchmarking.

Here is the description of the lab from the course website: Algorithm Selection Lab

In this lab we are to test the performance and time the program on Aarch64 and x86_64, analyse CPU and memory usage and so on. There are several servers we are going to work with: x86_64 server Xerxes; AArch64 server: AArchie, BBetty, CCharlie, and Israel. Our group started with running code on the first server AArchie. Next we ran the program with different modifications and time it. After, we repeated the process on other machines: BBetty, CCharlie, and Israel. Finally, we proceeded on Xerxes. So far, we were able to get time it takes to process the same info on different machines, by subtracting run-time of modified program from run-time of non-modified program.

Background
  • Digital sound is typically represented, uncompressed, as signed 16-bit integer signal samples. There is are two streams of samples, one each for the left and right stereo channels, at typical sample rates of 44.1 or 48 thousand samples per second per channel, for a total of 88.2 or 96 thousand samples per second (kHz). Since there are 16 bits (2 bytes) per sample, the data rate is 88.2 * 1000 * 2 = 176,400 bytes/second (~172 KiB/sec) or 96 * 1000 * 2 = 192,000 bytes/second (~187.5 KiB/sec).
  • To change the volume of sound, each sample can be scaled (multiplied) by a volume factor, in the range of 0.00 (silence) to 1.00 (full volume).
  • On a mobile device, the amount of processing required to scale sound will affect battery life.
Three Approaches

Three approaches to this problem are provided:
  1. The basic or Naive algorithm (vol1.c). This approach multiplies each sound sample by 0.75, casting from signed 16-bit integer to floating point and back again. Casting between integer and floating point can be expensive operations.
  2. A lookup-based algorithm (vol2.c). This approach uses a pre-calculated table of all 65536 possible results, and looks up each sample in that table instead of multiplying.
  3. A fixed-point algorithm (vol3.c). This approach uses fixed-point math and bit shifting to perform the multiplication without using floating-point math.
As for my assumptions regarding which algorithm will run faster I guess the fixed-point algorithm will be the fastest.

Conclusions

As we were told to not compare performance across different machines I will only stick to comparing results of relative performance of the various algorithms on the same machine. We conducted the tests several times on each machine and took the average result for each of real time. The results were similar to my assumption: the fixed-point algorithm showed up to be the fastest. the results of our testings is below.

Comments