From a8292b88bb0fcc02706feed9902c74658915e33a Mon Sep 17 00:00:00 2001
From: Michael Kuron <mkuron@icp.uni-stuttgart.de>
Date: Thu, 17 Oct 2019 14:46:55 +0200
Subject: [PATCH] Fix OpenCL with older Sympy and pyopencl versions

---
 pystencils/backends/opencl_backend.py | 5 ++++-
 pystencils/opencl/opencljit.py        | 8 ++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/pystencils/backends/opencl_backend.py b/pystencils/backends/opencl_backend.py
index d2e40a69f..4217e9384 100644
--- a/pystencils/backends/opencl_backend.py
+++ b/pystencils/backends/opencl_backend.py
@@ -81,7 +81,10 @@ class OpenClSympyPrinter(CudaSympyPrinter):
     # For math functions, OpenCL is more similar to the C++ printer CustomSympyPrinter
     # since built-in math functions are generic.
     # In CUDA, you have to differentiate between `sin` and `sinf`
-    _print_math_func = CustomSympyPrinter._print_math_func
+    try:
+        _print_math_func = CustomSympyPrinter._print_math_func
+    except AttributeError:
+        pass
     _print_Pow = CustomSympyPrinter._print_Pow
 
     def _print_Function(self, expr):
diff --git a/pystencils/opencl/opencljit.py b/pystencils/opencl/opencljit.py
index 75076db53..f1df02936 100644
--- a/pystencils/opencl/opencljit.py
+++ b/pystencils/opencl/opencljit.py
@@ -41,8 +41,12 @@ def make_python_function(kernel_function_node, opencl_queue, opencl_ctx, argumen
     code += str(generate_c(kernel_function_node, dialect='opencl', custom_backend=custom_backend))
     options = []
     if USE_FAST_MATH:
-        options.append("-cl-unsafe-math-optimizations -cl-mad-enable -cl-fast-relaxed-math -cl-finite-math-only")
-    options.append("-I \"" + get_pystencils_include_path() + "\"")
+        options.append("-cl-unsafe-math-optimizations")
+        options.append("-cl-mad-enable")
+        options.append("-cl-fast-relaxed-math")
+        options.append("-cl-finite-math-only")
+    options.append("-I")
+    options.append(get_pystencils_include_path())
     mod = cl.Program(opencl_ctx, code).build(options=options)
     func = getattr(mod, kernel_function_node.function_name)
 
-- 
GitLab