Skip to content
Snippets Groups Projects
Commit aa1ac13b authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

PEP8 test_wrapper

parent 676ac0ca
No related branches found
No related tags found
No related merge requests found
...@@ -454,26 +454,26 @@ def test_mempool(ctx_factory): ...@@ -454,26 +454,26 @@ def test_mempool(ctx_factory):
context = ctx_factory() context = ctx_factory()
pool = MemoryPool(CLAllocator(context)) pool = MemoryPool(CLAllocator(context))
maxlen = 10
queue = [] queue = []
e0 = 12 e0 = 12
for e in range(e0-6, e0-4): for e in range(e0-6, e0-4):
for i in range(100): for i in range(100):
queue.append(pool.allocate(1<<e)) queue.append(pool.allocate(1 << e))
if len(queue) > 10: if len(queue) > 10:
queue.pop(0) queue.pop(0)
del queue del queue
pool.stop_holding() pool.stop_holding()
@pytools.test.mark_test.opencl @pytools.test.mark_test.opencl
def test_mempool_2(): def test_mempool_2():
from pyopencl.tools import MemoryPool from pyopencl.tools import MemoryPool
from random import randrange from random import randrange
for i in range(2000): for i in range(2000):
s = randrange(1<<31) >> randrange(32) s = randrange(1 << 31) >> randrange(32)
bin_nr = MemoryPool.bin_number(s) bin_nr = MemoryPool.bin_number(s)
asize = MemoryPool.alloc_size(bin_nr) asize = MemoryPool.alloc_size(bin_nr)
...@@ -481,6 +481,7 @@ def test_mempool_2(): ...@@ -481,6 +481,7 @@ def test_mempool_2():
assert MemoryPool.bin_number(asize) == bin_nr, s assert MemoryPool.bin_number(asize) == bin_nr, s
assert asize < asize*(1+1/8) assert asize < asize*(1+1/8)
@pytools.test.mark_test.opencl @pytools.test.mark_test.opencl
def test_vector_args(ctx_factory): def test_vector_args(ctx_factory):
context = ctx_factory() context = ctx_factory()
...@@ -491,7 +492,7 @@ def test_vector_args(ctx_factory): ...@@ -491,7 +492,7 @@ def test_vector_args(ctx_factory):
{ dest[get_global_id(0)] = x; } { dest[get_global_id(0)] = x; }
""").build() """).build()
x = cl_array.vec.make_float4(1,2,3,4) x = cl_array.vec.make_float4(1, 2, 3, 4)
dest = np.empty(50000, cl_array.vec.float4) dest = np.empty(50000, cl_array.vec.float4)
mf = cl.mem_flags mf = cl.mem_flags
dest_buf = cl.Buffer(context, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=dest) dest_buf = cl.Buffer(context, mf.READ_WRITE | mf.COPY_HOST_PTR, hostbuf=dest)
...@@ -502,12 +503,13 @@ def test_vector_args(ctx_factory): ...@@ -502,12 +503,13 @@ def test_vector_args(ctx_factory):
assert (dest == x).all() assert (dest == x).all()
@pytools.test.mark_test.opencl @pytools.test.mark_test.opencl
def test_header_dep_handling(ctx_factory): def test_header_dep_handling(ctx_factory):
context = ctx_factory() context = ctx_factory()
from os.path import exists from os.path import exists
assert exists("empty-header.h") # if this fails, change dir to pyopencl/test assert exists("empty-header.h") # if this fails, change dir to pyopencl/test
kernel_src = """ kernel_src = """
#include <empty-header.h> #include <empty-header.h>
...@@ -522,6 +524,7 @@ def test_header_dep_handling(ctx_factory): ...@@ -522,6 +524,7 @@ def test_header_dep_handling(ctx_factory):
cl.Program(context, kernel_src).build(["-I", os.getcwd()]) cl.Program(context, kernel_src).build(["-I", os.getcwd()])
cl.Program(context, kernel_src).build(["-I", os.getcwd()]) cl.Program(context, kernel_src).build(["-I", os.getcwd()])
@pytools.test.mark_test.opencl @pytools.test.mark_test.opencl
def test_context_dep_memoize(ctx_factory): def test_context_dep_memoize(ctx_factory):
context = ctx_factory() context = ctx_factory()
...@@ -539,6 +542,7 @@ def test_context_dep_memoize(ctx_factory): ...@@ -539,6 +542,7 @@ def test_context_dep_memoize(ctx_factory):
assert counter[0] == 1 assert counter[0] == 1
@pytools.test.mark_test.opencl @pytools.test.mark_test.opencl
def test_can_build_binary(ctx_factory): def test_can_build_binary(ctx_factory):
ctx = ctx_factory() ctx = ctx_factory()
...@@ -556,11 +560,9 @@ def test_can_build_binary(ctx_factory): ...@@ -556,11 +560,9 @@ def test_can_build_binary(ctx_factory):
foo.build() foo.build()
if __name__ == "__main__": if __name__ == "__main__":
# make sure that import failures get reported, instead of skipping the tests. # make sure that import failures get reported, instead of skipping the tests.
import pyopencl import pyopencl # noqa
import sys import sys
if len(sys.argv) > 1: if len(sys.argv) > 1:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment