# MXV Matrix Vector Multiplication Timings

MXV is a C program which sets up several matrix vector multiplication problems y=A*x, and carries them out using

• Nested FOR I, FOR J loops, A stored as a vector;
• Nested FOR J, FOR I loops, A stored as a vector;

The user is allowed to specify M and N, the number of matrix rows and columns.

### Usage:

mxv m n
where
• m is the number of matrix rows;
• n is the number of matrix columns;

### Sample Results:

```          M        N       FLOP  FORIFORJ  FORJFORI

10       10        100       9      11

10      100      1,000      26      21
100       10      1,000      23      25

10    1,000     10,000      33      30
100      100     10,000      29      34
1,000       10     10,000      25      31

10   10,000    100,000      19      26
100    1,000    100,000      24      34
1,000      100    100,000      24      35
10,000       10    100,000      23      32

10  100,000  1,000,000      17      27
100   10,000  1,000,000       7      49
1,000    1,000  1,000,000      17      34
10,000      100  1,000,000      26      42
100,000       10  1,000,000      23      31
```

### Languages:

MXV is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

LINPACK_BENCH, a C program which measures the time needed to factor and solve a "large" (N=1000) dense linear system of equations, and is used as a benchmark.

MATMUL, a FORTRAN90 program which is an interactive matrix multiplication benchmark program.

MXM, a C program which sets up a matrix multiplication problem A=B*C of arbitrary size, and compares the time required for IJK, IKJ, JIK, JKI, KIJ and KJI orderings of the loops.

MXV_OPENMP, a C program which compares the performance of plain vanilla Fortran and the FORTRAN90 intrinsic routine MATMUL, for the matrix multiplication problem y=A*x, with and without parallelization by OpenMP.

SUM_MILLION, a C program which sums the integers from 1 to 1,000,000, as a demonstration of how to rate a computer's speed;

TIMER, C programs which demonstrate how to compute CPU time or elapsed time.

### Reference:

1. John Burkardt, Paul Puglielli,
Pittsburgh Supercomputing Center,
MATMUL: An Interactive Matrix Multiplication Benchmark

### Source Code:

• mxv.c, the source code.
• mxv.sh, commands to compile and link the source code.

### List of Routines:

• MAIN is the main program for MXV.
• CPU_TIME returns the current reading on the CPU clock.
• MATGEN generates a random matrix A and vector X.
• MXV_FORIFORJ computes y = A * x, using FOR I, FOR J loops.
• MXV_FORJFORI computes y = A * x, using FOR J, FOR I loops.
• TIMESTAMP prints the current YMDHMS date as a time stamp.

You can go up one level to the C source codes.

Last revised on 23 May 2008.