Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BenchTickWriter(object):
- def __init__(self, mpi_comm, filename, data):
- self.mycomm = mpi_comm
- self.selfcomm = MPI.COMM_SELF # each rank is its own communicator since this is file per process
- self.filename = filename
- self.data = data
- self.open_mask = mode = MPI.MODE_WRONLY|MPI.MODE_UNIQUE_OPEN|MPI.MODE_APPEND
- #self.open_mask = mode = MPI.MODE_WRONLY|MPI.MODE_UNIQUE_OPEN|MPI.MODE_CREATE
- self.timings = {}
- self.fd = self.open_file(self.filename, self.open_mask)
- return
- def open_file(self, filename, mask):
- return MPI.File.Open(self.selfcomm, filename, amode=mask)
- def write_data(self):
- bytes_written = 0
- mpistatus = MPI.Status()
- start_time = get_time()
- rc = MPI.File.Write_all(self.fd, self.data, status=mpistatus)
- bytes_written += mpistatus.count
- total_time = get_time() - start_time
- self.timings['write_data_tm'] = total_time
- self.timings['write_data_bytes'] = bytes_written
- return bytes_written
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement