Subversion Repositories programming

Rev

Rev 326 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 326 Rev 327
Line -... Line 1...
-
 
1
/* proj3_5.c - implements the APSP algorithm for a matrix of size 5x5
-
 
2
 *             as provided in the project description.
-
 
3
 *
-
 
4
 * Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
-
 
5
 */
-
 
6
 
-
 
7
 
1
#include <stdio.h>
8
#include <stdio.h>
2
#include <limits.h>
9
#include <limits.h>
3
#include <mpi.h>
10
#include <mpi.h>
4
 
11
 
5
const int ROOT_NODE = 0;
12
const int ROOT_NODE = 0;
Line 99... Line 106...
99
    }
106
    }
100
}
107
}
101
 
108
 
102
int main (int argc, char *argv[])
109
int main (int argc, char *argv[])
103
{
110
{
104
    const int n = 4;
111
    const int n = 5;
105
    int *b, *c;
112
    int *b, *c;
106
    int i, j, k, temp, t;
113
    int i, j, k, temp, t;
107
    MPI_Status status;
114
    MPI_Status status;
108
 
115
 
109
    /* Get all of the necessary info for each process */
116
    /* Get all of the necessary info for each process */
Line 135... Line 142...
135
        /* Initialize values */
142
        /* Initialize values */
136
        for (i=0; i<n; i++)
143
        for (i=0; i<n; i++)
137
            for (j=0; j<n; j++)
144
            for (j=0; j<n; j++)
138
                b[i*n+j] = INT_MAX;
145
                b[i*n+j] = INT_MAX;
139
 
146
 
140
        b[0] = 0;
147
        b[1] = 5;
141
        b[1] = 2;
148
        b[2] = 2;
142
        b[2] = INT_MAX;
-
 
143
        b[3] = 10;
-
 
144
 
149
 
145
        b[4] = 2;
-
 
146
        b[5] = 0;
150
        b[8] = 8;
-
 
151
 
147
        b[6] = 2;
152
        b[11] = 1;
148
        b[7] = INT_MAX;
-
 
149
 
153
 
150
        b[8]  = INT_MAX;
-
 
151
        b[9]  = 2;
154
        b[19] = 9;
-
 
155
 
152
        b[10] = 0;
156
        b[20] = 6;
153
        b[11] = 3;
157
        b[22] = 2;
154
 
158
 
155
        b[12] = 10;
159
        /* Force b[i][i] = 0 */
156
        b[13] = INT_MAX;
160
        for (i=0; i<n; i++)
157
        b[14] = 3;
-
 
158
        b[15] = 0;
161
            b[i*n+i] = 0; 
159
 
162
 
160
        if (n<=100)
163
        if (n<=100)
161
            print_matrix (b, n, "Input Matrix:");
164
            print_matrix (b, n, "Input Matrix:");
162
        else
165
        else
163
        {
166
        {