Skip to main content

Posts

Showing posts from February, 2018

Lab 4

This lab is going to exploring single instruction/multiple data (SIMD) vectorization, and the auto-vectorization capabilities of the GCC compiler. For the people who not familiar with Vectorization, this article will help: Automatic vectorization In this lab, we are going to write a short program that: -Create two 1000-element integer arrays -Fill them with random numbers in the rang -1000 to +1000 -Sum up those two arrays element-by-element to a third array -Sum up the third array -Print out the result Here is the source code I wrote: ------------------------------------------------------ #include <stdlib.h> #include <stdio.h> #include <time.h> int main(){ int sum; int arr1[1000]; int arr2[1000]; int arr3[1000]; srand(time(NULL)); for(int i=0; i<1000; i++){ arr1[i] = rand() % 2001 - 1000; arr2[i] = rand() % 2001 - 1000; } for(int i=0; i<1000; i++){ arr3[i] = arr1[i] + arr2[i]; } for(int i=0; i<1000; i++){ su

Lab 3

In this lab, we are going to use Assembly language to finish 3 parts. 1. As we are getting familiar with Assembly language, we will create a loop in Assembly to prints out 10 times of "Hello World!". This part is quite easy to do it, here is the source code for x86_64 assembler: ------------------------------------------------------ .text .globl    _start start = 0                       /* starting value for the loop index; note that this is a symbol (constant), not a variable */ max = 10                        /* loop exits when the index hits this number (loop condition is i<max) */ _start:     mov     $start,%r15         /* loop index */     mov     %r15,%r10 loop:         /* ... body of the loop ... do something useful here ... */     movq        $len,%rdx         movq    $msg, %rsi         movq    $1, %rax         movq    $1, %rax         syscall     inc     %r15                /* increment index */     cmp     $max,%r15           /* see if we&#

Lab2

Complied C Lab In this lab, we were asked to compile a C program, using gcc command with different options. At the beginning of this lab, we wrote a simple C program that prints a message: Then using gcc command and the following compiler options to compile the program: -g # enable debugging information -O0 # do not optimize (that's a capital letter and then the digit zero) -fno-builtin # do not use builtin function optimizations Note that the size of file is 73088 bytes We can use objdump --source a.out command to show source code, the source code is under <main> section. And  readelf -p .rodata a.out contains the string to be printed. Then we add the option "-static" to recompile the program, found out the size is changed to 696264 bytes, which is bigger than the original program. And section headers are also increased. Next, I removed the builtin function optimization by remove option "-fno-builtin"

Lab1 - Code Review Lab

comparison of two open source software packages Before this lab, I would say I don't have a clear concept of open source, that make me spend an amount of time to understand the stuff like open source license, Github, and Bugzilla etc. After researching, I chose the following two of open source software: Android Android is a mobile operating system developed by Google, based on a modified version of the Linux kernel and other open source software and designed primarily for touchscreen mobile devices. License: Apache License 2.0 There is an account called aosp-mirror on Github, which provides a read-only mirror of some of the most common repository from the Android Open Source Project. That makes us able to view the source code and the modified versions of the project, it's the same as any other GitHub's repository. In order to contribute, the developer will need to follow the specific way of submitting bugs and patches. https://source.android.com/setup/contributi