Bruce Labitt
2014-09-13 19:44:01 UTC
I'm trying to port an FDTD code to pycuda and have run into a problem. The
error occurs when using slices.
Known error?
All variables are gpuarray. Fails in main time loop.
In [4]: run fdtd_pycuda.py
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in
execfile(fname, *where)
202 else:
203 filename = fname
--> 204 __builtin__.execfile(filename, *where)
/home/bruce/FDTD/fdtd_pycuda.py in <module>()
554
555 bx[1:ie_tot,:,:] = D1hx[1:ie_tot,:,:] * bx[1:ie_tot,:,:] -
D2hx[1:ie_tot,:,:] * \
--> 556 ( ( ez[1:ie_tot, 1:jh_tot, :] - ez[1:ie_tot, 0:je_tot,
:]) - ( ey[1:ie_tot,:,1:kh_tot] - ey[1:ie_tot,:,0:ke_tot] ) ) / delta
557 """
558 above line generates RunTimeError: only contiguous arrays
may be used as arguments to this operation
/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/gpuarray.pyc
in __sub__(self, other)
425 if isinstance(other, GPUArray):
426 result = self._new_like_me(_get_common_dtype(self,
other))
--> 427 return self._axpbyz(1, other, -1, result)
428 else:
429 if other == 0:
/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/gpuarray.pyc
in _axpbyz(self, selffac, other, otherfac, out, add_timer, stream)
308 assert self.shape == other.shape
309 if not self.flags.forc or not other.flags.forc:
--> 310 raise RuntimeError("only contiguous arrays may "
311 "be used as arguments to this operation")
312
RuntimeError: only contiguous arrays may be used as arguments to this
operation
Evaluating the following generates the RuntimeError.
In [17]: ( ey[1:ie_tot,:,1:kh_tot] - ey[1:ie_tot,:,0:ke_tot] )
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-17-1c6dfb98d933> in <module>()
----> 1 ( ey[1:ie_tot,:,1:kh_tot] - ey[1:ie_tot,:,0:ke_tot] )
/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/gpuarray.pyc
in __sub__(self, other)
425 if isinstance(other, GPUArray):
426 result = self._new_like_me(_get_common_dtype(self,
other))
--> 427 return self._axpbyz(1, other, -1, result)
428 else:
429 if other == 0:
/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/gpuarray.pyc
in _axpbyz(self, selffac, other, otherfac, out, add_timer, stream)
308 assert self.shape == other.shape
309 if not self.flags.forc or not other.flags.forc:
--> 310 raise RuntimeError("only contiguous arrays may "
311 "be used as arguments to this operation")
312
RuntimeError: only contiguous arrays may be used as arguments to this
operation
ey.shape = (111, 110, 111)
kh_tot = 111
ke_tot = 110
Shapes are appropriate.
Work arounds for slices? Straight numpy implementation works fine.
Thanks,
Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tiker.net/pipermail/pycuda/attachments/20140913/8414133b/attachment.html>
error occurs when using slices.
Known error?
All variables are gpuarray. Fails in main time loop.
In [4]: run fdtd_pycuda.py
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in
execfile(fname, *where)
202 else:
203 filename = fname
--> 204 __builtin__.execfile(filename, *where)
/home/bruce/FDTD/fdtd_pycuda.py in <module>()
554
555 bx[1:ie_tot,:,:] = D1hx[1:ie_tot,:,:] * bx[1:ie_tot,:,:] -
D2hx[1:ie_tot,:,:] * \
--> 556 ( ( ez[1:ie_tot, 1:jh_tot, :] - ez[1:ie_tot, 0:je_tot,
:]) - ( ey[1:ie_tot,:,1:kh_tot] - ey[1:ie_tot,:,0:ke_tot] ) ) / delta
557 """
558 above line generates RunTimeError: only contiguous arrays
may be used as arguments to this operation
/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/gpuarray.pyc
in __sub__(self, other)
425 if isinstance(other, GPUArray):
426 result = self._new_like_me(_get_common_dtype(self,
other))
--> 427 return self._axpbyz(1, other, -1, result)
428 else:
429 if other == 0:
/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/gpuarray.pyc
in _axpbyz(self, selffac, other, otherfac, out, add_timer, stream)
308 assert self.shape == other.shape
309 if not self.flags.forc or not other.flags.forc:
--> 310 raise RuntimeError("only contiguous arrays may "
311 "be used as arguments to this operation")
312
RuntimeError: only contiguous arrays may be used as arguments to this
operation
Evaluating the following generates the RuntimeError.
In [17]: ( ey[1:ie_tot,:,1:kh_tot] - ey[1:ie_tot,:,0:ke_tot] )
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-17-1c6dfb98d933> in <module>()
----> 1 ( ey[1:ie_tot,:,1:kh_tot] - ey[1:ie_tot,:,0:ke_tot] )
/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/gpuarray.pyc
in __sub__(self, other)
425 if isinstance(other, GPUArray):
426 result = self._new_like_me(_get_common_dtype(self,
other))
--> 427 return self._axpbyz(1, other, -1, result)
428 else:
429 if other == 0:
/usr/local/lib/python2.7/dist-packages/pycuda-2014.1-py2.7-linux-x86_64.egg/pycuda/gpuarray.pyc
in _axpbyz(self, selffac, other, otherfac, out, add_timer, stream)
308 assert self.shape == other.shape
309 if not self.flags.forc or not other.flags.forc:
--> 310 raise RuntimeError("only contiguous arrays may "
311 "be used as arguments to this operation")
312
RuntimeError: only contiguous arrays may be used as arguments to this
operation
ey.shape = (111, 110, 111)
kh_tot = 111
ke_tot = 110
Shapes are appropriate.
Work arounds for slices? Straight numpy implementation works fine.
Thanks,
Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.tiker.net/pipermail/pycuda/attachments/20140913/8414133b/attachment.html>