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
3287ff1d
Commit
3287ff1d
authored
Dec 15, 2016
by
Thomas Steinreiter
Browse files
* refactoring
parent
6849bfea
Changes
7
Show whitespace changes
Inline
Side-by-side
cellular_automaton/wireworld_c++/.clang-format
View file @
3287ff1d
...
...
@@ -4,7 +4,7 @@ PointerAlignment: Left
IndentWidth: 4
TabWidth: 4
UseTab: ForIndentation
ColumnLimit:
8
0
ColumnLimit:
12
0
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
...
...
cellular_automaton/wireworld_c++/CMakeLists.txt
View file @
3287ff1d
...
...
@@ -22,7 +22,7 @@ if (MPI_FOUND AND Boost_FOUND)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native -Wall -Wextra"
)
elseif
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"Clang"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native -Weverything -Wno-missing-prototypes -Wno-padded -Wno-c++98-compat -Wno-c++98-compat-pedantic"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native -Weverything -Wno-missing-prototypes
-Wno-covered-switch-default -Wno-switch-enum
-Wno-padded -Wno-c++98-compat -Wno-c++98-compat-pedantic"
)
elseif
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"Intel"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-xHost -std=c++14 -Wall"
)
endif
()
...
...
cellular_automaton/wireworld_c++/Communicator.cpp
View file @
3287ff1d
...
...
@@ -18,10 +18,8 @@ Communicator::MpiRequest::~MpiRequest() {
}
// defines types and graph topology
Communicator
::
Communicator
(
const
MpiEnvironment
&
env
,
CommunicationMode
commMode
,
const
Size
&
procsSize
,
const
Size
&
tileSize
)
:
commMode_
(
commMode
)
{
Communicator
::
Communicator
(
const
MpiEnvironment
&
env
,
const
Size
&
procsSize
,
const
Size
&
tileSize
)
{
// Begin definition of basic types
MPI_Type_contiguous
(
static_cast
<
int
>
(
tileSize
.
Cols
),
MPI_CHAR
,
&
haloRowType_
);
...
...
@@ -130,7 +128,6 @@ Communicator::~Communicator() {
void
Communicator
::
swap
(
Communicator
&
first
,
Communicator
&
second
)
{
using
std
::
swap
;
swap
(
first
.
commMode_
,
second
.
commMode_
);
swap
(
first
.
neighbors_
,
second
.
neighbors_
);
swap
(
first
.
sizes_
,
second
.
sizes_
);
swap
(
first
.
sendTypes_
,
second
.
sendTypes_
);
...
...
cellular_automaton/wireworld_c++/Communicator.hpp
View file @
3287ff1d
...
...
@@ -40,8 +40,6 @@ class Communicator {
};
protected:
CommunicationMode
commMode_
;
// data members for graph topology
Vector
<
int
>
neighbors_
;
Vector
<
int
>
sizes_
;
...
...
@@ -58,7 +56,7 @@ class Communicator {
public:
Communicator
()
=
default
;
Communicator
(
const
MpiEnvironment
&
env
,
CommunicationMode
commMode
,
Communicator
(
const
MpiEnvironment
&
env
,
const
Size
&
gridSize
,
const
Size
&
tileSize
);
virtual
~
Communicator
();
void
swap
(
Communicator
&
first
,
Communicator
&
second
);
...
...
cellular_automaton/wireworld_c++/Configuration.cpp
View file @
3287ff1d
...
...
@@ -10,29 +10,17 @@
#include
<boost/format.hpp>
#include
<boost/program_options.hpp>
// BEGIN helper functions to parse Communication Mode cmd args
namespace
{
using
namespace
std
::
string_literals
;
std
::
array
<
std
::
pair
<
std
::
string
,
CommunicationMode
>
,
2
>
StringToCommunicationMode
{{
std
::
make_pair
(
"Collective"
s
,
CommunicationMode
::
Collective
),
//
std
::
make_pair
(
"P2P"
s
,
CommunicationMode
::
P2P
)
//
}};
}
// helper function to parse Communication Mode cmd args
std
::
istream
&
operator
>>
(
std
::
istream
&
in
,
CommunicationMode
&
comm
)
{
std
::
string
buf
;
in
>>
buf
;
auto
r
=
std
::
find_if
(
std
::
begin
(
StringToCommunicationMode
),
std
::
end
(
StringToCommunicationMode
),
[
&
](
auto
&
t
)
{
return
t
.
first
==
buf
;
});
if
(
r
==
std
::
end
(
StringToCommunicationMode
))
throw
boost
::
program_options
::
validation_error
(
boost
::
program_options
::
validation_error
::
invalid_option_value
);
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
))
throw
boost
::
program_options
::
validation_error
(
boost
::
program_options
::
validation_error
::
invalid_option_value
);
comm
=
r
->
second
;
return
in
;
}
// END helper functions
auto
Configuration
::
parseArgs
(
int
argc
,
char
*
argv
[],
const
MpiEnvironment
&
env
)
->
Configuration
{
...
...
cellular_automaton/wireworld_c++/Configuration.hpp
View file @
3287ff1d
...
...
@@ -4,13 +4,9 @@
#include
<string>
#include
"MpiEnvironment.hpp"
#include
"CommunicationMode.hpp"
#include
"Util.hpp"
enum
class
CommunicationMode
{
Collective
,
//
P2P
//
};
struct
Configuration
{
Size
Procs
{};
std
::
string
InputFilePath
;
...
...
cellular_automaton/wireworld_c++/MpiWireworld.cpp
View file @
3287ff1d
...
...
@@ -8,9 +8,8 @@
#include
<string>
#include
<vector>
#include
"
Collective
Communicator.hpp"
#include
"Communicator
Factory
.hpp"
#include
"FileIO.hpp"
#include
"P2PCommunicator.hpp"
#include
"State.hpp"
#include
"Tile.hpp"
#include
"Util.hpp"
...
...
@@ -56,7 +55,7 @@ void MpiWireworld::processArea(Coord start, Size size) {
?
State
::
ElectronHead
:
State
::
Conductor
;
};
case
State
::
Empty
:
default
:
return
currentState
;
}
}();
...
...
@@ -65,17 +64,7 @@ void MpiWireworld::processArea(Coord start, Size size) {
}
MpiWireworld
::
MpiWireworld
(
const
MpiEnvironment
&
env
,
const
Configuration
&
cfg
)
:
tile_
(
Tile
::
Read
(
cfg
,
env
)),
comm_
([
&
]()
->
std
::
unique_ptr
<
Communicator
>
{
switch
(
cfg
.
CommMode
)
{
case
CommunicationMode
::
Collective
:
return
std
::
make_unique
<
CollectiveCommunicator
>
(
env
,
cfg
.
CommMode
,
cfg
.
Procs
,
tile_
.
tileSize
());
case
CommunicationMode
::
P2P
:
return
std
::
make_unique
<
P2PCommunicator
>
(
env
,
cfg
.
CommMode
,
cfg
.
Procs
,
tile_
.
tileSize
());
}
}())
{
:
tile_
(
Tile
::
Read
(
cfg
,
env
)),
comm_
(
CommunicatorFactory
::
Create
(
cfg
,
tile_
,
env
))
{
comm_
->
Communicate
(
tile_
.
model
());
}
...
...
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