Title: COMP309/509 - Lecture 17 class: middle, center, inverse

COMP309/509 - Parallel and Distributed Computing

Lecture 17 - PVM Matrix Multiplication

By Mitchell Welch

University of New England


Reading


Summary


Matrix Multiplication on a Ring


Matrix Multiplication on a Ring


Matrix Multiplication on a Ring


Matrix Multiplication on a Ring


Matrix Multiplication on a Ring

int A[M+1], B[M+1], C[M+1];
for(j = 1; j < M + 1; j++)
  C[j] = A[i] * B[j];

Matrix Multiplication on a Ring

Examples>prc
Usage: prc matrixA matrixB matrixC M
Examples>prr
Usage: prr matrixA matrixB matrixC M
Examples>

Matrix Multiplication on a Ring


Matrix Example Code


Matrix Example Code

turing.une.edu.au.Examples> mkIdentityMatrix I 4
Finished writing I
turing.une.edu.au.Examples> mkRandomMatrix R 4
Finished writing R
turing.une.edu.au.Examples> prc I R IRrc 4
turing.une.edu.au.Examples> diff R IRrc
turing.une.edu.au.Examples>

Matrix Example Code


turing.une.edu.au.Examples> getMatrix R 4
R[1][1] = 1351
R[1][2] = 1386
R[1][3] = 1369
R[1][4] = 969
R[2][1] = 1780
R[2][2] = 1381
R[2][3] = 437
R[2][4] = 165
R[3][1] = 1327
R[3][2] = 981
R[3][3] = 195
R[3][4] = 1376
R[4][1] = 313
R[4][2] = 1283
R[4][3] = 1965
R[4][4] = 2026
Finished reading  R

Matrix Example Code


turing.une.edu.au.Examples> getMatrix IRrc 4
IRrc[1][1] = 1351
IRrc[1][2] = 1386
IRrc[1][3] = 1369
IRrc[1][4] = 969
IRrc[2][1] = 1780
IRrc[2][2] = 1381
IRrc[2][3] = 437
IRrc[2][4] = 165
IRrc[3][1] = 1327
IRrc[3][2] = 981
IRrc[3][3] = 195
IRrc[3][4] = 1376
IRrc[4][1] = 313
IRrc[4][2] = 1283
IRrc[4][3] = 1965
IRrc[4][4] = 2026
Finished reading  IRrc
turing.une.edu.au.Examples>

Matrix Example Code


test_u_run: 
#!/usr/bin/perl -w

print "Enter the size of the matrix ( = nprocs in ring ): ";
my $nprocs = <>;
chomp($nprocs);
`rm -f I R RIrr RIrc IRrr IRrc`;
`./mkRandomMatrix R $nprocs`;
`./mkIdentityMatrix I $nprocs`;

p_check('./prc', 'I', 'R', 'IRrc', 'R', $nprocs);
p_check('./prr', 'I', 'R', 'IRrr', 'R', $nprocs);
p_check('./prc', 'R', 'I', 'RIrc', 'R', $nprocs);
p_check('./prr', 'R', 'I', 'RIrr', 'R', $nprocs);

sub p_check {
    my($exe, $a, $b, $c, $r, $nprocs) = @_;
    `$exe $a $b $c $nprocs`;
    my $diff = `diff $r $c`;
    if($diff){
    print "$r and $c differ\n";
    } else {
    print "$r and $c agree\n";
    }
}

Debugging


Debugging


#define VERBOSE 1

...

if(VERBOSE)fprintf(stderr, "Yada Yada Yada\n");

Summary


class: middle, center, inverse

Questions?


Reading