Daa Mini Project Report
Daa Mini Project Report
MATRIX MULTIPLICATION
BY
STUDENT
NAME Roll no.
MATRIX MULTIPLICATION
“Techno-Social Excellence”
CERTIFICATE
This is to certify that the Project Entitled
”
“MATRIX MULTIPLICATION (DAA)
Submitted by
STUDENT
NAME Roll no.
Kartikay Dhakad BEA29
Ashish Auti BEA12
Nidhi Bachuwar BEA13
Is a bonafide work carried out by students under the supervision Dr. Megha V. Kadam and it is
submitted towards the partial fulfilment of the requirement of Mini Project of Laboratory Practice
III (410246) for Bachelor of Engineering (BE Computer Engineering).
MATRIX MULTIPLICATION
Abstract
MATRIX MULTIPLICATION
INDEX
22
12
REFERENCES
MATRIX MULTIPLICATION
INTRODUCTION
MATRIX MULTIPLICATION
MATRIX MULTIPLICATION
LITERATURE SERVEY
Another strategy is to assign one thread per cell or element of the resulting matrix,
distributing the workload more evenly. However, this approach introduces more
complex synchronization and thread management, potentially incurring additional
overhead. The performance trade-offs between these two multithreading strategies
have been a subject of investigation in the literature.
Notable research has also focused on the hardware-level optimizations for matrix
multiplication, such as cache-aware algorithms and techniques designed to exploit
the parallelism of modern processors. Matrix multiplication is a pivotal operation
in scientific and engineering applications, making the study of efficient
implementation techniques of utmost importance. In this report, we aim to explore
and compare the performance of both single-threaded and multithreaded matrix
multiplication using the one-thread-per-row and one-thread-per-cell approaches.
MATRIX MULTIPLICATION
OBJECTIVES OF SYSTEM
The objective of this mini project is to implement matrix multiplication using two
different multithreading approaches: one thread per row and one thread per cell.
The performance of both approaches will be analyzed and compared to determine
which one is more efficient in terms of execution time for a given matrix size. The
primary goals are as follows:
MATRIX MULTIPLICATION
PROBLEM STATEMENT
MATRIX MULTIPLICATION
IMPLEMENTATION
import numpy as np
threading
= 200
= np.random.rand(matrix_size, matrix_size)
single_threaded_matrix_multiply(A, B):
np.dot(A, B) end_time =
- start_time
MATRIX MULTIPLICATION
multithreaded_matrix_multiply_rowwise(A, B, num_threads):
start_time = time.time()
result[i] = np.dot(A[i], B)
threads.append(thread) thread.start()
thread.join()
multithreaded_matrix_multiply_cellwise(A, B, num_threads):
MATRIX MULTIPLICATION
start_time = time.time()
range(matrix_size): thread =
threads.append(thread) thread.start()
thread.join()
MATRIX MULTIPLICATION
cellwise_result, cellwise_time =
multithreaded_matrix_multiply_cellwise(matrix_A, matrix_B, num_threads)
# Output:
MATRIX MULTIPLICATION
ALGORITHMS USED
MATRIX MULTIPLICATION
4. Create multiple threads, one for each row chunk, and assign each thread to
compute the product of its assigned rows.
• You create multiple threads, one for each row chunk, and assign each
thread the task of computing the product of its assigned rows.
5. In each thread, compute the dot product of the assigned rows of matrix A with
the entire matrix B.
• Each thread performs the dot product calculation by multiplying the
assigned rows of A with the entire matrix B.
6. Store the results in the corresponding rows of matrix C.
• The results from each thread are stored in the corresponding rows of the
result matrix C.
7. Ensure proper synchronization to avoid race conditions.
• Proper synchronization mechanisms are implemented to ensure that
multiple threads do not access and modify the same memory locations
simultaneously, which helps prevent race conditions.
8. Return the resulting matrix C.
• Finally, you return the matrix C as the result of the parallel matrix
multiplication operation.
MATRIX MULTIPLICATION
MATRIX MULTIPLICATION
RESULTS
1. Single-Threaded Execution:
• The multithreaded execution with one thread per row for the same
matrix size (200x200) reduced the execution time to approximately
0.0090 seconds.
• The multithreaded execution with one thread per cell for the same
matrix size (200x200) had a significantly longer execution time of
approximately 7.8864 seconds.
MATRIX MULTIPLICATION
MATRIX MULTIPLICATION
Future Scope
- Advanced parallelization methods like SIMD and GPU acceleration have the
potential to significantly enhance the performance of matrix multiplication.
Exploring and implementing these techniques can unlock the full potential of
modern hardware, enabling faster and more efficient matrix operations. Research
into optimizing algorithms for these platforms can yield substantial speedup,
especially for large-scale matrices.
- Adapting the number of threads to the available hardware resources and problem
size is crucial for achieving optimal performance. Developing a dynamic thread
management system that intelligently allocates and deallocates threads can enhance
efficiency, ensuring that resources are utilized effectively. This would make the
algorithm more adaptable to varying computational environments.
MATRIX MULTIPLICATION
Incorporating these future scope elements can lead to not only enhanced
performance and efficiency but also a more adaptable and versatile matrix
multiplication algorithm suitable for a wide range of computing environments and
hardware setups.
MATRIX MULTIPLICATION
CONCLUSION
MATRIX MULTIPLICATION
REFERENCES