Skip to content

Commit

Permalink
Merge pull request #2025 from keichi/fix-unaligned-access
Browse files Browse the repository at this point in the history
Fix unaligned memory access in SSC engine
  • Loading branch information
JasonRuonanWang authored Mar 8, 2020
2 parents ddaeeb0 + dc81a88 commit c066f19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions source/adios2/engine/ssc/SscReader.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void SscReader::GetDeferredCommon(Variable<T> &variable, T *data)
b.shape.size() == 1 and b.start[0] == 0 and
b.count[0] == 1 and b.shape[0] == 1)
{
data[0] = reinterpret_cast<T *>(m_Buffer.data() +
b.bufferStart)[0];
std::memcpy(data, m_Buffer.data() + b.bufferStart,
sizeof(T));
}
else
{
Expand Down
10 changes: 6 additions & 4 deletions source/adios2/helper/adiosMpiHandshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ void MpiHandshake::Test()
size_t offset = PlaceInBuffer(stream, rank);
char mode = m_Buffer[offset];
offset += sizeof(char);
int appMasterRank =
reinterpret_cast<int *>(m_Buffer.data() + offset)[0];
int appMasterRank;
std::memcpy(&appMasterRank, m_Buffer.data() + offset,
sizeof(appMasterRank));
offset += sizeof(int);
int appSize =
reinterpret_cast<int *>(m_Buffer.data() + offset)[0];
int appSize;
std::memcpy(&appSize, m_Buffer.data() + offset,
sizeof(appSize));
offset += sizeof(int);
std::string filename = m_Buffer.data() + offset;
m_AppsSize[appMasterRank] = appSize;
Expand Down

0 comments on commit c066f19

Please sign in to comment.