Skip to content

Commit 4cf1a68

Browse files
committed
Remove code smells in comments.
1 parent 20f7937 commit 4cf1a68

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

kernel_tuner/backends/c.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def __init__(self, iterations=7, compiler_options=None, compiler=None):
6565
self.iterations = iterations
6666
self.max_threads = 1024
6767
self.compiler_options = compiler_options
68-
self.compiler = compiler or "g++" # use gcc by default
68+
# if no compiler is specified, use g++ by default
69+
self.compiler = compiler or "g++"
6970
self.lib = None
7071
self.using_openmp = False
7172
self.observers = [CRuntimeObserver(self)]

kernel_tuner/backends/cupy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def ready_argument_list(self, arguments):
118118
alloc = cp.array(arg)
119119
self.allocations.append(alloc)
120120
gpu_args.append(alloc)
121-
else: # if not a numpy array, just pass argument along
121+
# if not a numpy array, just pass argument along
122+
else:
122123
gpu_args.append(arg)
123124
return gpu_args
124125

kernel_tuner/backends/opencl.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def ready_argument_list(self, arguments):
9292
# if arg i is a numpy array copy to device
9393
if isinstance(arg, np.ndarray):
9494
gpu_args.append(cl.Buffer(self.ctx, self.mf.READ_WRITE | self.mf.COPY_HOST_PTR, hostbuf=arg))
95-
else: # if not an array, just pass argument along
95+
# if not an array, just pass argument along
96+
else:
9697
gpu_args.append(arg)
9798
return gpu_args
9899

@@ -201,7 +202,7 @@ def memcpy_htod(self, dest, src):
201202
"""
202203
if isinstance(dest, cl.Buffer):
203204
cl.enqueue_copy(self.queue, dest, src)
204-
205+
205206
def copy_constant_memory_args(self, cmem_args):
206207
raise NotImplementedError('PyOpenCL backend does not support constant memory')
207208

kernel_tuner/backends/pycuda.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ def __init__(self, device=0, iterations=7, compiler_options=None, observers=None
9393
"""
9494
self.allocations = []
9595
self.texrefs = []
96-
if not pycuda_available and isinstance(drv, PyCudaPlaceHolder): #and part to allow mocking
96+
# if not PyCuda available, check if mocking before raising exception
97+
if not pycuda_available and isinstance(drv, PyCudaPlaceHolder):
9798
raise ImportError("Error: pycuda not installed, please install e.g. using 'pip install pycuda'.")
9899

99100
drv.init()
@@ -162,7 +163,8 @@ def _finish_up():
162163

163164
def __del__(self):
164165
for gpu_mem in self.allocations:
165-
if hasattr(gpu_mem, 'free'): #if needed for when using mocks during testing
166+
# if needed for when using mocks during testing
167+
if hasattr(gpu_mem, 'free'):
166168
gpu_mem.free()
167169

168170
def ready_argument_list(self, arguments):
@@ -192,7 +194,8 @@ def ready_argument_list(self, arguments):
192194
# pycuda does not support bool, convert to uint8 instead
193195
elif isinstance(arg, np.bool_):
194196
gpu_args.append(arg.astype(np.uint8))
195-
else: # if not an array, just pass argument along
197+
# if not an array, just pass argument along
198+
else:
196199
gpu_args.append(arg)
197200
return gpu_args
198201

0 commit comments

Comments
 (0)