Changeset 4688acf in sasview
- Timestamp:
- Mar 30, 2019 9:15:11 PM (6 years ago)
- Branches:
- master
- Children:
- b2964ef
- Parents:
- 4ecf91a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/fitting/gpu_options.py
r4ecf91a r4688acf 16 16 import wx 17 17 18 # TODO: move device query functions to sasmodels 18 19 try: 19 20 import pyopencl as cl … … 29 30 30 31 logger = logging.getLogger(__name__) 31 32 33 32 34 33 class CustomMessageBox(wx.Dialog): … … 77 76 78 77 self.SetAutoLayout(True) 79 self.ShowModal()80 self.Destroy()81 78 82 79 … … 145 142 test_btn = wx.Button(self, test_id, 'Test') 146 143 test_btn.SetToolTipString("Test if models compile on the given infrastructure") 144 self.test_btn = test_btn 147 145 148 146 self.Bind(wx.EVT_BUTTON, self.on_OK, accept_btn) … … 180 178 :return: 181 179 """ 180 # TODO: Include cuda platforms if available. 182 181 clinfo = [] 183 182 platforms = [] … … 267 266 if "SAS_OPENCL" in os.environ: 268 267 del os.environ["SAS_OPENCL"] 269 sasmodels.sasview_model.reset_environment() 268 # CRUFT: next version of reset_environment() will return env 269 env = sasmodels.sasview_model.reset_environment() 270 270 271 271 try: 272 272 env = sasmodels.kernelcl.environment() 273 ctx = env.context[F64].devices[0] 274 clinfo = ('64bit: ', ctx.platform.vendor, 275 ctx.platform.version, 276 ctx.vendor, 277 ctx.name, 278 ctx.version) 279 if F32 in env.context: 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: 280 287 ctx32 = env.context[F32].devices[0] 281 if ctx32 != ctx: 282 clinfo += ('32bit: ', ctx32.platform.vendor, 283 ctx32.platform.version, 284 ctx32.vendor, 285 ctx32.name, 286 ctx32.version) 287 except Exception: 288 clinfo = None 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() 289 319 290 320 failures = [] 291 321 tests_completed = 0 292 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: 293 325 try: 294 test() 295 except Exception: 296 failures.append(test.description) 297 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) 298 333 tests_completed += 1 299 300 info = { 301 'version': sasmodels.__version__, 302 'platform': platform.uname(), 303 'opencl': clinfo, 304 'failing tests': failures, 305 } 306 307 msg_info = 'OpenCL tests results' 308 309 msg = str(tests_completed)+' tests completed.\n' 310 if len(failures) > 0: 311 msg += str(len(failures))+' tests failed.\n' 312 msg += 'Failing tests: ' 313 msg += json.dumps(info['failing tests']) 314 msg += "\n" 315 else: 316 msg += "All tests passed!\n" 317 318 msg += "\nPlatform Details:\n\n" 319 msg += "Sasmodels version: " 320 msg += info['version']+"\n" 321 msg += "\nPlatform used: " 322 msg += json.dumps(info['platform'])+"\n" 323 if no_opencl_msg: 324 msg += "\nOpenCL driver: None" 325 else: 326 msg += "\nOpenCL driver: " 327 msg += json.dumps(info['opencl'])+"\n" 328 329 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() 330 342 331 343 def on_help(self, event):
Note: See TracChangeset
for help on using the changeset viewer.