Skip to content

Commit

Permalink
Python reformatting
Browse files Browse the repository at this point in the history
With latest verisons of black and flake8

There is one import in gpu-burner.py that is needed (pycuda.autoinit)
as it has side effects, so this is marked as excempt for flake8
  • Loading branch information
graeme-of-cern committed May 3, 2024
1 parent b26bddd commit 7fff4d8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
17 changes: 10 additions & 7 deletions package/scripts/gpu-burner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
# pycuda is required!
#

import pycuda.autoinit
import pycuda.autoinit # noqa: F401
import pycuda.driver as drv
import numpy
from time import time

from pycuda.compiler import SourceModule
mod = SourceModule("""

mod = SourceModule(
"""
__global__ void multiply_them(float *dest, float *a, float *b, float *c)
{
const int i = threadIdx.x;
dest[i] = a[i] * b[i] + c[i];
}
""")
"""
)

multiply_them = mod.get_function("multiply_them")

Expand All @@ -30,9 +33,9 @@
dest = numpy.zeros_like(a)

start = time()
while (time() - start < 20):
while time() - start < 20:
multiply_them(
drv.Out(dest), drv.In(a), drv.In(b), drv.In(c),
block=(1024,1,1), grid=(1,1))
drv.Out(dest), drv.In(a), drv.In(b), drv.In(c), block=(1024, 1, 1), grid=(1, 1)
)

print(dest-a*b+c)
print(dest - a * b + c)
2 changes: 1 addition & 1 deletion package/scripts/precook_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def make_nvidia(proc_nvidia, fixed_value, rand=False):
"-", # jpg
"-", # ofa
random.randint(0, memory_lim) if rand else fixed_value, # fb
0, # ccpm
0, # ccpm
"python3", # command
]
for param in params:
Expand Down
8 changes: 5 additions & 3 deletions package/scripts/prmon_compress_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ def main():

parser.add_argument(
"--precision",
type=lambda x: float(x)
if 0 < float(x) < 1
else parser.exit(-1, "Precision must be strictly between 0 and 1"),
type=lambda x: (
float(x)
if 0 < float(x) < 1
else parser.exit(-1, "Precision must be strictly between 0 and 1")
),
default=0.05,
help="precision value for interpolation threshold",
)
Expand Down

0 comments on commit 7fff4d8

Please sign in to comment.