Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ALP4-Tutorials
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
Package registry
Container 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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mactavish96
ALP4-Tutorials
Commits
e7b4ada1
Commit
e7b4ada1
authored
2 years ago
by
Chao Zhan
Browse files
Options
Downloads
Patches
Plain Diff
Revert "add solution to round trip example"
This reverts commit
44af9246
.
parent
ec70034e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
exercises/MPI_examples/round_trip/round_trip.c
+4
-8
4 additions, 8 deletions
exercises/MPI_examples/round_trip/round_trip.c
with
4 additions
and
8 deletions
exercises/MPI_examples/round_trip/round_trip.c
+
4
−
8
View file @
e7b4ada1
...
@@ -13,25 +13,21 @@ int main(int argc, char** argv) {
...
@@ -13,25 +13,21 @@ int main(int argc, char** argv) {
// of the special case when you are the first process to prevent deadlock.
// of the special case when you are the first process to prevent deadlock.
if
(
rank
!=
0
)
{
if
(
rank
!=
0
)
{
MPI_Recv
(
&
token
,
1
,
MPI_INT
,
rank
-
1
,
0
,
MPI_COMM_WORLD
,
// TODO: Receive the token from the previous process in the ring
MPI_STATUS_IGNORE
);
printf
(
"Process %d received token %d from process %d
\n
"
,
rank
,
token
,
printf
(
"Process %d received token %d from process %d
\n
"
,
rank
,
token
,
rank
-
1
);
rank
-
1
);
}
else
{
}
else
{
// Set the token's value if you are process 0
// TODO: Set the token's value if you are process 0
token
=
1024
;
}
}
MPI_Send
(
&
token
,
1
,
MPI_INT
,
(
rank
+
1
)
%
num_procs
,
0
,
// TODO: send the token to the next process in the ring
MPI_COMM_WORLD
);
// Now process 0 can receive from the last process. This makes sure that at
// Now process 0 can receive from the last process. This makes sure that at
// least one MPI_Send is initialized before all MPI_Recvs (again, to prevent
// least one MPI_Send is initialized before all MPI_Recvs (again, to prevent
// deadlock)
// deadlock)
if
(
rank
==
0
)
{
if
(
rank
==
0
)
{
MPI_Recv
(
&
token
,
1
,
MPI_INT
,
rank
-
1
,
0
,
MPI_COMM_WORLD
,
// TODO: Receive the token from the last process in the ring
MPI_STATUS_IGNORE
);
printf
(
"Process %d received token %d from process %d
\n
"
,
rank
,
token
,
printf
(
"Process %d received token %d from process %d
\n
"
,
rank
,
token
,
num_procs
-
1
);
num_procs
-
1
);
}
}
...
...
This diff is collapsed.
Click to expand it.
mactavish96
@mactavish96
mentioned in commit
f7719cf6
·
2 years ago
mentioned in commit
f7719cf6
mentioned in commit f7719cf6fe7fb91443b523838de32970ffb8130b
Toggle commit list
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