Skip to main content

Posts

Final Project

Photo by  Octavian Dan  on  Unsplash We are approaching the end of the course, and as part of the curriculum, we have to pick one open source project to be our raw material for benchmarking, profiling and maybe improve it. I decided to go with AWK, which is a great tool to manipulate files. In the early days of my career, when I had to sort and filter huge text files from the billing system, the awk was my favourite. Check the awk's manual . So, here is the link to the awk repo . If you are interested in my test results, check it here . See you.

Going Faster

Photo by  Anders Jildén  on  Unsplash Today’s topic is compiler optimizations. Besides translating our source code into machine binary executable, the compiler, based on optimization parameters, can also produce faster executables. Just by adding some parameters to the compiler, we can get a better performance or a smaller executable, for example. There are hundreds of those parameters which we can turn on or off using the prefix -f and -fno. However, instead of doing one by one, we can use the features mode using the -O param. It ranges from 0 (no optimization – the default) to 3 (the highest). Using those parameters has a cost —usually, the faster, the larger executable. How does the compiler make it faster if my code is perfect? I’m going to put some methods here, but if you want, here is more detail . Also, bear in mind that most of the optimizations are done in the intermediate representation of the program. So, the examples below are rewritten just to...

Project Stage 1

Photo by  SpaceX  on  Unsplash Hello! This is my SPO 600 blog, and this post will be long – sorry. The goal is to pick one project that is CPU intensive, written in C or C++, and experiment different compiler options and present the results. That’s why it will be long – lots of data to show. I choose the AWK project ( https://github.com/onetrueawk/awk ). It is a handy tool to process files. Parse, sort, and filter are some trivial operations that are CPU intensive. To make it harder, I created a huge XML file to parse it and count the tags. I've described the machines in my last post, if you miss it, here it is . I also created a script to run and collect the data. I planned to run each candidate 10 times, but a few attempts didn’t receive any data. So, I decided to nest the loop in a way that even if someone kills my process, the data could be used. Guess what? It happened! To produce the candidates, I just changed the CFLAGS inside the makefile and ran the...

Benchmarking

Photo by  Alex manlyx  on  Unsplash Time to get the hands dirty and do some benchmarking. The goal of Lab6 is to run the different sound volume algorithms described in my last post in the five different machines and compare them. I talked about the algorithm in the last post, so now it’s time to talk about the machines. Here they are: AARCHIE BBETTY CCHARLIE ISRAEL XERXES OS Fedora 28 Fedora 31 Fedora 30 Ubuntu 19.04 Fedora 30 Architecture aarch64 aarch64 aarch64 aarch64 x86_64 CPU(s) 24 8 8 16 8 Thread(s) per core 1 1 1 1 2 Model name Cortex-A53 Cortex-A57 X-Gene Cortex-A72 Intel(R) Xeon(R) CPU E5-1630 v4 @ 3.70GHz L1d cache 32K - unknown 32K 32K L1i cache 32K - unknown 48K 32K L2 cache 256K - unknown 1024K 256K L3 cache 4096K - - - 10240K Before running anything, we need to make sure to get the time consumed by the algorithm o...

Performance Tuning Hero

Photo by  Ayo Ogunseinde  on  Unsplash Week 8! I’m Rodrigo, and this is my blog about my SPO 600 course. I’ve posted since January, and so far, I didn’t tell you what is SPO, right? It is Software Portability and Optimization. Today we will approach the Optimization part differently. Instead of squeezing the compiler, we will care about how the software is working. I have a pretty good experience in performance and tuning in Oracle database, PL/SQL and SQL. I can say that, by far, the significant gain in execution time lies in how the software is designed. The same steps that I’ve used, we are going to use in the course. First, do not touch the code without knowing how bad it is. Benchmarking is a must. Before, during and after, these metrics will guide our work and justify hours of analysis and development. It must be done right like a methodic scientist collecting vital data and not rushing. The more depth of info you get, the easiest will be the next steps. Se...

Just a Loop

Photo by  Tine Ivanič  on  Unsplash Hey everyone! This post is dedicated to Lab 5. I’ll say upfront that this was the most challenging loop of my career. Yes! If you told assembly, you were right. Our professor was kind to provide necessary codes from each platform. He also gave us access to several machines with different hardware capabilities for both architectures. Combined with the previous lecture, we had everything that we need to succeed. The goal was to create a program that shows “loop” ten times. Next, we had to change it to include the index number. Finally, extend it to show thirty times with the index suppressing the leading zero. Don’t forget, on BOTH architectures! If it were on C, C++, Java, JavaScript or Bash, I would have time to a coffee. To be fair, the first task was to put the “hello world” with the script provided. That was easy, and the only one that I accomplished. To compile it, I added a new target to the make file provided. The result y...

Hello World in Assembly

Photo by  Martin Sanchez  on  Unsplash Assembly alert! I promised to talk more about the compiler, but before it, more assembly. It is for a good reason, though. I was surprised to see my professor doing the “hello world” in assembly! Not only on x86_64 but also in the ARMv8 – different source code. He coded just like C or C++, saved, compiled and run it. The output was exactly like any other language. Nobody knew, but he was doing the Lab 5! I wish I were recording it. Our goal in this class was to compare the compiler output with the hand-crafted assembly. As expected, the compiler produced non-optimal executables even when we played with some fine-tuning options that I mentioned in the last post. How to compile an assembly code? Here are the commands: - Using GNU Assembler > as -g -o test.o test.s > ld -o test test.o - Using NASM Assembler > nasm -g -f elf64 -o test.o test.s > ld -o test test.o - Using GCC > gcc -g -o test.o test.S ...