From 0b0ba401287c1dd9fcb9f9527cf6b8985cc6d202 Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Wed, 13 Nov 2019 11:06:49 +0100 Subject: [PATCH] Add two helper functions to manage global cl ctx --- pystencils/opencl/opencljit.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pystencils/opencl/opencljit.py b/pystencils/opencl/opencljit.py index 051dc1ec5..939387338 100644 --- a/pystencils/opencl/opencljit.py +++ b/pystencils/opencl/opencljit.py @@ -28,6 +28,20 @@ def init_globally(device_index=0): _global_cl_queue = cl.CommandQueue(_global_cl_ctx) +def init_globally_with_context(opencl_ctx, opencl_queue): + global _global_cl_ctx + global _global_cl_queue + _global_cl_ctx = opencl_ctx + _global_cl_queue = opencl_queue + + +def clear_global_ctx(): + global _global_cl_ctx + global _global_cl_queue + _global_cl_ctx = None + _global_cl_queue = None + + def make_python_function(kernel_function_node, opencl_queue, opencl_ctx, argument_dict=None, custom_backend=None): """ Creates a **OpenCL** kernel function from an abstract syntax tree which -- GitLab