diff --git a/pystencils/boundaries/createindexlistcython.cpython-37m-x86_64-linux-gnu.so b/pystencils/boundaries/createindexlistcython.cpython-37m-x86_64-linux-gnu.so new file mode 100755 index 0000000000000000000000000000000000000000..d8c9d67e34b3de47631b85e9f14f727870fce103 Binary files /dev/null and b/pystencils/boundaries/createindexlistcython.cpython-37m-x86_64-linux-gnu.so differ diff --git a/pystencils_tests/test_opencl.py b/pystencils_tests/test_opencl.py index adffeb4750a62f5bb08ded29fffe00ac5900f706..4275c623206edb9dfc17f76e05f57381e11439e2 100644 --- a/pystencils_tests/test_opencl.py +++ b/pystencils_tests/test_opencl.py @@ -7,6 +7,7 @@ from pystencils.backends.cuda_backend import CudaBackend from pystencils.backends.opencl_backend import OpenClBackend from pystencils.opencl.opencljit import make_python_function + try: import pyopencl as cl HAS_OPENCL = True @@ -233,3 +234,41 @@ def test_without_cuda(): opencl_kernel = make_python_function(ast, queue, ctx) assert opencl_kernel is not None opencl_kernel(x=x, y=y, z=z) + + +@pytest.mark.skipif(not HAS_OPENCL, reason="Test requires pyopencl") +def test_kernel_creation(): + global pystencils + z, y, x = pystencils.fields("z, y, x: [20,30]") + + assignments = pystencils.AssignmentCollection({ + z[0, 0]: x[0, 0] * sp.log(x[0, 0] * y[0, 0]) + }) + + print(assignments) + + pystencils.opencl.clear_global_ctx() + + import pystencils.opencl.autoinit + ast = pystencils.create_kernel(assignments, target='opencl') + + print(ast.backend) + + code = str(pystencils.show_code(ast)) + print(code) + assert 'get_local_size' in code + + opencl_kernel = ast.compile() + + x_cpu = np.random.rand(20, 30) + y_cpu = np.random.rand(20, 30) + z_cpu = np.random.rand(20, 30) + + import pyopencl.array as array + assert get_global_cl_queue() + x = array.to_device(get_global_cl_queue(), x_cpu) + y = array.to_device(get_global_cl_queue(), y_cpu) + z = array.to_device(get_global_cl_queue(), z_cpu) + + assert opencl_kernel is not None + opencl_kernel(x=x, y=y, z=z)