Question
Write a C console program of the matrix multiplication algorithm ( [A]x[B] = [C] ) for double precision data types. Instrument and monitor and measure
Write a C console program of the matrix multiplication algorithm ( [A]x[B] = [C] ) for double precision data types. Instrument and monitor and measure execution time for the computation.
a) Your C program should be single threaded, and sequential. All matrices [A], [B], and [C] are to be square, i.e. same number of rows and columns Execution should be scalable and be able to handle matrix dimension N x N , from 4 x 4, 16x16, 32x32, 64x64, 128x128, 256x256, 512x512, 1024x1024 and 2048x2048. Set the matrix dimension, N, number of accuracy improvement loops, and system CPU clock speed using DEFINE statements. Use a random number generator to fill the random data into the matrices.
Compiler optimizations should be configured for full optimization ( -O3 in gcc or /Ox in MS VS). Comment your code to explain what it is doing. As in programming exercise 1 and 2, make your code portable. Using malloc is the preferred, and recommended method.
b) You should use the time.h header file library, and either the time() or clock() timing functions to capture the start and end execution times for your benchmark. You will need two nested loops to perform the matrix multiplication, and in addition, as in PE2, you will need to use a 3rd , outer accuracy improvement loop. Adjust the total number of iterations of your inner and outer accuracy improvement loops so that total execution time is approximately constant as you vary the dimensions of your A, B and C matrices change from 4x4 to 2048x2048.
c) Your console program should print out ( using formatted printf commands )
1) your name and the programming exercise number
2) Processor name
3) Processor Clock frequency
4) the square matrix dimension, N
5) Compiler optimization setting
6) # of accuracy loops,
7) Algorithmically evaluated number of arithmetic operations required to compute the NxN multiplication
8) total measured execution time,
9) evaluated execution time for the NxN matrix,
10) evaluated execution time per matrix element ,
11) evaluated execution time per arithmetic operation,
12) evaluated Cycles per arithmetic Op, CpOps
13) evaluated Ops per Cycle, and
14) evaluated double precision operations per second
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started