Skip to main content

Posts

Showing posts from October, 2017

Vectorization and SIMD (Lab 5)

Our task was to create a small program that: 1) Creates two 1000-element integer arrays and fills them with random numbers in the range -1000 to +1000 2) Sums those two arrays element-by-element to a third array 3) Sums the third array and prints the result The source code for the program is here . The best way I found to get this to compile vectorized on our aarch64 machine was: gcc -03 lab5.c Before this, I tried: gcc  -ftree-vectorize lab5.c //already done in -03, leaves a messy main that is hard to understand. gcc -ftree-vectorizer-verbose=2 lab5.c //supposed to show how the program was vectorized but has been retired for -fopt-info- gcc -O2 -ftree-vectorize -fopt-info-vec-all lab5.c //shows vectorization process, useful for making sure your code structure allows vectorization. Interestingly, this helped me understand having one for loop allows for no vectorization.  A picture demonstrating the breakdown of the code is here . I thought this task was reall

Building Open Source Software and the GNU Standard C Library (Lab 4 Part 2)

To download and build the glibc was quite simple thanks to the guide provided by Chris here . The main steps (provided by the article) are: 1) mkdir $HOME/src 2) cd $HOME/src 3) git clone git://sourceware.org/git/glibc.git 4) mkdir -p $HOME/build/glibc 5) cd $HOME/build/glibc 6) $HOME/src/glibc/configure --prefix=/usr 7) make  This builds a fully functional glibc in the build directory which can be rebuilt anytime using the src directory. The c files present in the src directory must be altered to change the object files in the build directory. I made a small print program here that simply outputs a test message. When compiled with the installed system glibc it prints "hello world!" once . When compiled with my build of glibc it prints it twice due to the changes I made to the print.c file in the src directory. It is important to note that everytime the src directory is altrered in any way the build directory must be remade, and commenting out the proper code to

Loops in Assembly Architectures (Lab 3)

The modern C and C++ languages are often taken for granted for their simple syntax and compiler intuition. In Assembly, every variable and value are stored in registers, simple output lines are multiple statements in length, and a number can only be 0 to 9. Below I examine two different architectures, X86_64 and aarch64: x86_64 The loop I have created that outputs Loop: number thirty times can be found here . Writing this was extremely difficult, constantly fighting a lack of good documentation and examples online. To write this code I viewed many examples online, wrote pseudo code, and wrote the program in C++ before beginning. Debugging was difficult as the errors given were vague or rididculous at times (no // style commenting comes to mind). The Visual Studio compiler for writing C or C++ for example, is alternatively much more informative and allows for easy: break points, live variable information, and detailed information on error codes. I dislike X86 for the limited amou