예제 #1
0
파일: __init__.py 프로젝트: Gormse/MacMiner
    def kernel_set_args(self, *args):
        assert len(args) == self.num_args, (
                "length of argument list (%d) and "
                "CL-generated number of arguments (%d) do not agree"
                % (len(args), self.num_args))

        i = None
        try:
            try:
                arg_type_chars = self.__dict__["_arg_type_chars"]
            except KeyError:
                for i, arg in enumerate(args):
                    self.set_arg(i, arg)
            else:
                from pyopencl._pvt_struct import pack

                for i, (arg, arg_type_char) in enumerate(
                        zip(args, arg_type_chars)):
                    if arg_type_char and arg_type_char != "V":
                        self.set_arg(i, pack(arg_type_char, arg))
                    else:
                        self.set_arg(i, arg)
        except LogicError, e:
            if i is not None:
                advice = ""
                from pyopencl.array import Array
                if isinstance(args[i], Array):
                    advice = " (perhaps you meant to pass 'array.data' instead of the array itself?)"

                raise LogicError(
                        "when processing argument #%d (1-based): %s%s"
                        % (i+1, str(e), advice))
            else:
                raise
예제 #2
0
파일: __init__.py 프로젝트: pohlt/pyopencl
    def kernel_set_args(self, *args):
        assert len(args) == self.num_args, (
            "length of argument list (%d) and "
            "CL-generated number of arguments (%d) do not agree" %
            (len(args), self.num_args))

        i = None
        try:
            try:
                arg_type_chars = self.__dict__["_arg_type_chars"]
            except KeyError:
                for i, arg in enumerate(args):
                    self.set_arg(i, arg)
            else:
                from pyopencl._pvt_struct import pack

                for i, (arg,
                        arg_type_char) in enumerate(zip(args, arg_type_chars)):
                    if arg_type_char and arg_type_char != "V":
                        self.set_arg(i, pack(arg_type_char, arg))
                    else:
                        self.set_arg(i, arg)
        except LogicError, e:
            if i is not None:
                advice = ""
                from pyopencl.array import Array
                if isinstance(args[i], Array):
                    advice = " (perhaps you meant to pass 'array.data' " \
                        "instead of the array itself?)"

                raise LogicError(
                    "when processing argument #%d (1-based): %s%s" %
                    (i + 1, str(e), advice))
            else:
                raise