Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
SWIFT
SWIFTsim
Commits
1e2e25f2
Commit
1e2e25f2
authored
Nov 2, 2018
by
Pedro Gonnet
Browse files
Options
Downloads
Patches
Plain Diff
remove test for concurrent MPI_Waitany, this is WAI.
parent
87cba124
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!659
Parallel rebuild2
,
!655
Parallel rebuild
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/testParallelMpiWaitany.c
+0
-118
0 additions, 118 deletions
tests/testParallelMpiWaitany.c
with
0 additions
and
118 deletions
tests/testParallelMpiWaitany.c
deleted
100644 → 0
+
0
−
118
View file @
87cba124
// Test MPI_Waitany in parallel.
//
// This test has each rank send each other rank an array of random ints with
// asynchronous sends and receives. The program spawns as many threads
// as it has incoming receives, which all call MPI_Waitany concurrently.
//
// Compile with:
// mpicc testParallelMpiWaitany.c -g -Wall
//
// Run with:
// mpirun --oversubscribe -n 100 ./a.out
#include
<mpi.h>
#include
<pthread.h>
#include
<stdio.h>
#include
<stdlib.h>
#define BUFFER_SIZE 1000
struct
thread_func_data
{
int
num_ranks
;
MPI_Request
*
requests
;
};
void
*
thread_func
(
void
*
data_in
)
{
const
struct
thread_func_data
*
data
=
(
struct
thread_func_data
*
)
data_in
;
// Wait on any of the requests.
int
index
=
MPI_UNDEFINED
;
MPI_Status
status
;
const
int
res
=
MPI_Waitany
(
data
->
num_ranks
,
data
->
requests
,
&
index
,
&
status
);
// Make sure all went well.
if
(
res
!=
MPI_SUCCESS
)
{
int
len
=
1024
;
char
error_message
[
len
];
MPI_Error_string
(
res
,
error_message
,
&
len
);
fprintf
(
stderr
,
"MPI_Waitany failed: %s
\n
"
,
error_message
);
}
if
(
index
==
MPI_UNDEFINED
)
{
fprintf
(
stderr
,
"MPI_Waitany didn't return a valid index.
\n
"
);
}
return
NULL
;
}
int
main
(
int
argc
,
char
**
argv
)
{
// Initialize the MPI environment.
int
provided
;
MPI_Init_thread
(
&
argc
,
&
argv
,
MPI_THREAD_MULTIPLE
,
&
provided
);
if
(
provided
!=
MPI_THREAD_MULTIPLE
)
{
fprintf
(
stderr
,
"MPI_Init_thread does not provide MPI_THREAD_MULTIPLE.
\n
"
);
abort
();
}
// Get the number of processes.
int
num_ranks
;
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
num_ranks
);
// Get the rank of the process.
int
rank
;
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
rank
);
printf
(
"Rank %02i is ready.
\n
"
,
rank
);
// Create a data buffers, fill the outgoing one with random numbers.
int
*
data_out
=
malloc
(
sizeof
(
int
)
*
BUFFER_SIZE
);
for
(
int
k
=
0
;
k
<
BUFFER_SIZE
;
k
++
)
{
data_out
[
k
]
=
rand
();
}
int
*
data_in
=
malloc
(
sizeof
(
int
)
*
BUFFER_SIZE
);
// Create the request objects.
MPI_Request
requests_in
[
num_ranks
];
MPI_Request
requests_out
[
num_ranks
];
// Asynchronously send the buffer to all other ranks.
for
(
int
rid
=
0
;
rid
<
num_ranks
;
rid
++
)
{
if
(
rid
!=
rank
)
{
MPI_Isend
(
data_out
,
BUFFER_SIZE
,
MPI_INT
,
rid
,
/*tag=*/
0
,
MPI_COMM_WORLD
,
&
requests_out
[
rid
]);
}
else
{
requests_out
[
rid
]
=
MPI_REQUEST_NULL
;
}
}
// Launch the asynchronous receives.
for
(
int
rid
=
0
;
rid
<
num_ranks
;
rid
++
)
{
if
(
rid
!=
rank
)
{
MPI_Irecv
(
data_in
,
BUFFER_SIZE
,
MPI_INT
,
rid
,
/*tag=*/
0
,
MPI_COMM_WORLD
,
&
requests_in
[
rid
]);
}
else
{
requests_in
[
rid
]
=
MPI_REQUEST_NULL
;
}
}
// Launch the threads that will call MPI_Waitany.
struct
thread_func_data
thread_data
=
{
num_ranks
,
requests_in
};
pthread_t
threads
[
num_ranks
-
1
];
for
(
int
tid
=
0
;
tid
<
num_ranks
-
1
;
tid
++
)
{
pthread_create
(
&
threads
[
tid
],
/*attr=*/
NULL
,
thread_func
,
&
thread_data
);
}
// Wait for all the threads to be done.
for
(
int
tid
=
0
;
tid
<
num_ranks
-
1
;
tid
++
)
{
pthread_join
(
threads
[
tid
],
/*value_ptr=*/
NULL
);
}
// Just to be sure, make sure the sends are all done.
MPI_Waitall
(
num_ranks
,
requests_out
,
MPI_STATUSES_IGNORE
);
// Clean up allocated memory.
free
(
data_in
);
free
(
data_out
);
// Finalize the MPI environment.
MPI_Finalize
();
printf
(
"Rank %02i is done.
\n
"
,
rank
);
}
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
sign in
to comment