Skip to content

Commit 85f3b4d

Browse files
committed
New batch (multi-app) mode added to PMCtrack-GUI
1 parent 09c9ee2 commit 85f3b4d

File tree

10 files changed

+707
-397
lines changed

10 files changed

+707
-397
lines changed

src/gui/backend/pmc_connect.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,25 @@ class PMCConnect(object):
3232
def __init__(self, info_machine):
3333
self.info_machine = info_machine
3434
if info_machine.is_remote:
35-
self.ssh_str = info_machine.GetSSHCommand()
35+
self.ssh_array = info_machine.GetSSHCommand().split()
3636

3737
def CheckFileExists(self, file):
38+
if file != "" and file != "\n" and file.find("#") == -1:
3839
if self.info_machine.is_remote:
39-
command = self.ssh_str.split()
40-
command.append("cat " + file)
41-
pipe = Popen(command, stdout=PIPE, stderr=PIPE)
42-
stdout, stderr = pipe.communicate()
43-
ok = (stderr == "")
40+
command = self.ssh_array[:]
41+
command.append("ls " + file)
42+
pipe = Popen(command, stdout=PIPE, stderr=PIPE)
43+
stdout, stderr = pipe.communicate()
44+
ok = (stderr == "")
4445
else:
45-
ok = os.path.exists(file)
46-
return ok
46+
ok = os.path.exists(file)
47+
else:
48+
ok = False
49+
return ok
4750

4851
def CheckPkgInstalled(self, pkg, remote):
4952
command = None
50-
if remote: command = self.ssh_str.split()
53+
if remote: command = self.ssh_array[:]
5154
else: command = []
5255
command.append(pkg)
5356
try:
@@ -59,9 +62,9 @@ def CheckPkgInstalled(self, pkg, remote):
5962
return installed
6063

6164
def CheckConnectivity(self):
62-
ssh_array = self.ssh_str.split()
63-
ssh_array.append("whoami")
64-
pipe = Popen(ssh_array, stdout=PIPE, stderr=PIPE)
65+
command = self.ssh_array[:]
66+
command.append("whoami")
67+
pipe = Popen(command, stdout=PIPE, stderr=PIPE)
6568
stdout, stderr = pipe.communicate()
6669
msg_error = ""
6770
if (stdout.find(self.info_machine.remote_user) != 0):
@@ -79,12 +82,12 @@ def CheckConnectivity(self):
7982

8083
def ReadFile(self, file):
8184
if self.info_machine.is_remote:
82-
ssh_array = self.ssh_str.split()
83-
ssh_array.append("cat " + file)
84-
pipe = Popen(ssh_array, stdout=PIPE, stderr=PIPE)
85-
result = pipe.stdout.read()
85+
command = self.ssh_array[:]
86+
command.append("cat " + file)
87+
pipe = Popen(command, stdout=PIPE, stderr=PIPE)
88+
result = pipe.stdout.read()
8689
else:
87-
descrip = open(file, 'rU')
88-
result = descrip.read()
89-
descrip.close()
90+
descrip = open(file, 'rU')
91+
result = descrip.read()
92+
descrip.close()
9093
return result

src/gui/backend/pmc_extract.py

Lines changed: 148 additions & 110 deletions
Large diffs are not rendered by default.

src/gui/backend/user_config.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def __init__(self):
100100
self.experiments = [] # List of experiments
101101
self.virtual_counters = [] # List of selected virtual counters
102102
self.machine = None # Information about monitoring machine
103-
self.path_benchmark = None
104-
self.args_benchmark = None
103+
self.applications = []
105104
self.cpu = None # CPU number where to run benchmark, or CPU mask
106105
self.time = 0 # Time between samples (in miliseconds)
107106
self.buffer_size = 0 # Samples buffer size (in bytes)
@@ -132,8 +131,8 @@ def GetCopy(self):
132131
for vcounter in self.virtual_counters:
133132
copy.virtual_counters.append(vcounter)
134133

135-
copy.path_benchmark = self.path_benchmark
136-
copy.args_benchmark = self.args_benchmark
134+
for application in self.applications:
135+
copy.applications.append(application)
137136
copy.cpu = self.cpu
138137
copy.time = self.time
139138
copy.buffer_size = self.buffer_size

src/gui/frontend/final_config_panel.py

Lines changed: 132 additions & 64 deletions
Large diffs are not rendered by default.

src/gui/frontend/graph_style_dialog.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def __init__(self, *args, **kwds):
7979
self.__do_layout()
8080

8181
self.Bind(wx.EVT_LISTBOX, self.on_select_mode, self.list_modes)
82+
self.Bind(wx.EVT_LISTBOX_DCLICK, self.on_dclick_list_modes, self.list_modes)
8283
self.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_change_bg_color, self.button_bg_color)
8384
self.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_change_grid_color, self.button_grid_color)
8485
self.Bind(wx.EVT_COLOURPICKER_CHANGED, self.on_change_line_color, self.button_line_color)
@@ -165,6 +166,11 @@ def __set_colors(self, bg_color, grid_color, line_color, line_style, line_width)
165166

166167
self.canvas.draw()
167168

169+
def on_dclick_list_modes(self, event):
170+
style_conf = self.list_modes.GetClientData(self.list_modes.GetSelection())
171+
self.__set_colors(style_conf.bg_color, style_conf.grid_color, style_conf.line_color, style_conf.line_style, style_conf.line_width)
172+
self.EndModal(0)
173+
168174
def on_select_mode(self, event):
169175
if self.first_time and self.is_customized:
170176
self.list_modes.SetSelection(wx.NOT_FOUND)

src/gui/frontend/machine_config_panel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ def on_click_next(self, event):
194194
self.__save_user_config()
195195
pmc_connect = PMCConnect(self.config_frame.user_config.machine)
196196
if self.__validate(pmc_connect):
197+
self.config_frame.pmc_connect = pmc_connect
197198
self.config_frame.facade_xml = FacadeXML(pmc_connect)
198199
self.config_frame.GoToPanel(1)
199200
if self.config_frame.panels[2] != None:
200-
self.config_frame.panels[2].UpdateCtrlBenchmark()
201+
self.config_frame.panels[2].UpdateCtrlPathSingleApp()
201202
self.config_frame.panels[2].UpdateComboCPU()

src/gui/frontend/monitoring_frame.py

Lines changed: 73 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ def __init__(self, *args, **kwargs):
4444
kwds = {"style": wx.DEFAULT_FRAME_STYLE}
4545
wx.Frame.__init__(self, *args, **kwds)
4646

47+
self.app_name = kwargs.get("app_name")
4748
self.version = kwargs.get("version")
4849
self.final_panel = kwargs.get("final_panel")
4950
self.user_config = kwargs.get("user_config")
5051
self.pack = kwargs.get("pack", "")
5152
self.num_exp = kwargs.get("num_exp", 0)
5253
self.num_metric = kwargs.get("num_metric", 0)
53-
self.name_benchmark = self.user_config.path_benchmark.split("/")[-1].split()[0]
5454

5555
# Indicates whether the graph is shown fully or only partly present.
5656
self.show_complete = False
@@ -83,7 +83,7 @@ def __init__(self, *args, **kwargs):
8383
metrics.append(metric.name)
8484
self.combo_metric = wx.ComboBox(self, wx.ID_ANY, choices=metrics, style=wx.CB_DROPDOWN | wx.CB_READONLY)
8585

86-
self.combo_pack = wx.ComboBox(self, wx.ID_ANY, choices=sorted(self.final_panel.pmc_extract.data.keys()), style=wx.CB_DROPDOWN | wx.CB_READONLY)
86+
self.combo_pack = wx.ComboBox(self, wx.ID_ANY, choices=sorted(self.final_panel.pmc_extract.data[self.app_name].keys()), style=wx.CB_DROPDOWN | wx.CB_READONLY)
8787
self.label_pack = wx.StaticText(self, -1, self.name_pack + ": ")
8888
self.label_exp = wx.StaticText(self, -1, _("Experiment") + ": ")
8989
self.label_metric = wx.StaticText(self, -1, _("Metric") + ": ")
@@ -121,15 +121,24 @@ def __init__(self, *args, **kwargs):
121121
self.fig.canvas.mpl_connect('button_press_event', self.on_click_graph)
122122

123123
def __set_properties(self):
124-
self.SetTitle("PMCTrack-GUI v" + self.version + " - " + _("Monitoring application '{0}'").format(self.name_benchmark))
124+
self.SetTitle("PMCTrack-GUI v" + self.version + " - " + _("Monitoring application '{0}'").format(self.app_name.split()[0]))
125125
self.SetSize((750, 640))
126-
if self.pack != "":
126+
if self.combo_pack.GetCount() > 0:
127+
if self.pack != "":
127128
self.combo_pack.SetStringSelection(self.pack)
128-
metric = self.user_config.experiments[self.num_exp].metrics[self.num_metric].name.encode("utf-8")
129-
self.sizer_graph_staticbox.SetLabel(_("Showing graph with {0} {1}, experiment {2} and metric '{3}'").format(self.name_pack, self.pack, (self.num_exp + 1), metric))
130-
else:
129+
else:
130+
self.combo_pack.SetSelection(0)
131+
self.pack = self.combo_pack.GetStringSelection()
132+
metric = self.user_config.experiments[self.num_exp].metrics[self.num_metric].name.encode("utf-8")
133+
self.sizer_graph_staticbox.SetLabel(_("Showing graph with {0} {1}, experiment {2} and metric '{3}'").format(self.name_pack, self.pack, (self.num_exp + 1), metric))
134+
else:
135+
self.SetTitle(self.GetTitle() + " " + _("(waiting)"))
131136
self.button_this_window.Disable()
132137
self.button_other_window.Disable()
138+
self.button_change_vis_graph.Disable()
139+
self.button_screenshot.Disable()
140+
self.button_hide_controls.Disable()
141+
self.button_stop_monitoring.Disable()
133142

134143
self.combo_exp.SetSelection(self.num_exp)
135144
self.combo_metric.SetSelection(self.num_metric)
@@ -200,7 +209,7 @@ def __init_plot(self):
200209
self.canvas = FigCanvas(self, -1, self.fig)
201210

202211
def __draw_plot(self):
203-
graph_data = self.final_panel.pmc_extract.data[self.pack][self.num_exp][self.num_metric]
212+
graph_data = self.final_panel.pmc_extract.data[self.app_name][self.pack][self.num_exp][self.num_metric]
204213

205214
# Updates the minimum and maximum value of the graph that is displayed (only if it's worth)
206215
if len(graph_data[self.samples_draw[self.num_exp].get(self.pack, 0):]) > 0:
@@ -238,42 +247,53 @@ def __change_vis_controls(self, show):
238247
self.separator.Layout()
239248

240249
def on_timer_update_data(self, event):
241-
packs_count = self.combo_pack.GetCount()
242-
# If a new pack (pid or cpu) is detected update the corresponding graphical controls.
243-
if len(self.final_panel.pmc_extract.data) > packs_count:
244-
self.combo_pack.SetItems(sorted(self.final_panel.pmc_extract.data))
245-
if packs_count > 0:
246-
self.combo_pack.SetStringSelection(self.pack)
247-
else: # If the first pack (pid or cpu) is detected as what we are currently monitoring pack.
248-
self.combo_pack.SetSelection(0)
249-
self.pack = self.combo_pack.GetStringSelection()
250-
metric = self.user_config.experiments[self.num_exp].metrics[self.num_metric].name.encode("utf-8")
251-
self.sizer_graph_staticbox.SetLabel(_("Showing graph with {0} {1}, experiment {2} and metric '{3}'").format(self.name_pack, self.pack, (self.num_exp + 1), metric))
252-
self.button_this_window.Enable()
253-
self.button_other_window.Enable()
254-
255-
if self.pack != "":
256-
num_graph_data = len(self.final_panel.pmc_extract.data[self.pack][self.num_exp][self.num_metric])
257-
258-
# Only if there are outstanding paint painting to the pack (pid or cpu) being displayed data.
259-
if num_graph_data > self.samples_draw[self.num_exp].get(self.pack, 0):
260-
self.__draw_plot()
261-
self.samples_draw[self.num_exp][self.pack] = num_graph_data
262-
263-
if self.final_panel.pmc_extract.state == 'F':
264-
self.timer_update_data.Stop()
265-
self.SetTitle(self.GetTitle() + " " + _("(finished)"))
266-
self.button_stop_monitoring.Disable()
267-
if len(self.final_panel.mon_frames) > 0 and self.final_panel.mon_frames[0] == self:
268-
self.final_panel.button_monitoring.SetLabel(_("Close monitoring windows"))
269-
dlg = wx.MessageDialog(parent=None, message=_("The application '{0}' is done.").format(self.name_benchmark),
270-
caption=_("Information"), style=wx.OK|wx.ICON_INFORMATION)
271-
dlg.ShowModal()
272-
dlg.Destroy()
273-
elif self.final_panel.pmc_extract.state == 'S':
274-
self.timer_update_data.Stop()
275-
self.SetTitle(self.GetTitle() + " " + _("(stopped)"))
276-
self.button_stop_monitoring.SetLabel(_("Resume application"))
250+
if self.final_panel.pmc_extract.error != None and len(self.user_config.applications) == 1:
251+
error_msg = _("PMCTrack error") + ":\n" + self.final_panel.pmc_extract.error
252+
dlg = wx.MessageDialog(parent=None, message=error_msg, caption=_("Error"), style=wx.OK | wx.ICON_ERROR)
253+
if dlg.ShowModal() == wx.ID_OK:
254+
self.final_panel.StopMonitoring(False)
255+
else:
256+
packs_count = self.combo_pack.GetCount()
257+
# If a new pack (pid or cpu) is detected update the corresponding graphical controls.
258+
if len(self.final_panel.pmc_extract.data[self.app_name]) > packs_count:
259+
self.combo_pack.SetItems(sorted(self.final_panel.pmc_extract.data[self.app_name]))
260+
if packs_count > 0:
261+
self.combo_pack.SetStringSelection(self.pack)
262+
else: # If the first pack (pid or cpu) is detected as what we are currently monitoring pack.
263+
self.combo_pack.SetSelection(0)
264+
self.pack = self.combo_pack.GetStringSelection()
265+
metric = self.user_config.experiments[self.num_exp].metrics[self.num_metric].name.encode("utf-8")
266+
self.SetTitle("PMCTrack-GUI v" + self.version + " - " + _("Monitoring application '{0}'").format(self.app_name.split()[0]))
267+
self.sizer_graph_staticbox.SetLabel(_("Showing graph with {0} {1}, experiment {2} and metric '{3}'").format(self.name_pack, self.pack, (self.num_exp + 1), metric))
268+
self.button_this_window.Enable()
269+
self.button_other_window.Enable()
270+
self.button_change_vis_graph.Enable()
271+
self.button_screenshot.Enable()
272+
self.button_hide_controls.Enable()
273+
self.button_stop_monitoring.Enable()
274+
275+
if self.pack != "":
276+
num_graph_data = len(self.final_panel.pmc_extract.data[self.app_name][self.pack][self.num_exp][self.num_metric])
277+
278+
# Only if there are outstanding paint painting to the pack (pid or cpu) being displayed data.
279+
if num_graph_data > self.samples_draw[self.num_exp].get(self.pack, 0):
280+
self.__draw_plot()
281+
self.samples_draw[self.num_exp][self.pack] = num_graph_data
282+
283+
if self.final_panel.pmc_extract.state[self.app_name] == 'F':
284+
self.timer_update_data.Stop()
285+
self.SetTitle(self.GetTitle() + " " + _("(finished)"))
286+
self.button_stop_monitoring.Disable()
287+
if len(self.final_panel.mon_frames) > 0 and len(self.user_config.applications) == 1 and self.final_panel.mon_frames[0] == self:
288+
self.final_panel.button_monitoring.SetLabel(_("Close monitoring windows"))
289+
dlg = wx.MessageDialog(parent=None, message=_("The application '{0}' is done.").format(self.app_name.split()[0]),
290+
caption=_("Information"), style=wx.OK|wx.ICON_INFORMATION)
291+
dlg.ShowModal()
292+
dlg.Destroy()
293+
elif self.final_panel.pmc_extract.state[self.app_name] == 'S':
294+
self.timer_update_data.Stop()
295+
self.SetTitle(self.GetTitle() + " " + _("(stopped)"))
296+
self.button_stop_monitoring.SetLabel(_("Resume application"))
277297

278298
def on_click_this_window(self, event):
279299
self.pack = self.combo_pack.GetStringSelection()
@@ -282,7 +302,7 @@ def on_click_this_window(self, event):
282302
metric = self.user_config.experiments[self.num_exp].metrics[self.num_metric].name.encode('utf-8')
283303
self.sizer_graph_staticbox.SetLabel(_("Showing graph with {0} {1}, experiment {2} and metric '{3}'").format(self.name_pack, self.pack, (self.num_exp + 1), metric))
284304
self.axes.set_ylabel(metric.decode('utf-8'))
285-
graph_data = self.final_panel.pmc_extract.data[self.pack][self.num_exp][self.num_metric]
305+
graph_data = self.final_panel.pmc_extract.data[self.app_name][self.pack][self.num_exp][self.num_metric]
286306
if self.samples_draw[self.num_exp].get(self.pack, 0) > 0:
287307
self.minval = min(graph_data[0:self.samples_draw[self.num_exp][self.pack]])
288308
self.maxval = max(graph_data[0:self.samples_draw[self.num_exp][self.pack]])
@@ -295,7 +315,7 @@ def on_click_other_window(self, event):
295315
sel_pack = self.combo_pack.GetStringSelection()
296316
sel_exp = self.combo_exp.GetSelection()
297317
sel_met = self.combo_metric.GetSelection()
298-
mon_frame = MonitoringFrame(None, -1, "", version=self.version, final_panel=self.final_panel, user_config=self.user_config, pack=sel_pack, num_exp=sel_exp, num_metric=sel_met)
318+
mon_frame = MonitoringFrame(None, -1, "", app_name=self.app_name, version=self.version, final_panel=self.final_panel, user_config=self.user_config, pack=sel_pack, num_exp=sel_exp, num_metric=sel_met)
299319
mon_frame.Show()
300320

301321
def on_change_experiment(self, event):
@@ -308,7 +328,7 @@ def on_change_experiment(self, event):
308328
def on_click_graph(self, event):
309329
if self.fig.canvas.HasCapture():
310330
self.fig.canvas.ReleaseMouse()
311-
if self.graph_style_dialog.ShowModal() == 0:
331+
if self.final_panel.pmc_extract.state[self.app_name] != "W" and self.graph_style_dialog.ShowModal() == 0:
312332
self.axes.set_axis_bgcolor(self.graph_style_dialog.GetBgColor())
313333
self.axes.grid(True, color=self.graph_style_dialog.GetGridColor())
314334
self.plot_data.set_linewidth(self.graph_style_dialog.GetLineWidth())
@@ -325,14 +345,15 @@ def on_click_change_vis_graph(self, event):
325345
self.__draw_plot()
326346

327347
def on_click_stop_monitoring(self, event):
328-
if self.final_panel.pmc_extract.state == 'R':
348+
if self.final_panel.pmc_extract.state[self.app_name] == 'R':
329349
self.final_panel.pmc_extract.StopMonitoring()
330-
elif self.final_panel.pmc_extract.state == 'S':
350+
elif self.final_panel.pmc_extract.state[self.app_name] == 'S':
331351
self.final_panel.pmc_extract.ResumeMonitoring()
332352
for mon_frame in self.final_panel.mon_frames:
353+
if mon_frame.app_name == self.app_name:
333354
mon_frame.timer_update_data.Start(100)
334355
mon_frame.button_stop_monitoring.SetLabel(_("Stop application"))
335-
mon_frame.SetTitle("PMCTrack-GUI v" + self.version + " - " + _("Monitoring application '{0}'").format(self.name_benchmark))
356+
mon_frame.SetTitle("PMCTrack-GUI v" + self.version + " - " + _("Monitoring application '{0}'").format(self.app_name.split()[0]))
336357

337358
def on_click_screenshot(self, event):
338359
metric = self.user_config.experiments[self.num_exp].metrics[self.num_metric].name
@@ -342,7 +363,7 @@ def on_click_screenshot(self, event):
342363
self,
343364
message=_("Save graph screenshot as..."),
344365
defaultDir=os.getcwd(),
345-
defaultFile="{0}-{1}-{2}.png".format(self.pack, self.num_exp, metric.replace(" ", "_")),
366+
defaultFile="{0}-{1}-{2}-{3}.png".format(self.app_name.split()[0], self.pack, self.num_exp, metric.replace(" ", "_")),
346367
wildcard=file_choices,
347368
style=wx.SAVE)
348369

@@ -357,7 +378,7 @@ def on_click_show_controls(self, event):
357378
self.__change_vis_controls(True)
358379

359380
def on_close_frame(self, event):
360-
if len(self.final_panel.mon_frames) > 1:
381+
if len(self.final_panel.mon_frames) > 1 or len(self.user_config.applications) > 1:
361382
self.final_panel.mon_frames.remove(self)
362383
self.graph_style_dialog.Destroy()
363384
self.Destroy()

0 commit comments

Comments
 (0)