Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions examples/from-wiki/gpu_scalar_mult.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,15 @@ def get_lin_comb_kernel_no_tex(summand_descriptors,
for i, (is_gpu_scalar, scalar_dtype, vector_dtype) in \
enumerate(summand_descriptors):
if is_gpu_scalar:
args.append(VectorArg(vector_dtype, "global_a%d" % i))
args.append(VectorArg(vector_dtype, "x%d" % i))
args.extend((VectorArg(vector_dtype, "global_a%d" % i), VectorArg(vector_dtype, "x%d" % i)))
loop_prep.append("%s a%d = *global_a%d"
% (dtype_to_ctype(scalar_dtype), i, i))
else:
args.append(ScalarArg(scalar_dtype, "a%d" % i))
args.append(VectorArg(vector_dtype, "x%d" % i))
args.extend((ScalarArg(scalar_dtype, "a%d" % i), VectorArg(vector_dtype, "x%d" % i)))

summands.append("a%d*x%d[i]" % (i, i))

args.append(VectorArg(dtype_z, "z"))
args.append(ScalarArg(numpy.uintp, "n"))
args.extend((VectorArg(dtype_z, "z"), ScalarArg(numpy.uintp, "n")))

mod = get_elwise_module(args,
"z[i] = " + " + ".join(summands),
Expand Down
2 changes: 1 addition & 1 deletion pycuda/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
sys.argv = args

with open(mainpyfile) as mainpy:
exec(compile(mainpy.read(), mainpyfile, "exec")) # ruff:ignore[exec-builtin]
exec(compile(mainpy.read(), mainpyfile, "exec"))
4 changes: 2 additions & 2 deletions pycuda/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def function_prepare_pre_v4(func, arg_types, block=None, shared=None, texrefs=No

func.arg_format = ""

for _i, arg_type in enumerate(arg_types):
for arg_type in arg_types:
if (
isinstance(arg_type, type)
and np is not None
Expand Down Expand Up @@ -541,7 +541,7 @@ def function_prepare(func, arg_types, texrefs=None):

func.arg_format = ""

for _i, arg_type in enumerate(arg_types):
for arg_type in arg_types:
if isinstance(arg_type, type) and np.number in arg_type.__mro__:
func.arg_format += np.dtype(arg_type).char
elif isinstance(arg_type, np.dtype):
Expand Down
9 changes: 3 additions & 6 deletions pycuda/elementwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ def __call__(self, *args, **kwargs):
range_ = slice(*slice_.indices(repr_vec.size))

if range_ is not None:
invocation_args.append(range_.start)
invocation_args.append(range_.stop)
invocation_args.extend((range_.start, range_.stop))
if range_.step is None:
invocation_args.append(1)
else:
Expand Down Expand Up @@ -439,13 +438,11 @@ def get_linear_combination_kernel(summand_descriptors, dtype_z):
% (dtype_to_ctype(scalar_dtype), i, i)
)
else:
args.append(ScalarArg(scalar_dtype, "a%d" % i))
args.append(VectorArg(vector_dtype, "x%d" % i))
args.extend((ScalarArg(scalar_dtype, "a%d" % i), VectorArg(vector_dtype, "x%d" % i)))

summands.append("a%d*x%d[i]" % (i, i))

args.append(VectorArg(dtype_z, "z"))
args.append(ScalarArg(np.uintp, "n"))
args.extend((VectorArg(dtype_z, "z"), ScalarArg(np.uintp, "n")))

mod = get_elwise_module(
args,
Expand Down
2 changes: 1 addition & 1 deletion pycuda/gl/autoinit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pycuda.tools import make_default_context


context = make_default_context(lambda dev: cudagl.make_context(dev))
context = make_default_context(cudagl.make_context)
device = context.get_device()

atexit.register(context.pop)
2 changes: 1 addition & 1 deletion pycuda/gpuarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def __bool__(self):

@property
def ptr(self):
return self.gpudata.__int__()
return int(self.gpudata)

# kernel invocation wrappers ----------------------------------------------
def _axpbyz(self, selffac, other, otherfac, out, add_timer=None, stream=None):
Expand Down
4 changes: 1 addition & 3 deletions pycuda/sparse/cg.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ def lc2(self, a, x, b, y, out=None):
b.bind_to_texref_ext(texrefs.pop(0), allow_double_hack=True)
else:
args.append(b)
args.append(y.gpudata)
args.append(out.gpudata)
args.append(x.mem_size)
args.extend((y.gpudata, out.gpudata, x.mem_size))

kernel.prepared_call(x._grid, x._block, *args)

Expand Down
2 changes: 1 addition & 1 deletion test/test_gpuarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_random_array(rng, shape, dtype):
return rng.random(shape, dtype)
elif dtype.kind in "il":
return rng.integers(-42, 42, shape, dtype)
elif dtype.kind in "u":
elif dtype.kind == "u":
return rng.integers(0, 42, shape, dtype)
elif dtype.kind == "c":
real_dtype = np.empty(0, dtype).real.dtype
Expand Down
Loading