Changes in / [fa307dd:b2964ef] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/gpu_options.py
r895703d r4688acf 16 16 import wx 17 17 18 # TODO: move device query functions to sasmodels 18 19 try: 19 20 import pyopencl as cl … … 24 25 import sasmodels.model_test 25 26 import sasmodels.sasview_model 27 from sasmodels.generate import F32, F64 26 28 27 29 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 28 30 29 31 logger = logging.getLogger(__name__) 30 31 32 32 33 33 class CustomMessageBox(wx.Dialog): … … 76 76 77 77 self.SetAutoLayout(True) 78 self.ShowModal()79 self.Destroy()80 78 81 79 … … 144 142 test_btn = wx.Button(self, test_id, 'Test') 145 143 test_btn.SetToolTipString("Test if models compile on the given infrastructure") 144 self.test_btn = test_btn 146 145 147 146 self.Bind(wx.EVT_BUTTON, self.on_OK, accept_btn) … … 179 178 :return: 180 179 """ 180 # TODO: Include cuda platforms if available. 181 181 clinfo = [] 182 182 platforms = [] … … 257 257 #The same block of code as for OK but it is needed if we want to have 258 258 #active response to Test button 259 259 260 no_opencl_msg = False 260 261 if self.sas_opencl: … … 265 266 if "SAS_OPENCL" in os.environ: 266 267 del os.environ["SAS_OPENCL"] 267 sasmodels.sasview_model.reset_environment() 268 # CRUFT: next version of reset_environment() will return env 269 env = sasmodels.sasview_model.reset_environment() 268 270 269 271 try: 270 272 env = sasmodels.kernelcl.environment() 271 clinfo = [(ctx.devices[0].platform.vendor, 272 ctx.devices[0].platform.version, 273 ctx.devices[0].vendor, 274 ctx.devices[0].name, 275 ctx.devices[0].version) 276 for ctx in env.context] 277 except Exception: 278 clinfo = None 273 clinfo = {} 274 if env.context[F64] is None: 275 clinfo['double'] = "None" 276 else: 277 ctx64 = env.context[F64].devices[0] 278 clinfo['double'] = ", ".join(( 279 ctx64.platform.vendor, 280 ctx64.platform.version, 281 ctx64.vendor, 282 ctx64.name, 283 ctx64.version)) 284 if env.context[F32] is None: 285 clinfo['single'] = "None" 286 else: 287 ctx32 = env.context[F32].devices[0] 288 clinfo['single'] = ", ".join(( 289 ctx32.platform.vendor, 290 ctx32.platform.version, 291 ctx32.vendor, 292 ctx32.name, 293 ctx32.version)) 294 # If the same device is used for single and double precision, then 295 # say so. Whether double is the same as single or single is the 296 # same as double depends on the order they are listed below. 297 if env.context[F32] == env.context[F64]: 298 clinfo['double'] = "same as single precision" 299 except Exception as exc: 300 logger.debug("exc %s", str(exc)) 301 clinfo = {'double': "None", 'single': "None"} 302 303 msg = "\nPlatform Details:\n\n" 304 msg += "Sasmodels version: " 305 msg += sasmodels.__version__ + "\n" 306 msg += "\nPlatform used: " 307 msg += json.dumps(platform.uname()) + "\n" 308 if no_opencl_msg: 309 msg += "\nOpenCL driver: None\n" 310 else: 311 msg += "\nOpenCL driver:\n" 312 msg += " single precision: " + clinfo['single'] + "\n" 313 msg += " double precision: " + clinfo['double'] + "\n" 314 315 msg_title = 'OpenCL tests results' 316 running = msg + "\nRunning tests. This may take several minutes.\n\n" 317 msg_dialog = CustomMessageBox(self.panel1, running, msg_title) 318 msg_dialog.Show() 279 319 280 320 failures = [] 281 321 tests_completed = 0 282 for test in sasmodels.model_test.model_tests(): 322 self.test_btn.Disable() 323 tests = sasmodels.model_test.make_suite('opencl', ['all']) 324 for test in tests: 283 325 try: 284 test() 285 except Exception: 286 failures.append(test.description) 287 326 wx.Yield() 327 test.run_all() 328 msg_dialog.text.AppendText('.') 329 except Exception as exc: 330 logger.debug("%s failed with %s", test.test_name, str(exc)) 331 msg_dialog.text.AppendText('\nFail: ' + test.test_name) 332 failures.append(test.test_name) 288 333 tests_completed += 1 289 290 info = { 291 'version': sasmodels.__version__, 292 'platform': platform.uname(), 293 'opencl': clinfo, 294 'failing tests': failures, 295 } 296 297 msg_info = 'OpenCL tests results' 298 299 msg = str(tests_completed)+' tests completed.\n' 300 if len(failures) > 0: 301 msg += str(len(failures))+' tests failed.\n' 302 msg += 'Failing tests: ' 303 msg += json.dumps(info['failing tests']) 304 msg += "\n" 305 else: 306 msg += "All tests passed!\n" 307 308 msg += "\nPlatform Details:\n\n" 309 msg += "Sasmodels version: " 310 msg += info['version']+"\n" 311 msg += "\nPlatform used: " 312 msg += json.dumps(info['platform'])+"\n" 313 if no_opencl_msg: 314 msg += "\nOpenCL driver: None" 315 else: 316 msg += "\nOpenCL driver: " 317 msg += json.dumps(info['opencl'])+"\n" 318 319 CustomMessageBox(self.panel1, msg, msg_info) 334 # TODO: Put a stop button in CustomDialog and test it here. 335 #if tests_completed > 5: break 336 337 status = 'Failed %d of %d' % (len(failures), tests_completed) 338 msg_dialog.text.AppendText('\n\n' + status + '\n') 339 self.test_btn.Enable() 340 msg_dialog.ShowModal() 341 msg_dialog.Destroy() 320 342 321 343 def on_help(self, event):
Note: See TracChangeset
for help on using the changeset viewer.