Skip to content

Commit

Permalink
Merge pull request #9 from adityapb/pysph-travis
Browse files Browse the repository at this point in the history
Update massage_args method to fix issues with pyopencl
  • Loading branch information
prabhuramachandran committed Feb 17, 2019
2 parents cbc775f + 6a987c3 commit 79cba2f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
os:
ubuntu

dist:
xenial

language: python
python:
- 2.7
- 3.6
- 3.7

install:
- sudo apt-get update
Expand Down
6 changes: 3 additions & 3 deletions compyle/jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def _generate_kernel(self, *args):
def _massage_arg(self, x):
if isinstance(x, array.Array):
return x.dev
elif isinstance(x, np.ndarray):
elif self.backend != 'cuda' or isinstance(x, np.ndarray):
return x
else:
return np.asarray(x)
Expand Down Expand Up @@ -353,7 +353,7 @@ def _generate_kernel(self, *args):
def _massage_arg(self, x):
if isinstance(x, array.Array):
return x.dev
elif isinstance(x, np.ndarray):
elif self.backend != 'cuda' or isinstance(x, np.ndarray):
return x
else:
return np.asarray(x)
Expand Down Expand Up @@ -459,7 +459,7 @@ def _generate_kernel(self, **kwargs):
def _massage_arg(self, x):
if isinstance(x, array.Array):
return x.dev
elif isinstance(x, np.ndarray):
elif self.backend != 'cuda' or isinstance(x, np.ndarray):
return x
else:
return np.asarray(x)
Expand Down
12 changes: 9 additions & 3 deletions compyle/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,10 @@ def _add_address_space(arg):
def _massage_arg(self, x):
if isinstance(x, array.Array):
return x.dev
else:
elif self.backend != 'cuda' or isinstance(x, np.ndarray):
return x
else:
return np.asarray(x)

def __call__(self, *args, **kw):
c_args = [self._massage_arg(x) for x in args]
Expand Down Expand Up @@ -704,8 +706,10 @@ def _correct_opencl_address_space(self, c_data):
def _massage_arg(self, x):
if isinstance(x, array.Array):
return x.dev
else:
elif self.backend != 'cuda' or isinstance(x, np.ndarray):
return x
else:
return np.asarray(x)

def __call__(self, *args):
c_args = [self._massage_arg(x) for x in args]
Expand Down Expand Up @@ -1061,8 +1065,10 @@ def _correct_opencl_address_space(self, c_data, func, func_type):
def _massage_arg(self, x):
if isinstance(x, array.Array):
return x.dev
else:
elif self.backend != 'cuda' or isinstance(x, np.ndarray):
return x
else:
return np.asarray(x)

def __call__(self, **kwargs):
c_args_dict = {k: self._massage_arg(x) for k, x in kwargs.items()}
Expand Down

0 comments on commit 79cba2f

Please sign in to comment.