From 640d3d780d96099b8acdf17fd22dc33fa519ca39 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 11 Dec 2009 23:24:17 +0000 Subject: [PATCH] - manager: add GPU always/auto/never menu items svn path=/trunk/boinc/; revision=19866 --- checkin_notes | 9 +++++ clientgui/AdvancedFrame.cpp | 60 ++++++++++++++++++++++++++++++++++ clientgui/AdvancedFrame.h | 2 ++ clientgui/Events.h | 3 ++ lib/daemonmgt.h | 65 ++++++++++++++++++------------------- 5 files changed, 106 insertions(+), 33 deletions(-) diff --git a/checkin_notes b/checkin_notes index ae3a95fabf..a3668b56e9 100644 --- a/checkin_notes +++ b/checkin_notes @@ -9942,3 +9942,12 @@ David 11 Dec 2009 sched/ sched_customize.cpp,h sched_types.h + +David 11 Dec 2009 + - manager: add GPU always/auto/never menu items + + clientgui + AdvancedFrame.cpp,h + Events.h + lib/ + daemonmgt.h diff --git a/clientgui/AdvancedFrame.cpp b/clientgui/AdvancedFrame.cpp index daf4624e16..c0271de7ca 100644 --- a/clientgui/AdvancedFrame.cpp +++ b/clientgui/AdvancedFrame.cpp @@ -166,6 +166,7 @@ BEGIN_EVENT_TABLE (CAdvancedFrame, CBOINCBaseFrame) EVT_MENU(ID_WIZARDDETACH, CAdvancedFrame::OnWizardDetach) // Activity EVT_MENU_RANGE(ID_ADVACTIVITYRUNALWAYS, ID_ADVACTIVITYSUSPEND, CAdvancedFrame::OnActivitySelection) + EVT_MENU_RANGE(ID_ADVACTIVITYGPUALWAYS, ID_ADVACTIVITYGPUSUSPEND, CAdvancedFrame::OnGPUSelection) EVT_MENU_RANGE(ID_ADVNETWORKRUNALWAYS, ID_ADVNETWORKSUSPEND, CAdvancedFrame::OnNetworkSelection) // Advanced EVT_MENU(ID_OPTIONS, CAdvancedFrame::OnOptions) @@ -446,6 +447,25 @@ bool CAdvancedFrame::CreateMenu( bool bRPCsSafe ) { _("&Suspend"), _("Stop work regardless of preferences") ); + if (pDoc->state.have_cuda || pDoc->state.have_ati) { + menuActivity->AppendSeparator(); + menuActivity->AppendRadioItem( + ID_ADVACTIVITYGPUALWAYS, + _("Use GPU always"), + _("Allow GPU work regardless of preferences") + ); + menuActivity->AppendRadioItem( + ID_ADVACTIVITYGPUBASEDONPREPERENCES, + _("Use GPU based on &preferences"), + _("Allow GPU work according to your preferences") + ); + menuActivity->AppendRadioItem( + ID_ADVACTIVITYGPUSUSPEND, + _("Use GPU never"), + _("Stop GPU work regardless of preferences") + ); + } + #if defined(__WXMSW__) || defined(__WXMAC__) menuActivity->AppendSeparator(); @@ -1153,6 +1173,25 @@ void CAdvancedFrame::OnActivitySelection(wxCommandEvent& event) { wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnActivitySelection - Function End")); } +void CAdvancedFrame::OnGPUSelection(wxCommandEvent& event) { + CMainDocument* pDoc = wxGetApp().GetDocument(); + + wxASSERT(pDoc); + wxASSERT(wxDynamicCast(pDoc, CMainDocument)); + + switch(event.GetId()) { + case ID_ADVACTIVITYGPUALWAYS: + pDoc->SetGPURunMode(RUN_MODE_ALWAYS, 0); + break; + case ID_ADVACTIVITYGPUSUSPEND: + pDoc->SetGPURunMode(RUN_MODE_NEVER, 0); + break; + case ID_ADVACTIVITYGPUBASEDONPREPERENCES: + pDoc->SetGPURunMode(RUN_MODE_AUTO, 0); + break; + } +} + void CAdvancedFrame::OnNetworkSelection(wxCommandEvent& event) { wxLogTrace(wxT("Function Start/End"), wxT("CAdvancedFrame::OnNetworkSelection - Function Begin")); @@ -1779,6 +1818,7 @@ void CAdvancedFrame::OnFrameRender(wxTimerEvent& WXUNUSED(event)) { CC_STATUS status; if ((pDoc->IsConnected()) && (0 == pDoc->GetCoreClientStatus(status))) { UpdateActivityModeControls(status); + UpdateGPUModeControls(status); UpdateNetworkModeControls(status); if (status.disallow_attach) { @@ -1911,6 +1951,26 @@ void CAdvancedFrame::UpdateActivityModeControls( CC_STATUS& status ) { pMenuBar->Check(ID_ADVACTIVITYRUNBASEDONPREPERENCES, true); } +void CAdvancedFrame::UpdateGPUModeControls( CC_STATUS& status ) { + wxMenuBar* pMenuBar = GetMenuBar(); + wxASSERT(pMenuBar); + wxASSERT(wxDynamicCast(pMenuBar, wxMenuBar)); + + if ((RUN_MODE_ALWAYS == status.gpu_mode) && pMenuBar->IsChecked(ID_ADVACTIVITYGPUALWAYS)) return; + if ((RUN_MODE_NEVER == status.gpu_mode) && pMenuBar->IsChecked(ID_ADVACTIVITYGPUSUSPEND)) return; + if ((RUN_MODE_AUTO == status.gpu_mode) && pMenuBar->IsChecked(ID_ADVACTIVITYGPUBASEDONPREPERENCES)) return; + + pMenuBar->Check(ID_ADVACTIVITYGPUALWAYS, false); + pMenuBar->Check(ID_ADVACTIVITYGPUSUSPEND, false); + pMenuBar->Check(ID_ADVACTIVITYGPUBASEDONPREPERENCES, false); + if (RUN_MODE_ALWAYS == status.gpu_mode) + pMenuBar->Check(ID_ADVACTIVITYGPUALWAYS, true); + if (RUN_MODE_NEVER == status.gpu_mode) + pMenuBar->Check(ID_ADVACTIVITYGPUSUSPEND, true); + if (RUN_MODE_AUTO == status.gpu_mode) + pMenuBar->Check(ID_ADVACTIVITYGPUBASEDONPREPERENCES, true); +} + void CAdvancedFrame::UpdateNetworkModeControls( CC_STATUS& status ) { wxMenuBar* pMenuBar = GetMenuBar(); diff --git a/clientgui/AdvancedFrame.h b/clientgui/AdvancedFrame.h index b78ad0f20c..dc6f7dbe61 100644 --- a/clientgui/AdvancedFrame.h +++ b/clientgui/AdvancedFrame.h @@ -76,6 +76,7 @@ public: void OnWizardDetach( wxCommandEvent& event ); void OnActivitySelection( wxCommandEvent& event ); + void OnGPUSelection( wxCommandEvent& event ); void OnNetworkSelection( wxCommandEvent& event ); void OnOptions( wxCommandEvent& event ); @@ -139,6 +140,7 @@ private: void SaveWindowDimensions(); void UpdateActivityModeControls( CC_STATUS& status ); + void UpdateGPUModeControls( CC_STATUS& status ); void UpdateNetworkModeControls( CC_STATUS& status ); void UpdateRefreshTimerInterval( wxInt32 iCurrentNotebookPage ); diff --git a/clientgui/Events.h b/clientgui/Events.h index 24d709536e..9617a80b07 100644 --- a/clientgui/Events.h +++ b/clientgui/Events.h @@ -70,6 +70,9 @@ #define ID_ADVNETWORKRUNALWAYS 6014 #define ID_ADVNETWORKRUNBASEDONPREPERENCES 6015 #define ID_ADVNETWORKSUSPEND 6016 +#define ID_ADVACTIVITYGPUALWAYS 6017 +#define ID_ADVACTIVITYGPUBASEDONPREPERENCES 6018 +#define ID_ADVACTIVITYGPUSUSPEND 6019 // Advanced Menu #define ID_OPTIONS 6017 diff --git a/lib/daemonmgt.h b/lib/daemonmgt.h index 30fcb34a04..e5271601b7 100644 --- a/lib/daemonmgt.h +++ b/lib/daemonmgt.h @@ -1,33 +1,32 @@ -// This file is part of BOINC. -// http://boinc.berkeley.edu -// Copyright (C) 2008 University of California -// -// BOINC is free software; you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation, -// either version 3 of the License, or (at your option) any later version. -// -// BOINC is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with BOINC. If not, see . - -#ifndef _BOINC_DAEMONMANAGEMENT_H_ -#define _BOINC_DAEMONMANAGEMENT_H_ - -extern bool is_daemon_installed(); -extern bool is_daemon_starting(); -extern bool is_daemon_running(); -extern bool is_daemon_stopping(); -extern bool is_daemon_stopped(); - - -extern bool start_daemon_via_daemonctrl(); -extern bool start_daemon(); -extern bool stop_daemon_via_daemonctrl(); -extern bool stop_daemon(); - -#endif \ No newline at end of file +// This file is part of BOINC. +// http://boinc.berkeley.edu +// Copyright (C) 2008 University of California +// +// BOINC is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// BOINC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with BOINC. If not, see . + +#ifndef _BOINC_DAEMONMANAGEMENT_H_ +#define _BOINC_DAEMONMANAGEMENT_H_ + +extern bool is_daemon_installed(); +extern bool is_daemon_starting(); +extern bool is_daemon_running(); +extern bool is_daemon_stopping(); +extern bool is_daemon_stopped(); + +extern bool start_daemon_via_daemonctrl(); +extern bool start_daemon(); +extern bool stop_daemon_via_daemonctrl(); +extern bool stop_daemon(); + +#endif