def write_timing_message(self, timing_msg: TimingMessage):
     if self.time_writer is not None:
         timing_msg.record_time(self.rank)
         self.time_writer.write_timing_message(timing_msg=timing_msg)
     else:
         self.class_log.warning(
             'Tried writing timing message before timing file created.')
Example #2
0
    def setUp(self):
        self.msgs_to_save = []
        msg = TimingMessage(label='Test', timestamp=100, start_rank=1)
        msg.record_time(rank=2)
        msg.record_time(rank=3)
        self.msgs_to_save.append(msg)
        self.msgs_to_save.append(msg)
        msg2 = TimingMessage(label='Test2', timestamp=101, start_rank=1)
        self.msgs_to_save.append(msg2)

        self.save_dir = '/tmp'
        self.prefix = 'test'
        self.mpi_rank = 0
        self.postfix = 'timing'
Example #3
0
    def test_TimingMessage_eq(self):
        msg_bytes = self.msg.pack()
        msg_unpack = TimingMessage.unpack(message_bytes=msg_bytes)

        new_msg = TimingMessage(label='Test', timestamp=100, start_rank=1)
        new_msg.record_time(rank=2)
        new_msg.record_time(rank=3)

        self.assertIsNot(
            self.msg, msg_unpack, 'The msg and the deserialized form '
            'should not be the same object: {}, {}.'.format(
                self.msg, msg_unpack))
        self.assertEqual(
            self.msg, msg_unpack, 'The msg and the deserialized form '
            'should be equal: {}, {}.'.format(self.msg, msg_unpack))
        self.assertNotEqual(
            self.msg, new_msg, 'Two messages created at different times '
            'should be different: {}, {}'.format(self.msg, new_msg))
Example #4
0
class TestTimingMessage(TestCase):
    def setUp(self):
        self.msg = TimingMessage(label='Test', timestamp=100, start_rank=1)
        self.msg.record_time(rank=2)
        self.msg.record_time(rank=3)

    def test_TimingMessage_serialization(self):

        msg_bytes = self.msg.pack()
        msg_unpack = TimingMessage.unpack(message_bytes=msg_bytes)

        self.assertEqual(
            self.msg.label, msg_unpack.label,
            'Serialization failed, labels do not match ({}, {})'.format(
                self.msg.label, msg_unpack.label))

        self.assertEqual(
            self.msg.timestamp, msg_unpack.timestamp,
            'Serialization failed, timestamps do not match ({}, {})'.format(
                self.msg.timestamp, msg_unpack.timestamp))

        self.assertEqual(
            self.msg.timing_data, msg_unpack.timing_data,
            'Serialization failed, timing_data does not match ({}, {})'.format(
                self.msg.timing_data, msg_unpack.timing_data))

    def test_TimingMessage_eq(self):
        msg_bytes = self.msg.pack()
        msg_unpack = TimingMessage.unpack(message_bytes=msg_bytes)

        new_msg = TimingMessage(label='Test', timestamp=100, start_rank=1)
        new_msg.record_time(rank=2)
        new_msg.record_time(rank=3)

        self.assertIsNot(
            self.msg, msg_unpack, 'The msg and the deserialized form '
            'should not be the same object: {}, {}.'.format(
                self.msg, msg_unpack))
        self.assertEqual(
            self.msg, msg_unpack, 'The msg and the deserialized form '
            'should be equal: {}, {}.'.format(self.msg, msg_unpack))
        self.assertNotEqual(
            self.msg, new_msg, 'Two messages created at different times '
            'should be different: {}, {}'.format(self.msg, new_msg))
Example #5
0
    def test_TimingMessage_serialization(self):

        msg_bytes = self.msg.pack()
        msg_unpack = TimingMessage.unpack(message_bytes=msg_bytes)

        self.assertEqual(
            self.msg.label, msg_unpack.label,
            'Serialization failed, labels do not match ({}, {})'.format(
                self.msg.label, msg_unpack.label))

        self.assertEqual(
            self.msg.timestamp, msg_unpack.timestamp,
            'Serialization failed, timestamps do not match ({}, {})'.format(
                self.msg.timestamp, msg_unpack.timestamp))

        self.assertEqual(
            self.msg.timing_data, msg_unpack.timing_data,
            'Serialization failed, timing_data does not match ({}, {})'.format(
                self.msg.timing_data, msg_unpack.timing_data))
 def forward_timing_message(self, timing_msg: timing_system.TimingMessage):
     self.comm.Send(buf=timing_msg.pack(),
                    dest=self.config['rank']['supervisor'],
                    tag=realtime_base.MPIMessageTag.TIMING_MESSAGE.value)
Example #7
0
 def setUp(self):
     self.msg = TimingMessage(label='Test', timestamp=100, start_rank=1)
     self.msg.record_time(rank=2)
     self.msg.record_time(rank=3)