Posts

Showing posts from February, 2018

SPO 600 - Lab 4

In Lab 4, I will be looking at Single Instruction Multiple Data (SIMD) and Auto-Vectorization. Simply put, vectorization is to process one operation on multiple pairs of operands at the same time, to make the program faster. For this lab, I will have to write a C program that creates two 1000-element integer arrays, fill them in with random numbers within the range -1000 to +1000, sums these two arrays element-by-element into a third array, calculate the sum of the third array, then display it. I will test the program in Aarch64 environment. Here is the source code: #include <stdio.h> #include <stdlib.h> #include <time.h> int main (){ const int SIZE = 1000 ; int a[SIZE], b[SIZE], c[SIZE]; int min = - 1000 , max = 1000 ; srand(time( NULL )); for ( int i = 0 ; i < SIZE; i ++ ){ a[i] = rand() % (max + 1 - min); b[i] = rand() % (max + 1 - min); } int sum = 0 ; for ( int j = 0 ; j < SIZE; j ++ ){ c[j] = a[j] + b[j]; su

SPO 600 - Lab 3

In Lab 3, I'll be looking at Assembler and Assembly Language. For this lab, I will write a program that prints a message and its loop count for each iteration - in Assembly Language . Here's the expected output: Loop: 0 Loop: 1 Loop: 2 Loop: 3 Loop: 4 Loop: 5 Loop: 6 Loop: 7 Loop: 8 Loop: 9 Looks quite simple, isn't it? Well, in C that would get the job done: #include <stdio.h> int main (){ for ( int i = 0 ; i < 10 ; i ++ ){ printf( "Loop: %d \n " , i); } return 0 ; } But in Assembly Language, it is much more complicated. In fact, you actually have to manually convert the number into ASCII, concatenate it into the string, and then print it out: .text .globl _start start = 0 max = 10 _start: mov $start, % r15 loop: mov % r15, % r14 add $ 48 , % r14 mov % r14b,msg + 6 movq $len, % rdx movq $msg, % rsi