











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!












COSC 4397 โ Parallel ComputationEdgar Gabriel
2
COSC 4397 โ Parallel ComputationEdgar Gabriel
(^35)
8
4
4 4
3
4 4
4
COSC 4397 โ Parallel ComputationEdgar Gabriel
5
COSC 4397 โ Parallel ComputationEdgar Gabriel
(^51)
3
4
4 2 0 1
3
1
โ โ โ โ โ
โ
โ
โ โ โ โ โ
0 5
2
5 0 4 1
4 0 2 1
1 2 0 5 3
1 5 0 1
3
3 1 0
Arbitrary starting point r=
(^51)
3
4
4 2 0 1
3
1
node considered in the following search, sinceVertex is already in the spawning tree
7
COSC 4397 โ Parallel ComputationEdgar Gabriel
(^51)
3
4
4 2 0 1
3
1
(^51)
3
4
4 2 0 1
3
1
8
COSC 4397 โ Parallel ComputationEdgar Gabriel
(^51)
3
4
4 2 0 1
3
1
10
COSC 4397 โ Parallel ComputationEdgar Gabriel
int find_u ( int vt[N], int vtcount, int d[N] ){
int i, j, found;int current_min=MY_INF, current_minloc=-1;for ( i=0; i<N; i++ ) {
for (found = 0, j=0; j<vtcount; j++ ) {
if (i==vt[j]) found=1; } if (found) continue;if ( d[i] < current_min) {
current_minloc = i;current_min = d[i]; } } return current_minloc; }
11
COSC 4397 โ Parallel ComputationEdgar Gabriel
void update_d ( int d[N], int vt[N], int vtcount,
int N, int u, int a[N][N] )
int i, j, found;for ( i=0; i<N; i++ ) {
for ( found=0, j=0; j<vtcount; j++ ) {
if (i==vt[j]) found=1; } if (found) continue;d[i] = min (d[i], a[u][i]); } return; }
13
COSC 4397 โ Parallel ComputationEdgar Gabriel
int find_u ( int vt[N], int vtcount, int d ){
int min[2], gmin[2], i, rank;MPI_Comm_rank ( MPI_COMM_WORLD, &rank );min[0] = d;min[1] = rank;for ( i=0; i < vtcount; i++ ) {
if ( vt[i] == rank ) {
min[0] = MY_INF;break; } } MPI_Allreduce ( min, gmin, 1, MPI_2INT, MPI_MINLOC,
return gmin[1];}
14
16
COSC 4397 โ Parallel ComputationEdgar Gabriel
void update_d ( int *d, int *vt, int vtcount, int u,
int a[N] )
int i, rank;MPI_Comm_rank ( MPI_COMM_WORLD, &rank);for ( i=0; i < vtcount; i++ ) {
if ( vt[i] == rank ) {
return; } } d = min (d, a[u]);return; }
17
COSC 4397 โ Parallel ComputationEdgar Gabriel
d A
19
COSC 4397 โ Parallel ComputationEdgar Gabriel
void update_d ( int *d, int *vt, int vtcount, int u,
int a[N] )
int i, j, rank, found;for ( i=0; i<nx; i++ ) {
for ( found=0, j=0; j<vtcount; j++ ) {
if ((
cxnx+i*
)==vt[j]) {
found=1; } } if (found) continue;d[i] = my_min (d[i], a[u][i]); } return; }