How to use waitAny method in fMBT

Best Python code snippet using fMBT_python

otf2_reader.py

Source:otf2_reader.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import re3import pandas as pd4from otf2Parser.otf2_2_ascii import All_traces_ascii5from pathlib import Path6 7def event_time(tracepath):8 Tracer_loop_time = 09 Tracer_walltime_time = 010 Isend_time = 011 Irecv_time = 012 Waitall_time = 013 Alltoall_time = 014 Waitany_time = 015 Allreduce_time = 016 Reduce_time = 017 Barrier_time = 018 Testany_time = 019 20 loop_init_time = 021 loop_final_time = 022 23 Contents = Path(tracepath).read_text()24 25 Re_Tracer_loop_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"TRACER_Loop"\s+<(\d+)>\n'26 Re_Tracer_loop_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"TRACER_Loop"\s+<(\d+)>\n'27 Re_Tracer_walltime_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"TRACER_WallTime_stencil4d"\s+<(\d+)>\n'28 Re_Tracer_walltime_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"TRACER_WallTime_stencil4d"\s+<(\d+)>\n'29 Re_Tracer_walltime_a2a_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"TRACER_WallTime_a2a"\s+<(\d+)>\n'30 Re_Tracer_walltime_a2a_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"TRACER_WallTime_a2a"\s+<(\d+)>\n'31 Re_Isend_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Isend"\s+<(\d+)>\n'32 Re_Isend_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Isend"\s+<(\d+)>\n'33 Re_Irecv_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Irecv"\s+<(\d+)>\n'34 Re_Irecv_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Irecv"\s+<(\d+)>\n'35 Re_waitall_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Waitall"\s+<(\d+)>\n'36 Re_waitall_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Waitall"\s+<(\d+)>\n'37 Re_alltoall_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Alltoall"\s+<(\d+)>\n'38 Re_alltoall_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Alltoall"\s+<(\d+)>\n'39 Re_waitany_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Waitany"\s+<(\d+)>\n'40 Re_waitany_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Waitany"\s+<(\d+)>\n'41 Re_allreduce_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Allreduce"\s+<(\d+)>\n'42 Re_allreduce_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Allreduce"\s+<(\d+)>\n'43 Re_reduce_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Reduce"\s+<(\d+)>\n'44 Re_reduce_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Reduce"\s+<(\d+)>\n'45 Re_barrier_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Barrier"\s+<(\d+)>\n'46 Re_barrier_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Barrier"\s+<(\d+)>\n'47 Re_testany_enter = 'ENTER\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Testany"\s+<(\d+)>\n'48 Re_testany_leave = 'LEAVE\s*(\d+)\s*(\d+)\s*Region:\s+"MPI_Testany"\s+<(\d+)>\n'49 50 Tracer_loop_enter = re.compile(Re_Tracer_loop_enter)51 Tracer_loop_leave = re.compile(Re_Tracer_loop_leave)52 Tracer_walltime_enter = re.compile(Re_Tracer_walltime_enter)53 Tracer_walltime_leave = re.compile(Re_Tracer_walltime_leave)54 Isend_enter = re.compile(Re_Isend_enter)55 Isend_leave = re.compile(Re_Isend_leave)56 Irecv_enter = re.compile(Re_Irecv_enter)57 Irecv_leave = re.compile(Re_Irecv_leave)58 Waitall_enter = re.compile(Re_waitall_enter)59 Waitall_leave = re.compile(Re_waitall_leave)60 Alltoall_enter = re.compile(Re_alltoall_enter)61 Alltoall_leave = re.compile(Re_alltoall_leave)62 Waitany_enter = re.compile(Re_waitany_enter)63 Waitany_leave = re.compile(Re_waitany_leave)64 Allreduce_enter = re.compile(Re_allreduce_enter)65 Allreduce_leave = re.compile(Re_allreduce_leave)66 Reduce_enter = re.compile(Re_reduce_enter)67 Reduce_leave = re.compile(Re_reduce_leave)68 Barrier_enter = re.compile(Re_barrier_enter)69 Barrier_leave = re.compile(Re_barrier_leave)70 Testany_enter = re.compile(Re_testany_enter)71 Testany_leave = re.compile(Re_testany_leave)72 73 Result_Tracer_loop_enter = Tracer_loop_enter.findall(Contents)74 Result_Tracer_loop_leave = Tracer_loop_leave.findall(Contents)75 Result_Tracer_walltime_enter = Tracer_walltime_enter.findall(Contents)76 Result_Tracer_walltime_leave = Tracer_walltime_leave.findall(Contents)77 Result_Isend_enter = Isend_enter.findall(Contents)78 Result_Isend_leave = Isend_leave.findall(Contents)79 Result_Irecv_enter = Irecv_enter.findall(Contents)80 Result_Irecv_leave = Irecv_leave.findall(Contents)81 Result_waitall_enter = Waitall_enter.findall(Contents)82 Result_waitall_leave = Waitall_leave.findall(Contents) 83 Result_Alltoall_enter = Alltoall_enter.findall(Contents)84 Result_Alltoall_leave = Alltoall_leave.findall(Contents)85 Result_Waitany_enter = Waitany_enter.findall(Contents)86 Result_Waitany_leave = Waitany_leave.findall(Contents)87 Result_Allreduce_enter = Allreduce_enter.findall(Contents)88 Result_Allreduce_leave = Allreduce_leave.findall(Contents)89 Result_Reduce_enter = Reduce_enter.findall(Contents)90 Result_Reduce_leave = Reduce_leave.findall(Contents)91 Result_Barrier_enter = Barrier_enter.findall(Contents)92 Result_Barrier_leave = Barrier_leave.findall(Contents)93 Result_Testany_enter = Testany_enter.findall(Contents)94 Result_Testany_leave = Testany_leave.findall(Contents)95 96 97 if(len(Result_Tracer_loop_leave) == len(Result_Tracer_loop_enter)) and (len(Result_Tracer_loop_enter) == 1):98 Tracer_loop_time = int(Result_Tracer_loop_leave[0][1]) - int(Result_Tracer_loop_enter[0][1])99 loop_init_time = int(Result_Tracer_loop_enter[0][1])100 loop_final_time = int(Result_Tracer_loop_leave[0][1])101 else:102 print("Tracer loop not recorded correctly")103 104 if(len(Result_Tracer_walltime_leave) == len(Result_Tracer_walltime_enter)) \105 and (len(Result_Tracer_walltime_enter) == 1) \106 and loop_init_time <= int(Result_Tracer_walltime_leave[0][1]) <= loop_final_time \107 and loop_init_time <= int(Result_Tracer_walltime_enter[0][1]) <= loop_final_time:108 Tracer_walltime_time = int(Result_Tracer_walltime_leave[0][1]) - int(Result_Tracer_walltime_enter[0][1])109 110 if(len(Result_Isend_enter) == len(Result_Isend_leave)) and (len(Result_Isend_enter) > 0):111 for i, j in enumerate(zip(Result_Isend_leave, Result_Isend_enter)):112 if loop_init_time <= int(j[0][1]) <= loop_final_time and loop_init_time <= int(j[1][1]) <= loop_final_time:113 Isend_time += (int(j[0][1]) - int(j[1][1]))114 115 if(len(Result_Irecv_enter) == len(Result_Irecv_leave)) and (len(Result_Irecv_enter) > 0):116 for i, j in enumerate(zip(Result_Irecv_leave, Result_Irecv_enter)):117 if loop_init_time <= int(j[0][1]) <= loop_final_time and loop_init_time <= int(j[1][1]) <= loop_final_time:118 Irecv_time += (int(j[0][1]) - int(j[1][1]))119 if(len(Result_waitall_enter) == len(Result_waitall_leave)) and (len(Result_waitall_enter) > 0):120 for i, j in enumerate(zip(Result_waitall_leave, Result_waitall_enter)):121 if loop_init_time <= int(j[0][1]) <= loop_final_time and loop_init_time <= int(j[1][1]) <= loop_final_time:122 Waitall_time += (int(j[0][1]) - int(j[1][1]))123 124 if(len(Result_Alltoall_enter) == len(Result_Alltoall_leave)) and (len(Result_Alltoall_enter) > 0):125 for i, j in enumerate(zip(Result_Alltoall_leave, Result_Alltoall_enter)):126 if loop_init_time <= int(j[0][1]) <= loop_final_time and loop_init_time <= int(j[1][1]) <= loop_final_time:127 Alltoall_time += (int(j[0][1]) - int(j[1][1]))128 129 if(len(Result_Waitany_enter) == len(Result_Waitany_leave)) and (len(Result_Waitany_enter) > 0):130 for i, j in enumerate(zip(Result_Waitany_leave, Result_Waitany_enter)):131 if loop_init_time <= int(j[0][1]) <= loop_final_time and loop_init_time <= int(j[1][1]) <= loop_final_time:132 Waitany_time += (int(j[0][1]) - int(j[1][1]))133 134 if(len(Result_Allreduce_enter) == len(Result_Allreduce_leave)) and (len(Result_Allreduce_enter) > 0):135 for i, j in enumerate(zip(Result_Allreduce_leave, Result_Allreduce_enter)):136 if loop_init_time <= int(j[0][1]) <= loop_final_time and loop_init_time <= int(j[1][1]) <= loop_final_time:137 Allreduce_time += (int(j[0][1]) - int(j[1][1]))138 139 if(len(Result_Reduce_enter) == len(Result_Reduce_leave)) and (len(Result_Reduce_enter) > 0):140 for i, j in enumerate(zip(Result_Reduce_leave, Result_Reduce_enter)):141 if loop_init_time <= int(j[0][1]) <= loop_final_time and loop_init_time <= int(j[1][1]) <= loop_final_time:142 Reduce_time += (int(j[0][1]) - int(j[1][1]))143 144 if(len(Result_Barrier_enter) == len(Result_Barrier_leave)) and (len(Result_Barrier_enter) > 0):145 for i, j in enumerate(zip(Result_Barrier_leave, Result_Barrier_enter)):146 if loop_init_time <= int(j[0][1]) <= loop_final_time and loop_init_time <= int(j[1][1]) <= loop_final_time:147 Barrier_time += (int(j[0][1]) - int(j[1][1]))148 149 if(len(Result_Testany_enter) == len(Result_Testany_leave)) and (len(Result_Testany_enter) > 0):150 for i, j in enumerate(zip(Result_Testany_leave, Result_Testany_enter)):151 if loop_init_time <= int(j[0][1]) <= loop_final_time and loop_init_time <= int(j[1][1]) <= loop_final_time:152 Testany_time += (int(j[0][1]) - int(j[1][1]))153 154 return {'Tracer_loop_time': Tracer_loop_time,155 'Tracer_walltime_time': Tracer_walltime_time,156 'Isend_time': Isend_time,157 'Irecv_time': Irecv_time,158 'Waitall_time': Waitall_time,159 'Alltoall_time': Alltoall_time,160 'Waitany_time': Waitany_time,161 'Allreduce_time': Allreduce_time,162 'Reduce_time': Reduce_time,163 'Barrier_time': Barrier_time,164 'Testany_time': Testany_time}165def read_otf():166 traceName = []167 ticksPerSecond = []168 tracerLoopTime = []169 communicationTime = []170 computationTime = []171 percentageOfCommunication = []172 for num, i in enumerate(All_traces_ascii[0]):173 print('Trace Name : {}'.format(str(i[0])))174 Tracer_loop_time_total = 0175 Tracer_walltime_time_total = 0176 Isend_time_total = 0177 Irecv_time_total = 0178 Waitall_time_totat = 0 179 Alltoall_time_total = 0180 Waitany_time_total = 0181 Allreduce_time_total = 0182 Reduce_time_total = 0183 Barrier_time_total = 0184 Testany_time_total = 0185 for j in range(int(i[1])):186 File_name = 'ascii_{}.out'.format(j)187 Time_event_dict = event_time(Path(i[0], File_name))188# print(Time_event_dict)189 Tracer_loop_time_total += Time_event_dict.get('Tracer_loop_time')190 Tracer_walltime_time_total += Time_event_dict.get('Tracer_walltime_time')191 Isend_time_total += Time_event_dict.get('Isend_time')192 Irecv_time_total += Time_event_dict.get('Irecv_time')193 Waitall_time_totat += Time_event_dict.get('Waitall_time')194 Alltoall_time_total += Time_event_dict.get('Alltoall_time')195 Waitany_time_total += Time_event_dict.get('Waitany_time')196 Allreduce_time_total += Time_event_dict.get('Allreduce_time')197 Reduce_time_total += Time_event_dict.get('Reduce_time')198 Barrier_time_total += Time_event_dict.get('Barrier_time')199 Testany_time_total += Time_event_dict.get('Testany_time')200 Ticks_per_second = int(All_traces_ascii[1][num][0][0])201# print('Ticks per second : {}'.format(Ticks_per_second))202 comm_time = Isend_time_total + Irecv_time_total + Waitall_time_totat + Alltoall_time_total + Waitany_time_total +Allreduce_time_total + Reduce_time_total + Barrier_time_total + Testany_time_total203# print('Tracer loop time : {}'.format( Tracer_loop_time_total / Ticks_per_second ))204# print('Communication time : {}'.format( comm_time / Ticks_per_second ))205# print('Computation time : {}'.format( (Tracer_loop_time_total - comm_time) / Ticks_per_second ))206# print('Percentage of computation : {}'.format((Tracer_loop_time_total - comm_time)/Tracer_loop_time_total * 100))207 traceName.append(str(i[0]))208 ticksPerSecond.append(int(All_traces_ascii[1][num][0][0]))209 tracerLoopTime.append(Tracer_loop_time_total / Ticks_per_second)210 communicationTime.append(comm_time / Ticks_per_second)211 computationTime.append((Tracer_loop_time_total - comm_time) / Ticks_per_second)212 percentageOfCommunication.append((Tracer_loop_time_total - comm_time)/Tracer_loop_time_total * 100)213 df = pd.DataFrame({214 'Trace Name': traceName,215 'Ticks per second': ticksPerSecond216 })217 print(df)...

Full Screen

Full Screen

test_request.py

Source:test_request.py Github

copy

Full Screen

1from mpi4py import MPI2import mpiunittest as unittest3class TestRequest(unittest.TestCase):4 def setUp(self):5 self.REQUEST = MPI.Request()6 self.STATUS = MPI.Status()7 def testWait(self):8 self.REQUEST.Wait()9 self.REQUEST.Wait(None)10 self.REQUEST.Wait(self.STATUS)11 self.REQUEST.wait()12 self.REQUEST.wait(None)13 self.REQUEST.wait(self.STATUS)14 def testTest(self):15 self.REQUEST.Wait()16 self.REQUEST.Wait(None)17 self.REQUEST.Test(self.STATUS)18 self.REQUEST.wait()19 self.REQUEST.wait(None)20 self.REQUEST.test(self.STATUS)21 def testGetStatus(self):22 try: flag = self.REQUEST.Get_status()23 except NotImplementedError: return24 self.assertTrue(flag)25 flag = self.REQUEST.Get_status(self.STATUS)26 self.assertTrue(flag)27 self.assertEqual(self.STATUS.Get_source(), MPI.ANY_SOURCE)28 self.assertEqual(self.STATUS.Get_tag(), MPI.ANY_TAG)29 self.assertEqual(self.STATUS.Get_error(), MPI.SUCCESS)30 self.assertEqual(self.STATUS.Get_count(MPI.BYTE), 0)31 self.assertEqual(self.STATUS.Get_elements(MPI.BYTE), 0)32 try: self.assertFalse(self.STATUS.Is_cancelled())33 except NotImplementedError: pass34class TestRequestArray(unittest.TestCase):35 def setUp(self):36 self.REQUESTS = [MPI.Request() for i in range(5)]37 self.STATUSES = [MPI.Status() for i in range(5)]38 def testWaitany(self):39 MPI.Request.Waitany(self.REQUESTS)40 MPI.Request.Waitany(self.REQUESTS, None)41 MPI.Request.Waitany(self.REQUESTS, self.STATUSES[0])42 MPI.Request.waitany(self.REQUESTS)43 MPI.Request.waitany(self.REQUESTS, None)44 MPI.Request.waitany(self.REQUESTS, self.STATUSES[0])45 def testTestany(self):46 MPI.Request.Testany(self.REQUESTS)47 MPI.Request.Testany(self.REQUESTS, None)48 MPI.Request.Testany(self.REQUESTS, self.STATUSES[0])49 MPI.Request.testany(self.REQUESTS)50 MPI.Request.testany(self.REQUESTS, None)51 MPI.Request.testany(self.REQUESTS, self.STATUSES[0])52 def testWaitall(self):53 MPI.Request.Waitall(self.REQUESTS)54 MPI.Request.Waitall(self.REQUESTS, None)55 for statuses in (tuple(self.STATUSES), (self.STATUSES[0],), ()):56 MPI.Request.Waitall(self.REQUESTS, statuses)57 for statuses in (self.STATUSES, []):58 MPI.Request.Waitall(self.REQUESTS, statuses)59 self.assertEqual(len(statuses), len(self.REQUESTS))60 MPI.Request.waitall(self.REQUESTS)61 MPI.Request.waitall(self.REQUESTS, None)62 for statuses in (self.STATUSES, []):63 MPI.Request.waitall(self.REQUESTS, statuses)64 self.assertEqual(len(statuses), len(self.REQUESTS))65 def testTestall(self):66 MPI.Request.Testall(self.REQUESTS)67 MPI.Request.Testall(self.REQUESTS, None)68 for statuses in (self.STATUSES, []):69 MPI.Request.Testall(self.REQUESTS, statuses)70 self.assertEqual(len(statuses), len(self.REQUESTS))71 MPI.Request.testall(self.REQUESTS)72 MPI.Request.testall(self.REQUESTS, None)73 for statuses in (self.STATUSES, []):74 MPI.Request.testall(self.REQUESTS, statuses)75 self.assertEqual(len(statuses), len(self.REQUESTS))76 def testWaitsome(self):77 ret = MPI.Request.Waitsome(self.REQUESTS)78 self.assertEqual(ret, None)79 ret = MPI.Request.Waitsome(self.REQUESTS, None)80 self.assertEqual(ret, None)81 for statuses in (self.STATUSES, []):82 ret = MPI.Request.Waitsome(self.REQUESTS, statuses)83 self.assertEqual(ret, None)84 self.assertEqual(len(statuses), len(self.REQUESTS))85 def testTestsome(self):86 ret = MPI.Request.Testsome(self.REQUESTS)87 self.assertEqual(ret, None)88 ret = MPI.Request.Testsome(self.REQUESTS, None)89 self.assertEqual(ret, None)90 for statuses in (self.STATUSES, []):91 ret = MPI.Request.Testsome(self.REQUESTS, statuses)92 self.assertEqual(ret, None)93 self.assertEqual(len(statuses), len(self.REQUESTS))94name, version = MPI.get_vendor()95if name == 'MPICH1' or name == 'LAM/MPI':96 del TestRequest.testGetStatus97if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful