Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Weinzierl
teaMPI
Commits
b3b9bb33
Commit
b3b9bb33
authored
Aug 16, 2018
by
Ben Hazelwood
Browse files
Realised I don't need to remap the status anymore! And a final (probably) tidy up
parent
4d204e8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/Wrapper.cpp
View file @
b3b9bb33
...
@@ -8,22 +8,14 @@
...
@@ -8,22 +8,14 @@
#include
"Timing.h"
#include
"Timing.h"
int
MPI_Init
(
int
*
argc
,
char
***
argv
)
{
int
MPI_Init
(
int
*
argc
,
char
***
argv
)
{
int
err
=
0
;
int
err
=
PMPI_Init
(
argc
,
argv
);
err
|=
PMPI_Init
(
argc
,
argv
);
initialiseTMPI
();
initialiseTMPI
();
return
err
;
return
err
;
}
}
int
MPI_Init_thread
(
int
*
argc
,
char
***
argv
,
int
required
,
int
*
provided
)
{
int
MPI_Init_thread
(
int
*
argc
,
char
***
argv
,
int
required
,
int
*
provided
)
{
int
err
=
0
;
int
err
=
PMPI_Init_thread
(
argc
,
argv
,
required
,
provided
);
err
|=
PMPI_Init_thread
(
argc
,
argv
,
required
,
provided
);
initialiseTMPI
();
initialiseTMPI
();
return
err
;
return
err
;
}
}
...
@@ -35,220 +27,101 @@ int MPI_Is_thread_main(int* flag) {
...
@@ -35,220 +27,101 @@ int MPI_Is_thread_main(int* flag) {
int
MPI_Comm_rank
(
MPI_Comm
comm
,
int
*
rank
)
{
int
MPI_Comm_rank
(
MPI_Comm
comm
,
int
*
rank
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
*
rank
=
getTeamRank
();
*
rank
=
getTeamRank
();
// logInfo("Returning rank " << *rank);
return
MPI_SUCCESS
;
return
MPI_SUCCESS
;
}
}
int
MPI_Comm_size
(
MPI_Comm
comm
,
int
*
size
)
{
int
MPI_Comm_size
(
MPI_Comm
comm
,
int
*
size
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
*
size
=
getTeamSize
();
*
size
=
getTeamSize
();
// logInfo("Returning size " << *size);
return
MPI_SUCCESS
;
return
MPI_SUCCESS
;
}
}
int
MPI_Send
(
const
void
*
buf
,
int
count
,
MPI_Datatype
datatype
,
int
dest
,
int
MPI_Send
(
const
void
*
buf
,
int
count
,
MPI_Datatype
datatype
,
int
dest
,
int
tag
,
MPI_Comm
comm
)
{
int
tag
,
MPI_Comm
comm
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Send
(
buf
,
count
,
datatype
,
dest
,
tag
,
getTeamComm
());
int
err
=
0
;
logInfo
(
"Send to rank "
<<
dest
<<
"/"
<<
mapTeamToWorldRank
(
dest
)
<<
" with tag "
<<
tag
);
err
|=
PMPI_Send
(
buf
,
count
,
datatype
,
dest
,
tag
,
getTeamComm
());
logInfo
(
"Send to rank "
<<
dest
<<
"/"
<<
mapTeamToWorldRank
(
dest
)
<<
" with tag "
<<
tag
);
return
err
;
return
err
;
}
}
int
MPI_Recv
(
void
*
buf
,
int
count
,
MPI_Datatype
datatype
,
int
source
,
int
tag
,
int
MPI_Recv
(
void
*
buf
,
int
count
,
MPI_Datatype
datatype
,
int
source
,
int
tag
,
MPI_Comm
comm
,
MPI_Status
*
status
)
{
MPI_Comm
comm
,
MPI_Status
*
status
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Recv
(
buf
,
count
,
datatype
,
source
,
tag
,
getTeamComm
(),
status
);
int
err
=
0
;
logInfo
(
"Receive from rank "
<<
source
<<
"/"
<<
mapTeamToWorldRank
(
source
)
<<
" with tag "
<<
tag
);
err
|=
PMPI_Recv
(
buf
,
count
,
datatype
,
source
,
tag
,
getTeamComm
(),
status
);
remapStatus
(
status
);
logInfo
(
"Receive from rank "
<<
source
<<
"/"
<<
mapTeamToWorldRank
(
source
)
<<
" with tag "
<<
tag
);
return
err
;
return
err
;
}
}
int
MPI_Isend
(
const
void
*
buf
,
int
count
,
MPI_Datatype
datatype
,
int
dest
,
int
MPI_Isend
(
const
void
*
buf
,
int
count
,
MPI_Datatype
datatype
,
int
dest
,
int
tag
,
MPI_Comm
comm
,
MPI_Request
*
request
)
{
int
tag
,
MPI_Comm
comm
,
MPI_Request
*
request
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Isend
(
buf
,
count
,
datatype
,
dest
,
tag
,
getTeamComm
(),
request
);
int
err
=
0
;
logInfo
(
"Isend to rank "
<<
dest
<<
"/"
<<
mapTeamToWorldRank
(
dest
)
<<
" with tag "
<<
tag
);
err
|=
PMPI_Isend
(
buf
,
count
,
datatype
,
dest
,
tag
,
getTeamComm
(),
request
);
logInfo
(
"Isend to rank "
<<
dest
<<
"/"
<<
mapTeamToWorldRank
(
dest
)
<<
" with tag "
<<
tag
);
return
err
;
return
err
;
}
}
int
MPI_Irecv
(
void
*
buf
,
int
count
,
MPI_Datatype
datatype
,
int
source
,
int
tag
,
int
MPI_Irecv
(
void
*
buf
,
int
count
,
MPI_Datatype
datatype
,
int
source
,
int
tag
,
MPI_Comm
comm
,
MPI_Request
*
request
)
{
MPI_Comm
comm
,
MPI_Request
*
request
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Irecv
(
buf
,
count
,
datatype
,
source
,
tag
,
getTeamComm
(),
request
);
int
err
=
0
;
logInfo
(
"Receive from rank "
<<
source
<<
"/"
<<
mapTeamToWorldRank
(
source
)
<<
" with tag "
<<
tag
);
err
|=
PMPI_Irecv
(
buf
,
count
,
datatype
,
source
,
tag
,
getTeamComm
(),
request
);
logInfo
(
"Receive from rank "
<<
source
<<
"/"
<<
mapTeamToWorldRank
(
source
)
<<
" with tag "
<<
tag
);
return
err
;
return
err
;
}
}
int
MPI_Wait
(
MPI_Request
*
request
,
MPI_Status
*
status
)
{
int
MPI_Wait
(
MPI_Request
*
request
,
MPI_Status
*
status
)
{
int
err
=
0
;
logInfo
(
"Wait initialised"
);
logInfo
(
"Wait initialised"
);
int
err
=
PMPI_Wait
(
request
,
status
);
err
|=
PMPI_Wait
(
request
,
status
);
logInfo
(
"Wait completed"
);
remapStatus
(
status
);
logInfo
(
"Wait completed "
<<
")"
);
return
err
;
return
err
;
}
}
int
MPI_Waitall
(
int
count
,
MPI_Request
array_of_requests
[],
MPI_Status
array_of_statuses
[])
{
int
MPI_Waitall
(
int
count
,
MPI_Request
array_of_requests
[],
MPI_Status
array_of_statuses
[])
{
int
err
=
0
;
logInfo
(
"Waitall initialised with "
<<
count
<<
" requests"
);
logInfo
(
"Waitall initialised with "
<<
count
<<
" requests"
);
int
err
=
PMPI_Waitall
(
count
,
array_of_requests
,
array_of_statuses
);
err
|=
PMPI_Waitall
(
count
,
array_of_requests
,
array_of_statuses
);
if
(
array_of_statuses
!=
MPI_STATUSES_IGNORE
)
{
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
remapStatus
(
&
array_of_statuses
[
i
]);
}
}
logInfo
(
"Waitall completed with "
<<
count
<<
" requests"
);
logInfo
(
"Waitall completed with "
<<
count
<<
" requests"
);
return
err
;
return
err
;
}
}
int
MPI_Test
(
MPI_Request
*
request
,
int
*
flag
,
MPI_Status
*
status
)
{
int
MPI_Test
(
MPI_Request
*
request
,
int
*
flag
,
MPI_Status
*
status
)
{
int
err
=
0
;
int
err
=
PMPI_Test
(
request
,
flag
,
status
);
logInfo
(
"Test completed (FLAG="
<<
*
flag
<<
",STATUS_SOURCE="
<<
status
->
MPI_SOURCE
<<
",STATUS_TAG="
<<
status
->
MPI_TAG
<<
")"
);
err
|=
PMPI_Test
(
request
,
flag
,
status
);
if
(
*
flag
)
{
remapStatus
(
status
);
}
logInfo
(
"Test completed ("
<<
"FLAG="
<<
*
flag
<<
",STATUS_SOURCE="
<<
status
->
MPI_SOURCE
<<
",STATUS_TAG="
<<
status
->
MPI_TAG
<<
")"
);
return
err
;
return
err
;
}
}
int
MPI_Probe
(
int
source
,
int
tag
,
MPI_Comm
comm
,
MPI_Status
*
status
)
{
int
MPI_Probe
(
int
source
,
int
tag
,
MPI_Comm
comm
,
MPI_Status
*
status
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
0
;
logInfo
(
"Probe initialised (SOURCE="
<<
source
<<
",TAG="
<<
tag
<<
")"
);
int
err
=
PMPI_Probe
(
source
,
tag
,
getTeamComm
(),
status
);
logInfo
(
logInfo
(
"Probe finished (SOURCE="
<<
mapTeamToWorldRank
(
source
)
<<
",TAG="
<<
tag
<<
",STATUS_SOURCE="
<<
status
->
MPI_SOURCE
<<
",STATUS_TAG="
<<
status
->
MPI_TAG
<<
")"
);
"Probe initialised (SOURCE="
<<
source
<<
",TAG="
<<
tag
<<
")"
);
err
|=
PMPI_Probe
(
source
,
tag
,
getTeamComm
(),
status
);
remapStatus
(
status
);
logInfo
(
"Probe finished ("
<<
"SOURCE="
<<
mapTeamToWorldRank
(
source
)
<<
",TAG="
<<
tag
<<
",STATUS_SOURCE="
<<
status
->
MPI_SOURCE
<<
",STATUS_TAG="
<<
status
->
MPI_TAG
<<
")"
);
return
err
;
return
err
;
}
}
int
MPI_Iprobe
(
int
source
,
int
tag
,
MPI_Comm
comm
,
int
*
flag
,
int
MPI_Iprobe
(
int
source
,
int
tag
,
MPI_Comm
comm
,
int
*
flag
,
MPI_Status
*
status
)
{
MPI_Status
*
status
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Iprobe
(
source
,
tag
,
getTeamComm
(),
flag
,
status
);
int
err
=
0
;
logInfo
(
"Iprobe finished (FLAG="
<<
*
flag
<<
",SOURCE="
<<
mapTeamToWorldRank
(
source
)
<<
",TAG="
<<
tag
<<
",STATUS_SOURCE="
<<
status
->
MPI_SOURCE
<<
",STATUS_TAG="
<<
status
->
MPI_TAG
<<
")"
);
err
|=
PMPI_Iprobe
(
source
,
tag
,
getTeamComm
(),
flag
,
status
);
remapStatus
(
status
);
logInfo
(
"Iprobe finished ("
<<
"FLAG="
<<
*
flag
<<
",SOURCE="
<<
mapTeamToWorldRank
(
source
)
<<
",TAG="
<<
tag
<<
",STATUS_SOURCE="
<<
status
->
MPI_SOURCE
<<
",STATUS_TAG="
<<
status
->
MPI_TAG
<<
")"
);
return
err
;
return
err
;
}
}
int
MPI_Barrier
(
MPI_Comm
comm
)
{
int
MPI_Barrier
(
MPI_Comm
comm
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
synchroniseRanksInTeam
();
int
err
=
0
;
err
|=
synchroniseRanksInTeam
();
return
err
;
return
err
;
}
}
int
MPI_Bcast
(
void
*
buffer
,
int
count
,
MPI_Datatype
datatype
,
int
root
,
int
MPI_Bcast
(
void
*
buffer
,
int
count
,
MPI_Datatype
datatype
,
int
root
,
MPI_Comm
comm
)
{
MPI_Comm
comm
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Bcast
(
buffer
,
count
,
datatype
,
root
,
getTeamComm
());
int
err
=
0
;
err
|=
PMPI_Bcast
(
buffer
,
count
,
datatype
,
root
,
getTeamComm
());
return
err
;
return
err
;
}
}
int
MPI_Allreduce
(
const
void
*
sendbuf
,
void
*
recvbuf
,
int
count
,
int
MPI_Allreduce
(
const
void
*
sendbuf
,
void
*
recvbuf
,
int
count
,
MPI_Datatype
datatype
,
MPI_Op
op
,
MPI_Comm
comm
)
{
MPI_Datatype
datatype
,
MPI_Op
op
,
MPI_Comm
comm
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Allreduce
(
sendbuf
,
recvbuf
,
count
,
datatype
,
op
,
getTeamComm
());
int
err
=
0
;
err
|=
PMPI_Allreduce
(
sendbuf
,
recvbuf
,
count
,
datatype
,
op
,
getTeamComm
());
return
err
;
return
err
;
}
}
...
@@ -256,10 +129,7 @@ int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
...
@@ -256,10 +129,7 @@ int MPI_Alltoall(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
void
*
recvbuf
,
int
recvcount
,
MPI_Datatype
recvtype
,
void
*
recvbuf
,
int
recvcount
,
MPI_Datatype
recvtype
,
MPI_Comm
comm
)
{
MPI_Comm
comm
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Alltoall
(
sendbuf
,
sendcount
,
sendtype
,
recvbuf
,
recvcount
,
recvtype
,
getTeamComm
());
int
err
=
0
;
err
|=
PMPI_Alltoall
(
sendbuf
,
sendcount
,
sendtype
,
recvbuf
,
recvcount
,
recvtype
,
getTeamComm
());
return
err
;
return
err
;
}
}
...
@@ -268,17 +138,13 @@ int MPI_Alltoallv(const void *sendbuf, const int *sendcounts,
...
@@ -268,17 +138,13 @@ int MPI_Alltoallv(const void *sendbuf, const int *sendcounts,
const
int
*
recvcounts
,
const
int
*
rdispls
,
MPI_Datatype
recvtype
,
const
int
*
recvcounts
,
const
int
*
rdispls
,
MPI_Datatype
recvtype
,
MPI_Comm
comm
)
{
MPI_Comm
comm
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Alltoallv
(
sendbuf
,
sendcounts
,
sdispls
,
sendtype
,
recvbuf
,
recvcounts
,
rdispls
,
recvtype
,
getTeamComm
());
int
err
=
0
;
err
|=
PMPI_Alltoallv
(
sendbuf
,
sendcounts
,
sdispls
,
sendtype
,
recvbuf
,
recvcounts
,
rdispls
,
recvtype
,
getTeamComm
());
return
err
;
return
err
;
}
}
double
MPI_Wtime
()
{
double
MPI_Wtime
()
{
const
double
t
=
PMPI_Wtime
();
// If you mark on the timeline here expect negative time values (you've been warned)
// If you mark on the timeline here expect negative time values (you've been warned)
return
t
;
return
PMPI_Wtime
()
;
}
}
int
MPI_Sendrecv
(
const
void
*
sendbuf
,
int
sendcount
,
MPI_Datatype
sendtype
,
int
MPI_Sendrecv
(
const
void
*
sendbuf
,
int
sendcount
,
MPI_Datatype
sendtype
,
...
@@ -295,30 +161,22 @@ int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
...
@@ -295,30 +161,22 @@ int MPI_Sendrecv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
}
else
{
}
else
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
MPI_Sendrecv
(
sendbuf
,
sendcount
,
sendtype
,
dest
,
sendtag
,
recvbuf
,
recvcount
,
recvtype
,
source
,
recvtag
,
getTeamComm
(),
status
);
MPI_Sendrecv
(
sendbuf
,
sendcount
,
sendtype
,
dest
,
sendtag
,
recvbuf
,
recvcount
,
recvtype
,
source
,
recvtag
,
getTeamComm
(),
status
);
remapStatus
(
status
);
}
}
return
MPI_SUCCESS
;
return
MPI_SUCCESS
;
}
}
int
MPI_Finalize
()
{
int
MPI_Finalize
()
{
logInfo
(
"Finalize"
);
logInfo
(
"Finalize"
);
Timing
::
finaliseTiming
();
Timing
::
finaliseTiming
();
// Wait for all replicas before finalising
// Wait for all replicas before finalising
PMPI_Barrier
(
MPI_COMM_WORLD
);
PMPI_Barrier
(
MPI_COMM_WORLD
);
freeTeamComm
();
freeTeamComm
();
Timing
::
outputTiming
();
Timing
::
outputTiming
();
return
PMPI_Finalize
();
return
PMPI_Finalize
();
}
}
int
MPI_Abort
(
MPI_Comm
comm
,
int
errorcode
)
{
int
MPI_Abort
(
MPI_Comm
comm
,
int
errorcode
)
{
assert
(
comm
==
MPI_COMM_WORLD
);
assert
(
comm
==
MPI_COMM_WORLD
);
int
err
=
PMPI_Abort
(
getTeamComm
(),
errorcode
);
int
err
=
0
;
err
|=
PMPI_Abort
(
getTeamComm
(),
errorcode
);
return
err
;
return
err
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment