Skip to content

Commit

Permalink
file write ordered
Browse files Browse the repository at this point in the history
  • Loading branch information
patflick committed Sep 10, 2018
1 parent d8e9224 commit 20bd82a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/mxx/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ std::string file_block_decompose(const char* filename, MPI_Comm comm = MPI_COMM_
return local_str;
}

template <typename T>
void write_ordered(const std::string& filename, const T* buf, size_t count, const mxx::comm& comm) {
MPI_File handle;
MPI_File_open(comm, &filename[0], MPI_MODE_CREATE | MPI_MODE_WRONLY, MPI_INFO_NULL, &handle);
mxx::datatype dt = mxx::get_datatype<T>();
MPI_File_write_ordered(handle, const_cast<T*>(buf), count, dt.type(), MPI_STATUS_IGNORE);
MPI_File_close(&handle);
}
template <typename T>
void write_ordered(const std::string& filename, const std::vector<T>& data, const mxx::comm& comm) {
write_ordered(filename, data.data(), data.size(), comm);
}

template <typename _Iterator>
void write_files(const std::string& filename, _Iterator begin, _Iterator end, MPI_Comm comm = MPI_COMM_WORLD)
{
Expand Down Expand Up @@ -142,6 +155,7 @@ void write_files(const std::string& filename, _Iterator begin, _Iterator end, MP
outfs.close();
}


} // namespace mxx

#endif // MXX_FILE_HPP

0 comments on commit 20bd82a

Please sign in to comment.