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...