コード例 #1
0
ファイル: gpuarray.py プロジェクト: Benli11/pycuda
    def func(self, other):
        if not self.flags.forc:
            raise RuntimeError("only contiguous arrays may "
                    "be used as arguments to this operation")

        if isinstance(other, GPUArray):
            assert self.shape == other.shape

            if not other.flags.forc:
                raise RuntimeError("only contiguous arrays may "
                        "be used as arguments to this operation")

            result = self._new_like_me()
            func = elementwise.get_binary_op_kernel(
                    self.dtype, other.dtype, result.dtype,
                    operator)
            func.prepared_async_call(self._grid, self._block, None,
                    self.gpudata, other.gpudata, result.gpudata,
                    self.mem_size)

            return result
        else:  # scalar operator
            result = self._new_like_me()
            func = elementwise.get_scalar_op_kernel(
                    self.dtype, result.dtype, operator)
            func.prepared_async_call(self._grid, self._block, None,
                    self.gpudata, other, result.gpudata,
                    self.mem_size)
            return result
コード例 #2
0
    def func(self, other):
        if not self.flags.forc:
            raise RuntimeError("only contiguous arrays may "
                    "be used as arguments to this operation")

        if isinstance(other, GPUArray):
            assert self.shape == other.shape

            if not other.flags.forc:
                raise RuntimeError("only contiguous arrays may "
                        "be used as arguments to this operation")

            result = self._new_like_me()
            func = elementwise.get_binary_op_kernel(
                    self.dtype, other.dtype, result.dtype,
                    operator)
            func.prepared_async_call(self._grid, self._block, None,
                    self.gpudata, other.gpudata, result.gpudata,
                    self.mem_size)

            return result
        else:  # scalar operator
            result = self._new_like_me()
            func = elementwise.get_scalar_op_kernel(
                    self.dtype, result.dtype, operator)
            func.prepared_async_call(self._grid, self._block, None,
                    self.gpudata, other, result.gpudata,
                    self.mem_size)
            return result
コード例 #3
0
ファイル: gpuarray.py プロジェクト: abergeron/pycuda
    def _elwise_multiply(self, other, out, stream=None):
        if not self.flags.forc:
            raise RuntimeError("only contiguous arrays may " "be used as arguments to this operation")

        func = elementwise.get_binary_op_kernel(self.dtype, other.dtype, out.dtype, "*")
        func.prepared_async_call(
            self._grid, self._block, stream, self.gpudata, other.gpudata, out.gpudata, self.mem_size
        )

        return out
コード例 #4
0
ファイル: gpuarray.py プロジェクト: hvcl-old/Vivaldi
    def _elwise_multiply(self, other, out, stream=None):
        if not self.flags.forc:
            raise RuntimeError("only contiguous arrays may "
                               "be used as arguments to this operation")

        func = elementwise.get_binary_op_kernel(self.dtype, other.dtype,
                                                out.dtype, "*")
        func.prepared_async_call(self._grid, self._block, stream, self.gpudata,
                                 other.gpudata, out.gpudata, self.mem_size)

        return out
コード例 #5
0
ファイル: gpuarray.py プロジェクト: abergeron/pycuda
    def _div(self, other, out, stream=None):
        """Divides an array by another array."""

        if not self.flags.forc or not other.flags.forc:
            raise RuntimeError("only contiguous arrays may " "be used as arguments to this operation")

        assert self.shape == other.shape

        func = elementwise.get_binary_op_kernel(self.dtype, other.dtype, out.dtype, "/")
        func.prepared_async_call(
            self._grid, self._block, stream, self.gpudata, other.gpudata, out.gpudata, self.mem_size
        )

        return out
コード例 #6
0
ファイル: gpuarray.py プロジェクト: hvcl-old/Vivaldi
    def _div(self, other, out, stream=None):
        """Divides an array by another array."""

        if not self.flags.forc or not other.flags.forc:
            raise RuntimeError("only contiguous arrays may "
                               "be used as arguments to this operation")

        assert self.shape == other.shape

        func = elementwise.get_binary_op_kernel(self.dtype, other.dtype,
                                                out.dtype, "/")
        func.prepared_async_call(self._grid, self._block, stream, self.gpudata,
                                 other.gpudata, out.gpudata, self.mem_size)

        return out