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
675569f0
Commit
675569f0
authored
Oct 12, 2016
by
Thomas Steinreiter
Browse files
added invalid newline char detection, cleanup
parent
8a205098
Changes
3
Hide whitespace changes
Inline
Side-by-side
cellular_automaton/wireworld_c++/FileIO.cpp
View file @
675569f0
#include
"FileIO.hpp"
#include
<algorithm>
#include
<array>
#include
<fstream>
#include
<iomanip>
#include
<array>
#include
<iostream>
#include
<sstream>
...
...
@@ -17,6 +17,10 @@ HeaderInfo FileIO::ReadHeader(const std::string& path) {
MPI_File_read_all
(
fh
,
buf
.
data
(),
buf
.
size
(),
MPI_CHAR
,
MPI_STATUS_IGNORE
);
MPI_File_close
(
&
fh
);
if
(
std
::
find
(
std
::
begin
(
buf
),
std
::
end
(
buf
),
'\r'
)
!=
std
::
end
(
buf
))
{
MpiReportErrorAbort
(
"Invalid newline character detected!"
);
}
// make stream from buf
std
::
istringstream
input
;
input
.
rdbuf
()
->
pubsetbuf
(
buf
.
data
(),
buf
.
size
());
...
...
cellular_automaton/wireworld_c++/MpiEnvironment.cpp
View file @
675569f0
...
...
@@ -15,6 +15,8 @@ MpiEnvironment::MpiEnvironment(int& argc, char* argv[]) {
MPI_Comm_rank
(
MPI_COMM_WORLD
,
&
_worldRank
);
MPI_Comm_size
(
MPI_COMM_WORLD
,
&
_worldSize
);
_isMaster
=
{
_worldRank
==
0
};
// We want the program to stop on I/O errors
MPI_File_set_errhandler
(
MPI_FILE_NULL
,
MPI_ERRORS_ARE_FATAL
);
}
MpiEnvironment
::~
MpiEnvironment
()
{
if
(
_worldRank
!=
-
1
)
{
MPI_Finalize
();
}
...
...
cellular_automaton/wireworld_c++/main.cpp
View file @
675569f0
#include
<cassert>
#include
<chrono>
#include
<cstdlib>
#include
<fstream>
#include
<iostream>
#include
<string>
#include
<thread>
#include
<vector>
#include
"Configuration.hpp"
#include
"MpiEnvironment.hpp"
...
...
@@ -16,12 +11,12 @@ using namespace std::string_literals;
int
main
(
int
argc
,
char
*
argv
[])
{
const
auto
&
starttime
=
std
::
chrono
::
system_clock
::
now
();
// we rely on the MPI implementation to correctly forward the arguments
MpiEnvironment
env
(
argc
,
argv
);
const
auto
&
cfg
=
Configuration
::
parseArgs
(
argc
,
argv
,
env
);
const
auto
cfg
=
Configuration
::
parseArgs
(
argc
,
argv
,
env
);
MpiWireworld
ww
(
env
,
cfg
);
for
(
std
::
size_t
i
{
0
};
i
<
cfg
.
Generations
;
++
i
)
{
ww
.
simulateStep
();
...
...
@@ -29,6 +24,7 @@ int main(int argc, char* argv[]) {
std
::
cout
<<
"iteration:"
<<
i
<<
'\n'
;
}
}
// write output file if needed
if
(
!
cfg
.
OutputFilePath
.
empty
())
{
ww
.
write
();
}
if
(
env
.
isMaster
())
{
...
...
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