0% found this document useful (0 votes)
17 views

Second Assignment

This document describes a homework assignment on vectorization for a Computer Architecture II course. The objective is to implement matrix-matrix, matrix-vector, and vector-vector multiplication operations using both scalar and SIMD vectorized versions. The student created functions to initialize matrices and vectors and perform the various operations. Execution times were recorded for different input sizes to analyze the performance improvement from vectorization. Matrix-matrix multiplication showed the most benefit from vectorization, with speedups over 1x for all tested sizes.

Uploaded by

Mahmoud Barmawi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Second Assignment

This document describes a homework assignment on vectorization for a Computer Architecture II course. The objective is to implement matrix-matrix, matrix-vector, and vector-vector multiplication operations using both scalar and SIMD vectorized versions. The student created functions to initialize matrices and vectors and perform the various operations. Execution times were recorded for different input sizes to analyze the performance improvement from vectorization. Matrix-matrix multiplication showed the most benefit from vectorization, with speedups over 1x for all tested sizes.

Uploaded by

Mahmoud Barmawi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

An-Najah National University ‫جامعة النجاح الوطنية‬

Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬


Electrical and Computer Engineering ‫دائرة الهندسة الكهربائية والحاسوب‬
Department

Computer Architecture II HW #2
SIMD Vectorization

Student Name Mahmoud Nedal Mohammad Barmawi

Student ID 12028655

Course Name Computer Architecture II


Instructor Name Dr. Samer Arandi

Introduction:
The second assignment focuses on the concept of vectorization. But what
exactly is vectorization? It's the process of transforming an algorithm so that
instead of working on individual values one by one, it operates on a group of
values simultaneously. In modern CPUs, there's direct support for vector
operations, where a single instruction can be applied to multiple data elements
(SIMD - Single Instruction Multiple Data -). With the evolution of multicore chip
design, software development has embraced task parallelism. Alongside this trend,
another type of parallelism has gained traction: instruction level parallelism. This
involves enhancing the ability of processors to execute multiple instructions
simultaneously. As the number of cores in CPUs increases, the width of SIMD
registers has also been progressively expanding.

The alterations needed in software to make the most of instruction level


parallelism are referred to as 'vectorization'.
An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬
Electrical and Computer Engineering ‫دائرة الهندسة الكهربائية والحاسوب‬
Department

In this assignment, the objective is to carry out operations including Matrix –


Matrix Multiplication, Matrix – Vector Multiplication, and Vector – Vector
Multiplication. It's important to note that the result of Matrix * Matrix
multiplication is itself a Matrix. Conversely, when multiplying two vectors, the
output is a single value. Lastly, the product of a Matrix * Vector operation yields a
vector.

Procedures:

o implement the require function like as

initialize_matrix, matrix_vector, matrix_vector_sse, matrix_matrix,

matrix_matrix_sse.
An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬
Electrical and Computer Engineering ‫دائرة الهندسة الكهربائية والحاسوب‬
Department

o
An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬
Electrical and Computer Engineering ‫دائرة الهندسة الكهربائية والحاسوب‬
Department

o After it, we made it code in the main


An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬
Electrical and Computer Engineering ‫دائرة الهندسة الكهربائية والحاسوب‬
Department

And call the functions in order with, and I set the value for SIZE like as
128,256,512.

o We open Ubuntu and get to the location of the fil, for example the project
file is on disk D, then we will access it using this command

o We compile the code using this command

And run it and see result we run it using this command


An-Najah National University ‫جامعة النجاح الوطنية‬
Faculty of Engineering and IT ‫كلية الهندسة وتكنولوجيا المعلومات‬
Electrical and Computer Engineering ‫دائرة الهندسة الكهربائية والحاسوب‬
Department

Here we will show all result on the table:


Vector-Vector Multiplication
Input-size Scalar Vector Improvement (%)
128 0.000001 0.0000010 1
256 0.000001 0.0000010 1
512 0.000002 0.000001 2

Matrix-Vector Multiplication
Input-size Scalar Vector Improvement (%)
128 0.000038 0.000024 1.58
256 0.000155 0.000088 1.76
512 0.000760 0.000350 2.17

Matrix-Matrix Multiplication
Input-size Scalar Vector Improvement (%)
128 0.004514 0.004323 1.044
256 0.037055 0.034092 1.086
512 0.327801 0.298169 1.099

Conclusion:
We observe that the most time-consuming operation is the matrix-matrix

multiplication, particularly when dealing with a sizable matrix. Subsequently,

the matrix-vector multiplication process follows, succeeded by the vector-

vector multiplication.

You might also like