Commit bd3523e7 authored by fabianw's avatar fabianw
Browse files

switched to memcpy for buffer fill in MPI I/O

parent 97a49114
......@@ -7,6 +7,7 @@
#define ISOEXTRACTORMPI_H_XABTB0WN
#include <mpi.h>
#include <cstring>
#include "IsoExtractor.h"
#include "InterpolatorMPI.h"
......@@ -191,12 +192,6 @@ private:
unsigned long long mytri = tList.size();
MPI_Allgather(&mytri, 1, MPI_UNSIGNED_LONG_LONG, allsize.data(), 1, MPI_UNSIGNED_LONG_LONG, comm);
// if (0 == rank)
// {
// for (const auto v: allsize)
// std::cout << v << std::endl;
// }
long long offset = 0;
MPI_File_get_position(file_id, &offset);
......@@ -208,17 +203,22 @@ private:
if (allsize[rank] > 0)
{
tarr = new Triangle[allsize[rank]];
// for (size_t i=0; i<allsize[rank]; ++i)
// memcpy(&tarr[0].vertices[0][0] + i*sizeof(Triangle), (char*)&tList[i].vertices[0][0], sizeof(Triangle));
void* const base = &tarr[0].vertices[0][0];
for (size_t i=0; i<allsize[rank]; ++i)
{
for (int j = 0; j < 3; ++j)
{
tarr[i].vertices[j][0] = tList[i].vertices[j][0];
tarr[i].vertices[j][1] = tList[i].vertices[j][1];
tarr[i].vertices[j][2] = tList[i].vertices[j][2];
}
void* const dst = base + i*sizeof(Triangle);
const void* const src = &tList[i].vertices[0][0];
memcpy(dst, src, sizeof(Triangle));
}
// for (size_t i=0; i<allsize[rank]; ++i)
// {
// for (int j = 0; j < 3; ++j)
// {
// tarr[i].vertices[j][0] = tList[i].vertices[j][0];
// tarr[i].vertices[j][1] = tList[i].vertices[j][1];
// tarr[i].vertices[j][2] = tList[i].vertices[j][2];
// }
// }
MPI_File_write_at(file_id, offset, (char *)&tarr[0].vertices[0][0], allsize[rank]*sizeof(Triangle), MPI_CHAR, &status);
}
......@@ -250,7 +250,6 @@ private:
MPI_File_write_at(file_id, offset, (char *)&tcarr[0].n, allsize[rank]*sizeof(TriangleConnect), MPI_CHAR, &status);
}
MPI_Barrier(comm);
if (tcarr != nullptr)
delete [] tcarr;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment