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
37 changes: 14 additions & 23 deletions aksetup_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def count_down_delay(delay):
sys.stdout.flush()
delay -= 1
sleep(1)
print("")
print()


DASH_SEPARATOR = 75 * "-"
Expand Down Expand Up @@ -297,7 +297,6 @@ def get_default_config(self):
return dict((opt.name, opt.default) for opt in self.options)

def read_config_from_pyfile(self, filename):
result = {}
filevars = {}
infile = open(filename)
try:
Expand All @@ -307,11 +306,7 @@ def read_config_from_pyfile(self, filename):

exec(compile(contents, filename, "exec"), filevars)

for key, value in filevars.items():
if key in self.optdict:
result[key] = value

return result
return {key: value for key, value in filevars.items() if key in self.optdict}

def update_conf_file(self, filename, config):
result = {}
Expand All @@ -324,16 +319,13 @@ def update_conf_file(self, filename, config):

filevars.pop("__builtins__", None)

for key, value in config.items():
if value is not None:
filevars[key] = value
filevars.update({key: value for key, value in config.items() if value is not None})

keys = list(filevars.keys())
keys.sort()

outf = open(filename, "w")
for key in keys:
outf.write("%s = %s\n" % (key, repr(filevars[key])))
outf.writelines("%s = %s\n" % (key, repr(filevars[key])) for key in keys)
outf.close()

return result
Expand Down Expand Up @@ -520,8 +512,7 @@ def take_from_configparser(self, options):
import re
sep = re.compile(r"(?<!\\),")
result = sep.split(opt)
result = [i.replace(r"\,", ",") for i in result]
return result
return [i.replace(r"\,", ",") for i in result]
else:
return []

Expand Down Expand Up @@ -588,9 +579,9 @@ def set_up_shipped_boost_if_requested(project_name, conf, source_path=None,
print("(The files should be under %s/.)" % source_path)
print(DASH_SEPARATOR)
print("If you got this package from git, you probably want to do")
print("")
print()
print(" $ git submodule update --init")
print("")
print()
print("to fetch what you are presently missing. If you got this from")
print("a distributed package on the net, that package is broken and")
print("should be fixed. For now, I will turn off 'USE_SHIPPED_BOOST'")
Expand Down Expand Up @@ -798,7 +789,7 @@ def _run_git_command(cmd):
print(DASH_SEPARATOR)
print("The package directory appears to be a git repository, but I could")
print("not invoke git to check whether my submodules are up to date.")
print("")
print()
print("The error was:")
print(git_error)
print("Hit Ctrl-C now if you'd like to think about the situation.")
Expand Down Expand Up @@ -855,20 +846,20 @@ def check_git_submodules():
print("git submodules are not up-to-date or in odd state")
print(DASH_SEPARATOR)
print("If this makes no sense, you probably want to say")
print("")
print()
print(" $ git submodule update --init")
print("")
print()
print("to fetch what you are presently missing and "
"move on with your life.")
print("If you got this from a distributed package on the "
"net, that package is")
print("broken and should be fixed. Please inform whoever "
"gave you this package.")
print("")
print()
print("These issues were found:")
for w in pkg_warnings:
print(" %s" % w)
print("")
print()
print("I will try to initialize the submodules for you "
"after a short wait.")
print(DASH_SEPARATOR)
Expand Down Expand Up @@ -898,12 +889,12 @@ def check_pybind11():
print("Pybind11 is not installed.")
print(DASH_SEPARATOR)
print("Very likely, the build process after this message will fail.")
print("")
print()
print("Simply press Ctrl+C and type")
print("python -m pip install pybind11")
print("to fix this. If you don't, the build will continue ")
print("in a few seconds.")
print("")
print()
print("[1] https://pybind11.readthedocs.io/en/stable/")
print(DASH_SEPARATOR)

Expand Down
2 changes: 1 addition & 1 deletion examples/cai_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# We use autoprimaryctx instead of autoinit because Numba can only operate on a
# primary context
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray


# Create a PyCUDA gpuarray
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

# part 2 ----------------------------------------------------------------------

import pycuda.gpuarray as gpuarray
from pycuda import gpuarray


a_gpu = gpuarray.to_gpu(numpy.random.randn(4, 4).astype(numpy.float32))
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_elementwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy

import pycuda.gpuarray as gpuarray
from pycuda import gpuarray
from pycuda.curandom import rand as curand


Expand Down
2 changes: 1 addition & 1 deletion examples/fill_gpu_with_nans.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy

import pycuda.driver as cuda
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray


free_bytes, total_bytes = cuda.mem_get_info()
Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/2d_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run(self):
num = 2 # I KNOW THIS IS A BAD PRACTISE, BUT I COUNDN'T FIND ANY OTHER WAY(INIT CANNOT BE USED HERE)

# THE TRANSPOSE-SPLIT ALGORITHM FOR FFT
for _t in range(0, trans):
for _t in range(trans):
for i in range(m):
a2_1[i, :] = a2[i*p/m:(i+1)*p/m, :].flatten() # DIVIDE AND RESHAPE THE INPUT IMAGE INTO 1D ARRAY

Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/arithmetic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

import pycuda.driver as cuda
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray
from pycuda.compiler import SourceModule


Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/c++_function_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

import pycuda.gpuarray as gpuarray
from pycuda import gpuarray
from pycuda.compiler import SourceModule


Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/demo_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy

import pycuda.gpuarray as gpuarray
from pycuda import gpuarray


a = (numpy.random.randn(400)
Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/distance_element_wise3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy

import pycuda.driver as cuda
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray
from pycuda.elementwise import ElementwiseKernel as Elementwise


Expand Down
4 changes: 2 additions & 2 deletions examples/from-wiki/game_of_life.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

import matplotlib.pyplot as plt
import numpy as np
from pylab import cm as cm
from pylab import cm

import pycuda.gpuarray as gpuarray
from pycuda import gpuarray
from pycuda.compiler import SourceModule


Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/gl_interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def keyPressed(*args):
print("Closing..")
destroy_PBOs()
destroy_texture()
exit()
sys.exit()
elif args[0] == "a":
print("toggling animation")
animate = not animate
Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/gpu_scalar_mult.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy

import pycuda.driver as drv
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray
from pycuda.tools import context_dependent_memoize


Expand Down
8 changes: 3 additions & 5 deletions examples/from-wiki/mandelbrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import numpy as nm

import pycuda.driver as drv
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray


# set width and height of window, more pixels take longer to calculate
Expand All @@ -42,8 +42,7 @@ def calculate_z_gpu(q, maxiter, z):
# we bring the iterations_gpu array back to determine pixel colours later
complex_gpu(z_gpu, q_gpu, iterations_gpu, maxiter)

iterations = iterations_gpu.get()
return iterations
return iterations_gpu.get()


def calculate_z_numpy_gpu(q, maxiter, z):
Expand Down Expand Up @@ -73,8 +72,7 @@ def calculate_z_numpy_gpu(q, maxiter, z):
zg = gpuarray.if_positive(comparison_result, cmplx0sg, zg)
outputg = gpuarray.if_positive(comparison_result, iterg, outputg)
iterg = iterg + 1
output = outputg.get()
return output
return outputg.get()


def calculate_z_numpy(q, maxiter, z):
Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/mandelbrot_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import numpy as np
from matplotlib.patches import Rectangle
from matplotlib.widgets import RectangleSelector
from pylab import cm as cm
from pylab import cm

import pycuda.driver as drv
from pycuda.compiler import SourceModule
Expand Down
4 changes: 2 additions & 2 deletions examples/from-wiki/manhattan_distance_for_2D_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run(res, step):


res = numpy.array([[0
for _ in range(0, w)]
for _ in range(0, w)], dtype="int32")
for _ in range(w)]
for _ in range(w)], dtype="int32")
print(res)
run(res, 0)
2 changes: 1 addition & 1 deletion examples/from-wiki/matrix_transpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pycuda.autoinit
import pycuda.driver as cuda
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray
from pycuda.compiler import SourceModule
from pycuda.tools import context_dependent_memoize

Expand Down
4 changes: 2 additions & 2 deletions examples/from-wiki/measure_gpuarray_speed_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

from pytools import Table

import pycuda.curandom as curandom
import pycuda.driver as drv
from pycuda import curandom


def main():
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray

sizes = []
times = []
Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/plot_random_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# simple module to show the plotting of random data
from __future__ import annotations

import pycuda.curandom as curandom
from pycuda import curandom


size = 1000
Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/select_to_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy

import pycuda.driver as cuda
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray
from pycuda.compiler import SourceModule


Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/simple_speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
import pycuda.autoinit
import pycuda.cumath
import pycuda.driver as drv
import pycuda.gpuarray as gpuarray
import pycuda.tools
from pycuda import gpuarray
from pycuda.compiler import SourceModule
from pycuda.elementwise import ElementwiseKernel

Expand Down
8 changes: 4 additions & 4 deletions examples/from-wiki/sobel_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,13 +514,13 @@ def keyboard(key, x=0, y=0):
global mode, scale
if key == "q":
sys.exit(0)
elif key == "I" or key == "i":
elif key in {"I", "i"}:
mode = 0
elif key == "T" or key == "t":
elif key in {"T", "t"}:
mode = 1
elif key == "S" or key == "s":
elif key in {"S", "s"}:
mode = 2
elif key == "D" or key == "d":
elif key in {"D", "d"}:
mode = 3
elif key == "-":
scale -= 0.1
Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/sparse_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy.linalg as la

import pycuda.driver as drv
import pycuda.gpuarray as gpuarray
from pycuda import gpuarray


def main_cg():
Expand Down
2 changes: 1 addition & 1 deletion examples/from-wiki/thrust_interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from codepy.bpl import BoostPythonModule
from codepy.cuda import CudaModule

import pycuda.gpuarray as gpuarray
from pycuda import gpuarray


# Make a host_module, compiled for CPU
Expand Down
1 change: 0 additions & 1 deletion pycuda/autoinit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from pycuda.tools import make_default_context


global context
context = make_default_context()
device = context.get_device()

Expand Down
1 change: 0 additions & 1 deletion pycuda/autoprimaryctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def _retain_primary_context(dev):
return context


global context
context = make_default_context(_retain_primary_context)
device = context.get_device()

Expand Down
2 changes: 1 addition & 1 deletion pycuda/characterize.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def sizeof(type_name, preamble=""):
no_extern_c=True,
)

import pycuda.gpuarray as gpuarray
from pycuda import gpuarray

output = gpuarray.empty((), dtype=np.uintp)
mod.get_function("write_size")(output, block=(1, 1, 1), grid=(1, 1))
Expand Down
Loading
Loading