Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CodeVault
hpc-kernels
structured_grids
Commits
1dc02038
Commit
1dc02038
authored
Dec 15, 2016
by
Thomas Steinreiter
Browse files
* refactored MpiRequest
* added missing files
parent
3287ff1d
Changes
7
Hide whitespace changes
Inline
Side-by-side
cellular_automaton/wireworld_c++/CollectiveCommunicator.cpp
View file @
1dc02038
...
@@ -16,7 +16,7 @@ void CollectiveCommunicator::Communicate(State* model) {
...
@@ -16,7 +16,7 @@ void CollectiveCommunicator::Communicate(State* model) {
);
);
}
}
Communicator
::
MpiRequest
CollectiveCommunicator
::
AsyncCommunicate
(
State
*
model
)
{
MpiRequest
CollectiveCommunicator
::
AsyncCommunicate
(
State
*
model
)
{
if
(
commDistGraph_
==
MPI_COMM_NULL
)
if
(
commDistGraph_
==
MPI_COMM_NULL
)
MpiReportErrorAbort
(
"Communicator not initialized"
);
MpiReportErrorAbort
(
"Communicator not initialized"
);
...
...
cellular_automaton/wireworld_c++/CommunicationMode.hpp
0 → 100644
View file @
1dc02038
#pragma once
#include
<array>
#include
<tuple>
enum
class
CommunicationMode
{
Collective
,
//
P2P
//
};
constexpr
std
::
array
<
std
::
pair
<
const
char
*
,
CommunicationMode
>
,
2
>
StringToCommunicationMode
()
{
return
{{
std
::
make_pair
(
"Collective"
,
CommunicationMode
::
Collective
),
//
std
::
make_pair
(
"P2P"
,
CommunicationMode
::
P2P
)
//
}};
}
cellular_automaton/wireworld_c++/Communicator.cpp
View file @
1dc02038
...
@@ -4,19 +4,6 @@
...
@@ -4,19 +4,6 @@
#include
"Communicator.hpp"
#include
"Communicator.hpp"
Communicator
::
MpiRequest
::
MpiRequest
(
DoubleVector
<
MPI_Request
>
reqs
)
:
reqs_
(
reqs
)
{}
void
Communicator
::
MpiRequest
::
Wait
()
{
MPI_Waitall
(
static_cast
<
int
>
(
reqs_
.
size
()),
//
reqs_
.
data
(),
//
MPI_STATUSES_IGNORE
);
//
finished
=
true
;
}
Communicator
::
MpiRequest
::~
MpiRequest
()
{
if
(
!
finished
)
{
MpiReportErrorAbort
(
"Forgot to Wait for MPI_Request"
);
}
}
// defines types and graph topology
// defines types and graph topology
Communicator
::
Communicator
(
const
MpiEnvironment
&
env
,
const
Size
&
procsSize
,
Communicator
::
Communicator
(
const
MpiEnvironment
&
env
,
const
Size
&
procsSize
,
const
Size
&
tileSize
)
{
const
Size
&
tileSize
)
{
...
...
cellular_automaton/wireworld_c++/Communicator.hpp
View file @
1dc02038
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include
"Configuration.hpp"
#include
"Configuration.hpp"
#include
"MpiEnvironment.hpp"
#include
"MpiEnvironment.hpp"
#include
"MpiRequest.hpp"
#include
"State.hpp"
#include
"State.hpp"
#include
"Util.hpp"
#include
"Util.hpp"
...
@@ -17,28 +18,6 @@ class Communicator {
...
@@ -17,28 +18,6 @@ class Communicator {
template
<
typename
T
>
template
<
typename
T
>
using
Vector
=
boost
::
container
::
static_vector
<
T
,
NoNeighbors
>
;
using
Vector
=
boost
::
container
::
static_vector
<
T
,
NoNeighbors
>
;
public:
// Life cycle handling for MPI_Requests
class
MpiRequest
{
// TODO: unnest
public:
template
<
typename
T
>
using
DoubleVector
=
boost
::
container
::
static_vector
<
T
,
NoNeighbors
*
2
>
;
private:
DoubleVector
<
MPI_Request
>
reqs_
;
bool
finished
{};
public:
MpiRequest
(
DoubleVector
<
MPI_Request
>
reqs
);
MpiRequest
(
const
MpiRequest
&
)
=
default
;
MpiRequest
(
MpiRequest
&&
)
=
default
;
MpiRequest
&
operator
=
(
const
MpiRequest
&
)
=
default
;
MpiRequest
&
operator
=
(
MpiRequest
&&
)
=
default
;
void
Wait
();
~
MpiRequest
();
};
protected:
protected:
// data members for graph topology
// data members for graph topology
Vector
<
int
>
neighbors_
;
Vector
<
int
>
neighbors_
;
...
...
cellular_automaton/wireworld_c++/CommunicatorFactory.hpp
0 → 100644
View file @
1dc02038
#pragma once
#include
<array>
#include
<memory>
#include
<tuple>
#include
"CollectiveCommunicator.hpp"
#include
"CommunicationMode.hpp"
#include
"Configuration.hpp"
#include
"P2PCommunicator.hpp"
#include
"Tile.hpp"
#include
"Util.hpp"
struct
CommunicatorFactory
{
static
std
::
unique_ptr
<
Communicator
>
Create
(
Configuration
cfg
,
const
Tile
&
tile
,
const
MpiEnvironment
&
env
)
{
switch
(
cfg
.
CommMode
)
{
case
CommunicationMode
::
Collective
:
return
std
::
make_unique
<
CollectiveCommunicator
>
(
env
,
cfg
.
Procs
,
tile
.
tileSize
());
case
CommunicationMode
::
P2P
:
return
std
::
make_unique
<
P2PCommunicator
>
(
env
,
cfg
.
Procs
,
tile
.
tileSize
());
default:
MpiReportErrorAbort
(
"Unknown CommunicationMode"
);
}
}
};
cellular_automaton/wireworld_c++/MpiRequest.hpp
0 → 100644
View file @
1dc02038
#pragma once
#include
<boost/container/static_vector.hpp>
#include
<mpi.h>
class
MpiRequest
{
constexpr
static
std
::
size_t
NoNeighbors
{
8
};
public:
template
<
typename
T
>
using
DoubleVector
=
boost
::
container
::
static_vector
<
T
,
NoNeighbors
*
2
>
;
private:
DoubleVector
<
MPI_Request
>
reqs_
;
bool
finished
{};
public:
MpiRequest
(
DoubleVector
<
MPI_Request
>
reqs
)
:
reqs_
(
reqs
)
{}
MpiRequest
(
const
MpiRequest
&
)
=
default
;
MpiRequest
(
MpiRequest
&&
)
=
default
;
MpiRequest
&
operator
=
(
const
MpiRequest
&
)
=
default
;
MpiRequest
&
operator
=
(
MpiRequest
&&
)
=
default
;
void
Wait
()
{
MPI_Waitall
(
static_cast
<
int
>
(
reqs_
.
size
()),
//
reqs_
.
data
(),
//
MPI_STATUSES_IGNORE
);
//
finished
=
true
;
}
~
MpiRequest
()
{
if
(
!
finished
)
{
MpiReportErrorAbort
(
"Forgot to Wait for MPI_Request"
);
}
}
};
cellular_automaton/wireworld_c++/P2PCommunicator.cpp
View file @
1dc02038
...
@@ -4,8 +4,8 @@ void P2PCommunicator::Communicate(State* model) {
...
@@ -4,8 +4,8 @@ void P2PCommunicator::Communicate(State* model) {
AsyncCommunicate
(
model
).
Wait
();
AsyncCommunicate
(
model
).
Wait
();
}
}
Communicator
::
MpiRequest
P2PCommunicator
::
AsyncCommunicate
(
State
*
model
)
{
MpiRequest
P2PCommunicator
::
AsyncCommunicate
(
State
*
model
)
{
Communicator
::
MpiRequest
::
DoubleVector
<
MPI_Request
>
reqs
;
MpiRequest
::
DoubleVector
<
MPI_Request
>
reqs
;
for
(
std
::
size_t
i
{
0
};
i
<
neighbors_
.
size
();
++
i
)
{
for
(
std
::
size_t
i
{
0
};
i
<
neighbors_
.
size
();
++
i
)
{
{
{
MPI_Request
req
;
MPI_Request
req
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment