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
af23d9e5
Commit
af23d9e5
authored
Dec 15, 2016
by
Thomas Steinreiter
Browse files
* fixed clang-tidy warnings
parent
1dc02038
Changes
4
Show whitespace changes
Inline
Side-by-side
cellular_automaton/wireworld_c++/CollectiveCommunicator.cpp
View file @
af23d9e5
#include
"CollectiveCommunicator.hpp"
void
CollectiveCommunicator
::
Communicate
(
State
*
model
)
{
if
(
commDistGraph_
==
MPI_COMM_NULL
)
MpiReportErrorAbort
(
"Communicator not initialized"
);
if
(
commDistGraph_
==
MPI_COMM_NULL
)
{
MpiReportErrorAbort
(
"Communicator not initialized"
);
}
MPI_Neighbor_alltoallw
(
model
,
// sendbuf
sizes_
.
data
(),
// sendcounts
...
...
@@ -17,8 +16,7 @@ void CollectiveCommunicator::Communicate(State* model) {
}
MpiRequest
CollectiveCommunicator
::
AsyncCommunicate
(
State
*
model
)
{
if
(
commDistGraph_
==
MPI_COMM_NULL
)
MpiReportErrorAbort
(
"Communicator not initialized"
);
if
(
commDistGraph_
==
MPI_COMM_NULL
)
{
MpiReportErrorAbort
(
"Communicator not initialized"
);
}
MPI_Request
req
;
MPI_Ineighbor_alltoallw
(
model
,
// sendbuf
...
...
cellular_automaton/wireworld_c++/Communicator.cpp
View file @
af23d9e5
...
...
@@ -5,11 +5,9 @@
#include
"Communicator.hpp"
// defines types and graph topology
Communicator
::
Communicator
(
const
MpiEnvironment
&
env
,
const
Size
&
procsSize
,
const
Size
&
tileSize
)
{
Communicator
::
Communicator
(
const
MpiEnvironment
&
env
,
const
Size
&
gridSize
,
const
Size
&
tileSize
)
{
// Begin definition of basic types
MPI_Type_contiguous
(
static_cast
<
int
>
(
tileSize
.
Cols
),
MPI_CHAR
,
&
haloRowType_
);
MPI_Type_contiguous
(
static_cast
<
int
>
(
tileSize
.
Cols
),
MPI_CHAR
,
&
haloRowType_
);
MPI_Type_commit
(
&
haloRowType_
);
MPI_Type_vector
(
static_cast
<
int
>
(
tileSize
.
Rows
),
1
,
static_cast
<
int
>
(
tileSize
.
Cols
+
2
),
MPI_CHAR
,
...
...
@@ -29,9 +27,7 @@ Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize,
const
auto
tRows
=
tileSize
.
Rows
;
// character coordinates to displacement
const
auto
dp
=
[
&
](
std
::
size_t
x
,
std
::
size_t
y
)
{
return
static_cast
<
MPI_Aint
>
(
y
*
(
tCols
+
2
)
+
x
);
};
const
auto
dp
=
[
&
](
std
::
size_t
x
,
std
::
size_t
y
)
{
return
static_cast
<
MPI_Aint
>
(
y
*
(
tCols
+
2
)
+
x
);
};
const
std
::
array
<
MPI_Aint
,
NoNeighbors
>
generalSendDisplacements
{{
dp
(
1
,
1
),
dp
(
1
,
1
),
dp
(
tCols
,
1
),
//
...
...
@@ -56,16 +52,14 @@ Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize,
// border cases)
const
auto
rank2coord
=
[
&
](
std
::
size_t
rank
)
{
return
Coord
{
rank
%
procs
Size
.
Cols
,
//
rank
/
procs
Size
.
Cols
//
rank
%
grid
Size
.
Cols
,
//
rank
/
grid
Size
.
Cols
//
};
};
const
auto
coord2rank
=
[
&
](
Coord
c
)
{
return
static_cast
<
int
>
(
procs
Size
.
Cols
*
c
.
Y
+
c
.
X
);
};
const
auto
coord2rank
=
[
&
](
Coord
c
)
{
return
static_cast
<
int
>
(
grid
Size
.
Cols
*
c
.
Y
+
c
.
X
);
};
const
auto
isInsideProcsGrid
=
[
&
](
Coord
c
)
{
return
c
.
X
<
procsSize
.
Cols
&&
c
.
Y
<
procsSize
.
Rows
;
};
const
auto
isInsideProcsGrid
=
[
&
](
Coord
c
)
{
return
c
.
X
<
gridSize
.
Cols
&&
c
.
Y
<
gridSize
.
Rows
;
};
const
auto
myCoord
=
rank2coord
(
env
.
worldRank
());
const
std
::
array
<
Coord
,
NoNeighbors
>
generalNeighborCoords
{{
...
...
@@ -90,14 +84,13 @@ Communicator::Communicator(const MpiEnvironment& env, const Size& procsSize,
}
}
MPI_Dist_graph_create_adjacent
(
MPI_COMM_WORLD
,
// comm_old
MPI_Dist_graph_create_adjacent
(
MPI_COMM_WORLD
,
// comm_old
static_cast
<
int
>
(
neighbors_
.
size
()),
// indegree
neighbors_
.
data
(),
// sources
reinterpret
_cast
<
int
*>
(
MPI_UNWEIGHTED
),
// sourceweights
static
_cast
<
int
*>
(
MPI_UNWEIGHTED
),
// sourceweights
static_cast
<
int
>
(
neighbors_
.
size
()),
// outdegree
neighbors_
.
data
(),
// destinations
reinterpret
_cast
<
int
*>
(
MPI_UNWEIGHTED
),
// destweights
static
_cast
<
int
*>
(
MPI_UNWEIGHTED
),
// destweights
MPI_INFO_NULL
,
// info
0
,
// reorder
&
commDistGraph_
// comm_dist_graph
...
...
@@ -126,9 +119,7 @@ void Communicator::swap(Communicator& first, Communicator& second) {
swap
(
first
.
haloCornerType_
,
second
.
haloCornerType_
);
}
Communicator
::
Communicator
(
Communicator
&&
other
)
noexcept
{
swap
(
*
this
,
other
);
}
Communicator
::
Communicator
(
Communicator
&&
other
)
noexcept
{
swap
(
*
this
,
other
);
}
Communicator
&
Communicator
::
operator
=
(
Communicator
&&
other
)
noexcept
{
swap
(
*
this
,
other
);
return
*
this
;
...
...
cellular_automaton/wireworld_c++/Configuration.cpp
View file @
af23d9e5
...
...
@@ -16,14 +16,14 @@ std::istream& operator>>(std::istream& in, CommunicationMode& comm) {
in
>>
buf
;
const
auto
&
str2comm
=
StringToCommunicationMode
();
auto
r
=
std
::
find_if
(
std
::
begin
(
str2comm
),
std
::
end
(
str2comm
),
[
&
](
auto
&
t
)
{
return
t
.
first
==
buf
;
});
if
(
r
==
std
::
end
(
str2comm
))
if
(
r
==
std
::
end
(
str2comm
))
{
throw
boost
::
program_options
::
validation_error
(
boost
::
program_options
::
validation_error
::
invalid_option_value
);
}
comm
=
r
->
second
;
return
in
;
}
auto
Configuration
::
parseArgs
(
int
argc
,
char
*
argv
[],
const
MpiEnvironment
&
env
)
->
Configuration
{
auto
Configuration
::
parseArgs
(
int
argc
,
char
*
argv
[],
const
MpiEnvironment
&
env
)
->
Configuration
{
namespace
po
=
boost
::
program_options
;
Configuration
cfg
;
...
...
@@ -52,16 +52,13 @@ auto Configuration::parseArgs(int argc, char* argv[], const MpiEnvironment& env)
.
run
(),
vm
);
if
(
vm
.
count
(
"help"
)
>
0
&&
env
.
isMaster
())
{
std
::
cout
<<
desc
<<
"
\n
"
;
}
if
(
vm
.
count
(
"help"
)
>
0
&&
env
.
isMaster
())
{
std
::
cout
<<
desc
<<
"
\n
"
;
}
po
::
notify
(
vm
);
}
catch
(
const
po
::
error
&
err
)
{
MpiReportErrorAbort
(
err
.
what
());
}
// if no dimensions given, use MPI_Dims_create
if
(
cfg
.
Procs
.
Cols
<
1
||
cfg
.
Procs
.
Rows
<
1
)
{
std
::
array
<
int
,
2
>
dims
{{
static_cast
<
int
>
(
cfg
.
Procs
.
Cols
),
static_cast
<
int
>
(
cfg
.
Procs
.
Rows
)}};
std
::
array
<
int
,
2
>
dims
{{
static_cast
<
int
>
(
cfg
.
Procs
.
Cols
),
static_cast
<
int
>
(
cfg
.
Procs
.
Rows
)}};
MPI_Dims_create
(
static_cast
<
int
>
(
env
.
worldSize
()),
// nnodes
2
,
// ndims
dims
.
data
());
// dims
...
...
@@ -74,8 +71,7 @@ auto Configuration::parseArgs(int argc, char* argv[], const MpiEnvironment& env)
const
auto
&
totalCellCount
=
cfg
.
Procs
.
Cols
*
cfg
.
Procs
.
Rows
;
const
auto
&
worldSize
=
env
.
worldSize
();
if
(
totalCellCount
!=
static_cast
<
std
::
size_t
>
(
worldSize
))
{
MpiReportErrorAbort
(
boost
::
str
(
boost
::
format
(
"Total number of cells (%d) does not match "
MpiReportErrorAbort
(
boost
::
str
(
boost
::
format
(
"Total number of cells (%d) does not match "
"the MPI World size (%d)"
)
%
totalCellCount
%
worldSize
));
}
...
...
cellular_automaton/wireworld_c++/main.cpp
View file @
af23d9e5
...
...
@@ -6,8 +6,6 @@
#include
"MpiEnvironment.hpp"
#include
"MpiWireworld.hpp"
using
namespace
std
::
string_literals
;
int
main
(
int
argc
,
char
*
argv
[])
{
const
auto
&
starttime
=
std
::
chrono
::
system_clock
::
now
();
...
...
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