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
71ae80c3
Commit
71ae80c3
authored
Oct 13, 2016
by
Thomas Steinreiter
Browse files
fixed bug: write correct line endings
parent
cf6ca9b8
Changes
4
Hide whitespace changes
Inline
Side-by-side
cellular_automaton/wireworld_c++/FileIO.cpp
View file @
71ae80c3
...
...
@@ -59,8 +59,8 @@ void FileIO::WriteHeader(const HeaderInfo& header, const std::string& path,
MPI_File_close
(
&
fh
);
}
SizeCoord
FileIO
::
GetTile
SizeCoord
(
Size
globalSize
,
Size
procsSize
,
std
::
size_t
rank
)
{
TileInfo
FileIO
::
GetTile
Info
(
Size
globalSize
,
Size
procsSize
,
std
::
size_t
rank
)
{
const
auto
tileX
=
rank
%
procsSize
.
Cols
;
const
auto
tileY
=
rank
/
procsSize
.
Cols
;
...
...
@@ -72,16 +72,16 @@ SizeCoord FileIO::GetTileSizeCoord(Size globalSize, Size procsSize,
const
auto
tileSizeCols
=
xEnd
-
xBeg
;
const
auto
tileSizeRows
=
yEnd
-
yBeg
;
return
{{
tileSizeCols
,
tileSizeRows
},
{
xBeg
,
yBeg
}};
return
{{
tileSizeCols
,
tileSizeRows
},
{
xBeg
,
yBeg
}
,
{
tileX
,
tileY
}
};
}
FileIO
::
Tile
::
Tile
(
const
std
::
string
&
path
,
HeaderInfo
header
,
Size
procsSize
,
std
::
size_t
rank
,
State
*
buf
)
:
_path
(
path
),
_headerLength
(
header
.
HeaderLength
),
_srcSize
(
header
.
GlobalSize
),
_procsSize
(
procsSize
),
_rank
(
rank
),
_buf
(
buf
),
_
tileSizeCoord
(
FileIO
::
GetTile
SizeCoord
(
header
.
GlobalSize
,
procsSize
,
rank
)),
_tileSize
(
_tile
SizeCoord
.
Size
),
_tileCoord
(
_tile
SizeCoord
.
Coord
),
_srcSize
(
header
.
GlobalSize
),
_procsSize
(
procsSize
),
_rank
(
rank
),
_
buf
(
buf
),
_tileInfo
(
FileIO
::
GetTile
Info
(
header
.
GlobalSize
,
procsSize
,
rank
)),
_tileSize
(
_tile
Info
.
Size
),
_tileCoord
(
_tile
Info
.
Global
Coord
),
_tileType
(
MpiSubarray
({{
header
.
GlobalSize
.
Rows
,
_tileSize
.
Rows
,
0
},
{
header
.
GlobalSize
.
Cols
+
LF
,
_tileSize
.
Cols
,
0
}})),
...
...
@@ -116,15 +116,16 @@ void FileIO::Tile::Write() const {
// ranks actually write line feeds
// are we a rightMost tile?
const
auto
rightMost
=
_tileCoord
.
X
==
_procsSize
.
Cols
-
1
;
const
auto
rightMost
=
_tile
Info
.
Proc
Coord
.
X
==
_procsSize
.
Cols
-
1
;
const
auto
noLfNeeded
=
rightMost
?
_tileSize
.
Rows
:
0
;
const
auto
lfType
=
MpiSubarray
(
// subsize must be > 0
{{
_srcSize
.
Rows
,
std
::
max
<
std
::
size_t
>
(
noLfNeeded
,
1
),
0
},
{
_srcSize
.
Cols
+
LF
,
1
,
0
}});
const
std
::
vector
<
char
>
lfs
(
noLfNeeded
,
'\n'
);
const
auto
lfDisp
=
_headerLength
+
(
_srcSize
.
Cols
+
LF
)
*
_tileCoord
.
Y
+
_tileCoord
.
X
+
_tileSize
.
Cols
;
const
auto
lfDisp
=
_headerLength
+
_tileInfo
.
GlobalCoord
.
Y
*
(
_srcSize
.
Cols
+
LF
)
+
_srcSize
.
Cols
;
MPI_File_set_view
(
file
,
lfDisp
,
MPI_CHAR
,
lfType
.
type
(),
"native"
,
MPI_INFO_NULL
);
...
...
cellular_automaton/wireworld_c++/FileIO.hpp
View file @
71ae80c3
...
...
@@ -20,7 +20,8 @@ struct FileIO {
static
void
WriteHeader
(
const
HeaderInfo
&
header
,
const
std
::
string
&
path
,
const
MpiEnvironment
&
env
);
static
SizeCoord
GetTileSizeCoord
(
Size
globalSize
,
Size
procsSize
,
std
::
size_t
rank
);
static
TileInfo
GetTileInfo
(
Size
globalSize
,
Size
procsSize
,
std
::
size_t
rank
);
// helper class to share commonly used data for reading and writing
class
Tile
{
...
...
@@ -32,7 +33,7 @@ struct FileIO {
const
std
::
size_t
_rank
;
State
*
_buf
;
const
SizeCoord
_tileSizeCoord
;
const
TileInfo
_tileInfo
;
const
Size
_tileSize
;
const
Coord
_tileCoord
;
const
MpiSubarray
_tileType
;
...
...
cellular_automaton/wireworld_c++/Tile.cpp
View file @
71ae80c3
...
...
@@ -11,7 +11,7 @@
Tile
::
Tile
(
const
Configuration
&
cfg
,
const
MpiEnvironment
&
env
)
:
_env
(
env
),
_cfg
(
cfg
),
_header
(
FileIO
::
ReadHeader
(
cfg
.
InputFilePath
)),
//
_tileSize
(
FileIO
::
GetTile
SizeCoord
(
_header
.
GlobalSize
,
cfg
.
Procs
,
env
.
worldRank
()).
Size
),
_tileSize
(
FileIO
::
GetTile
Info
(
_header
.
GlobalSize
,
cfg
.
Procs
,
env
.
worldRank
()).
Size
),
_modelWidth
(
_tileSize
.
Cols
+
2
)
{
const
auto
bufsize
=
(
_tileSize
.
Cols
+
2
)
*
(
_tileSize
.
Rows
+
2
);
_memoryA
.
resize
(
bufsize
);
...
...
cellular_automaton/wireworld_c++/Util.hpp
View file @
71ae80c3
...
...
@@ -14,9 +14,10 @@ struct Coord {
Coord
(
std
::
size_t
x
,
std
::
size_t
y
)
:
X
(
x
),
Y
(
y
)
{}
};
struct
SizeCoord
{
struct
TileInfo
{
::
Size
Size
;
::
Coord
Coord
;
::
Coord
GlobalCoord
;
::
Coord
ProcCoord
;
};
[[
noreturn
]]
void
MpiReportErrorAbort
(
const
std
::
string
&
err
);
\ No newline at end of file
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