diff --git a/pystencils/kernelcreation.py b/pystencils/kernelcreation.py index 759435eded7c140f87e5d2c26a2092ba864633f1..73b45b844d6a35823d806d966474048b9b676e8d 100644 --- a/pystencils/kernelcreation.py +++ b/pystencils/kernelcreation.py @@ -142,7 +142,9 @@ def create_indexed_kernel(assignments, cpu_openmp=True, gpu_indexing='block', gpu_indexing_params=MappingProxyType({}), - use_textures_for_interpolation=True): + use_textures_for_interpolation=True, + opencl_queue=None, + opencl_ctx=None): """ Similar to :func:`create_kernel`, but here not all cells of a field are updated but only cells with coordinates which are stored in an index field. This traversal method can e.g. be used for boundary handling. @@ -192,7 +194,7 @@ def create_indexed_kernel(assignments, return ast elif target == 'llvm': raise NotImplementedError("Indexed kernels are not yet supported in LLVM backend") - elif target == 'gpu': + elif target == 'gpu' or target == 'opencl': from pystencils.gpucuda import created_indexed_cuda_kernel idx_creator = indexing_creator_from_params(gpu_indexing, gpu_indexing_params) ast = created_indexed_cuda_kernel(assignments, @@ -201,6 +203,12 @@ def create_indexed_kernel(assignments, coordinate_names=coordinate_names, indexing_creator=idx_creator, use_textures_for_interpolation=use_textures_for_interpolation) + if target == 'opencl': + from pystencils.opencl.opencljit import make_python_function + ast._backend = 'opencl' + ast.compile = functools.partial(make_python_function, ast, opencl_queue, opencl_ctx) + ast._target = 'opencl' + ast._backend = 'opencl' return ast else: raise ValueError("Unknown target %s. Has to be either 'cpu' or 'gpu'" % (target,))