CSE 1325 UTA Benchmarking Parallel Processing Using Java Program

CSE 1325: Object-Oriented ProgrammingUniversity of Texas at Arlington
Summer 2021
Dr. Alex Dillho
Extra Credit
Benchmarking Parallel Processing
In this assignment, you will be benchmarking the time it takes to perfrom tasks in parallel
using multiple threads versus using a single thread.
Matrix Multiplication
Matrix multiplication is an extremely common operation that is used in many highperformance computing applications. For example, articial neural networks perform
many matrix multiplications while computing output and while training. Your code
should benchmark this task, which means you will need to implement the operation. The
Java API does not provide this operation natively.
You can implement matrix multiplication following the denition as seen here:
https://en.wikipedia.org/wiki/Matrix_multiplication
Your implementation should end up as a nested for-loop with 3 loops total. That is, the
rst loop iterates over the rows of A using i. The second loop iterates over the columns
of B using j . The third loop sums the products of the values using k.
n
X
cij = aik bkj
k=1
For simplicity’s sake, you can assume the matrices
A
and
B
are square and of
This implies that the output matrix C will also be square and of the
same size as A and B .
the same size.
BONUS (10 points):
Implement matrix multiplication to work with non-
square matrices.
Multi-Threading
To compare the time it takes to compute batch operations of matrix multiplication using multiple threads versus a single thread, your program should be able to start many
threads. Each thread will perform matrix multiplication on two matrices and update a
shared 3D array. The user should be able to input the number of batch items to benchmark when the program starts, not to exceed 128 items.
CSE 1325: Extra Credit
Dillho
If the user enters 64, then your code should benchmark the time it takes to multiple 64
sets of matrices. The results would be stored in a 3D array. The user should also be
able to specify the size of the matrices.
If you implement the bonus above,
add input for the size of matrix A and size of matrix B.
As an example, if the user wanted to benchmark the time it takes to multiply 64 pairs of
square matrices that are 10×10, the resulting 3D output array should be of size 64×10×10.
Your program should launch 64 threads that will perform matrix multiplication on one
pair of matrices.
Benchmarking
When benchmarking linear versus parallel computation. You should use System.nanoTime()
as shown below.
long startTime = System.nanoTime();
// Perform some computation
long endTime = System.nanoTime();
long timeInMs = TimeUnit.NANOSECONDS.toMillis(endTime – startTime);
Your program will rst benchmark the time it takes to perform this on a single thread
before benchmarking the time it takes using multi-threading. Report both times to the
console before exiting.
Submission
Create a zip le using the name template LASTNAME_ID_EC.zip which includes the required .java les. Submit the zip le through Canvas.
2

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER