On Thu, 22 Nov 2012 20:54:58 +0000 Alex Leach <[email protected]> wrote:
> Hi, > > On Thursday 22 Nov 2012 21:22:16 Jerome Kieffer wrote: > <snip> > > Question: Is there a way within PyOpenCL to know if a device is actually > > available or not ? The flag: device.available is set to 1 regardless if the > > GPU is actually ON or OFF. The only unacceptable solution I found is based > > on try/except :( I need to amend what I said: device.available is 0 when freshly booted with device switched OFF. Overall it is trick to know if the device is working or not; especially that it is dynamic... One needs to restart python to have values actualized. > Sorry, I can't be much help, but thought I'd make a general comment about > Python coding style.. > > >From http://docs.python.org/2/glossary.html: > > """ > EAFP > Easier to ask for forgiveness than permission. This common Python coding > style > assumes the existence of valid keys or attributes and catches exceptions if > the assumption proves false. This clean and fast style is characterized by > the > presence of many try and except statements. The technique contrasts with the > LBYL style common to many other languages such as C. > """ I prefer import this: In the face of ambiguity, refuse the temptation to guess. -- Jérôme Kieffer On-Line Data analysis / Software Group ISDD / ESRF tel +33 476 882 445 _______________________________________________ PyOpenCL mailing list [email protected] http://lists.tiker.net/listinfo/pyopencl
