Commit 86b189d0 authored by Markus Holzer's avatar Markus Holzer
Browse files

Merge branch 'pycuda-not-avaible-handler' into 'master'

Throw an error when performing GPU operations with SerialDataHandling when pycuda is not available

See merge request pycodegen/pystencils!164
parents 7005aac5 f5d3f8d9
......@@ -39,3 +39,9 @@ class PyCudaArrayHandler:
return self.to_gpu(cpu_array)
from_numpy = to_gpu
class PyCudaNotAvailableHandler:
def __getattribute__(self, name):
raise NotImplementedError("Unable to initiaize PyCuda! "
"Try to run `import pycuda.autoinit` to check whether PyCuda is working correctly!")
......@@ -6,7 +6,7 @@ import numpy as np
from pystencils.datahandling.blockiteration import SerialBlock
from pystencils.datahandling.datahandling_interface import DataHandling
from pystencils.datahandling.pycuda import PyCudaArrayHandler
from pystencils.datahandling.pycuda import PyCudaArrayHandler, PyCudaNotAvailableHandler
from pystencils.datahandling.pyopencl import PyOpenClArrayHandler
from pystencils.field import (
Field, FieldType, create_numpy_array_with_layout, layout_string_to_tuple,
......@@ -53,7 +53,7 @@ class SerialDataHandling(DataHandling):
try:
self.array_handler = PyCudaArrayHandler()
except Exception:
self.array_handler = None
self.array_handler = PyCudaNotAvailableHandler()
if default_target == 'opencl' or opencl_queue:
self.array_handler = PyOpenClArrayHandler(opencl_queue)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment