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 :(
> 
> try: queue=pyopencl.CommandQueue(ctx)
> except RuntimeError: print("Sorry, switched off")

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.
"""

So I wouldn't be too disappointed with a well-placed try/except block fixing 
the problem.


Kind regards,
Alex
_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl

Reply via email to