Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpi-par
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alesanc
mpi-par
Commits
e3c30b4d
Commit
e3c30b4d
authored
Jun 10, 2024
by
alexgara
Browse files
Options
Downloads
Patches
Plain Diff
Fix: dead lock
parent
fdf914c2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
align_mpi.c
+38
-25
38 additions, 25 deletions
align_mpi.c
with
38 additions
and
25 deletions
align_mpi.c
+
38
−
25
View file @
e3c30b4d
...
...
@@ -27,7 +27,6 @@
/* TAGS for comunnications */
#define TAG_NO_COMPLETE 69
#define TAG_END 8
#define TAG_SEND_PAT_FOUND 5
#define TAG_SEND_CHECKSUM 10
#define END_SIG -2
...
...
@@ -391,7 +390,6 @@ int main(int argc, char *argv[]) {
unsigned
long
pat
;
MPI_Request
request
;
MPI_Status
status
;
int
send_to_continue_flag
=
0
;
...
...
@@ -419,11 +417,14 @@ int main(int argc, char *argv[]) {
if
(
(
start
+
ind
>=
my_size
)
&&
(
rank
!=
nprocs
-
1
)){
envio_array
[
0
]
=
my_begin
+
start
;
envio_array
[
1
]
=
ind
-
1
;
//TODO check if its -1 or normal
envio_array
[
1
]
=
ind
;
//Last position checked
envio_array
[
2
]
=
pat
;
//Envio el parton para que continue el siguente que le toca
MPI_CHEK_FUCKTION
(
MPI_Isend
(
envio_array
,
3
,
MPI_UNSIGNED_LONG
,
rank
+
1
,
TAG_NO_COMPLETE
,
MPI_COMM_WORLD
,
&
request
));
printf
(
"
\n
ENVIA(%d) rank=%d a rank+1=%d pat=%lu
\n
"
,
(
1
),
rank
,
rank
+
1
,
envio_array
[
2
]);
fflush
(
stdout
);
send_to_continue_flag
=
1
;
break
;
}
...
...
@@ -449,7 +450,9 @@ int main(int argc, char *argv[]) {
envio_array
[
0
]
=
(
unsigned
long
)
END_SIG
;
envio_array
[
1
]
=
(
unsigned
long
)
END_SIG
;
envio_array
[
2
]
=
(
unsigned
long
)
END_SIG
;
MPI_CHEK_FUCKTION
(
MPI_Isend
(
envio_array
,
3
,
MPI_UNSIGNED_LONG
,
rank
+
1
,
TAG_END
,
MPI_COMM_WORLD
,
&
request
));
MPI_CHEK_FUCKTION
(
MPI_Isend
(
envio_array
,
3
,
MPI_UNSIGNED_LONG
,
rank
+
1
,
TAG_NO_COMPLETE
,
MPI_COMM_WORLD
,
&
request
));
printf
(
"
\n
ENVIA FIN rank=%d a rank+1=%d
\n
"
,
rank
,
rank
+
1
);
fflush
(
stdout
);
}
MPI_CHEK_FUCKTION
(
MPI_Barrier
(
MPI_COMM_WORLD
));
...
...
@@ -461,20 +464,37 @@ int main(int argc, char *argv[]) {
int
start_r
,
pat_r
,
length_r
;
while
(
1
&&
(
rank
!=
0
)){
//First check if the previous process has finished & have nothing more to do
MPI_CHEK_FUCKTION
(
MPI_Wait
(
&
request
,
MPI_STATUS_IGNORE
));
MPI_CHEK_FUCKTION
(
MPI_Recv
(
recibo_array
,
3
,
MPI_UNSIGNED_LONG
,
rank
-
1
,
MPI_ANY_TAG
,
MPI_COMM_WORLD
,
&
status
));
printf
(
"
\n
RECIBE(%d) rank=%d desde rank-1=%d pat=%lu con TAG=%d
\n
"
,
(
status
.
MPI_TAG
==
TAG_END
)
,
rank
,
status
.
MPI_SOURCE
,
recibo_array
[
2
],
status
.
MPI_TAG
);
//else continue because the rank-1 send work to do
start_r
=
recibo_array
[
0
];
//Were the patter was start to be detected
length_r
=
recibo_array
[
1
];
//Lenght already checked
pat_r
=
recibo_array
[
2
];
//Pattern searching
//THEN its end sigal the first so no more thing to do
if
(
status
.
MPI_TAG
==
TAG_END
)
break
;
if
(
pat_r
==
(
unsigned
long
)
END_SIG
){
printf
(
"
\n
GET FIN rank=%d desde rank-1=%d
\n
"
,
rank
,
status
.
MPI_SOURCE
);
fflush
(
stdout
);
if
(
rank
!=
nprocs
-
1
){
envio_array
[
0
]
=
END_SIG
;
envio_array
[
1
]
=
END_SIG
;
envio_array
[
2
]
=
END_SIG
;
MPI_CHEK_FUCKTION
(
MPI_Isend
(
envio_array
,
3
,
MPI_UNSIGNED_LONG
,
rank
+
1
,
TAG_NO_COMPLETE
,
MPI_COMM_WORLD
,
&
request
));
printf
(
"
\n
ENVIA FIN rank=%d a rank+1=%d
\n
"
,
rank
,
rank
+
1
);
fflush
(
stdout
);
}
break
;
}
else
{
printf
(
"
\n
RECIBE rank=%d desde rank-1=%d pat=%lu con TAG=%d
\n
"
,
rank
,
status
.
MPI_SOURCE
,
recibo_array
[
2
],
status
.
MPI_TAG
);
fflush
(
stdout
);
}
//else continue because the rank-1 send work to do
start_r
=
recibo_array
[
0
];
length_r
=
recibo_array
[
1
];
pat_r
=
recibo_array
[
2
];
//search for the pattern in my space
//we only check like start = 0 / because of it will be a continuos pattern that start ranks before this
...
...
@@ -482,16 +502,17 @@ int main(int argc, char *argv[]) {
//The pattern gets out of this region so send to the next rank
if
(
(
ind
>=
my_size
)
&&
(
rank
!=
nprocs
-
1
)){
envio_array
[
0
]
=
start_r
;
envio_array
[
1
]
=
(
ind
-
1
)
+
length_r
;
envio_array
[
1
]
=
ind
+
length_r
;
//Length already checked
envio_array
[
2
]
=
pat_r
;
//Send to the next rank
MPI_CHEK_FUCKTION
(
MPI_Isend
(
envio_array
,
3
,
MPI_UNSIGNED_LONG
,
rank
+
1
,
TAG_NO_COMPLETE
,
MPI_COMM_WORLD
,
&
request
));
//printf("\n ENVIA(%d) rank=%d a rank+1=%d pat=%lu\n", (1), rank, rank+1, envio_array[2]);
printf
(
"
\n
ENVIA(%d) rank=%d a rank+1=%d pat=%lu
\n
"
,
(
1
),
rank
,
rank
+
1
,
envio_array
[
2
]);
fflush
(
stdout
);
send_to_continue_flag
=
1
;
break
;
}
else
if
(
sequence
[
ind
]
!=
pattern
[
pat_r
][
ind
+
length_r
]
)
break
;
else
if
(
sequence
[
ind
]
!=
pattern
[
pat_r
][
ind
+
(
length_r
-
1
)
]
)
break
;
}
//Check if is outside of the loop and the pattern continue in other
...
...
@@ -506,17 +527,9 @@ int main(int argc, char *argv[]) {
}
}
printf
(
"
\n
TERMINO rank=%d LLEGA pat=%lu, sig=%d
\n
"
,
rank
,
pat
,
rank
+
1
);
fflush
(
stdout
);
//If its outside then send signal to the next that there is no more patterns
if
(
rank
!=
0
){
envio_array
[
0
]
=
END_SIG
;
envio_array
[
1
]
=
END_SIG
;
envio_array
[
2
]
=
END_SIG
;
MPI_CHEK_FUCKTION
(
MPI_Isend
(
envio_array
,
3
,
MPI_UNSIGNED_LONG
,
rank
+
1
,
TAG_END
,
MPI_COMM_WORLD
,
&
request
));
}
MPI_CHEK_FUCKTION
(
MPI_Barrier
(
MPI_COMM_WORLD
));
printf
(
"==================
\n
rank=%d LLEGA pat=%lu, sig=%d
\n
"
,
rank
,
pat
,
rank
+
1
);
fflush
(
stdout
);
unsigned
long
*
recive_pat_found
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment