From 703c638439c944c76399f5e0d1d828f7bba7c2cc Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Fri, 29 Apr 2011 17:08:21 -0400
Subject: [PATCH] Warn about Nvidia breaking the cl_ext header.

---
 aksetup_helper.py | 42 ++++++++++++++++--------------------------
 setup.py          | 31 +++++++++++++++++++++----------
 2 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/aksetup_helper.py b/aksetup_helper.py
index 42ea8cd9..8a274909 100644
--- a/aksetup_helper.py
+++ b/aksetup_helper.py
@@ -5,6 +5,19 @@ distribute_setup.use_setuptools()
 import setuptools
 from setuptools import Extension
 
+def count_down_delay(delay):
+    from time import sleep
+    import sys
+    while delay:
+        sys.stdout.write("Continuing in %d seconds...   \r" % delay)
+        sys.stdout.flush()
+        delay -= 1
+        sleep(1)
+    print("")
+
+
+
+
 if not hasattr(setuptools, "_distribute"):
     print("-------------------------------------------------------------------------")
     print("Setuptools conflict detected.")
@@ -20,15 +33,8 @@ if not hasattr(setuptools, "_distribute"):
     print("I will continue after a short while, fingers crossed.")
     print("-------------------------------------------------------------------------")
 
-    delay = 10
+    count_down_delay(delay=10)
 
-    from time import sleep
-    import sys
-    while delay:
-        sys.stdout.write("Continuing in %d seconds...   \r" % delay)
-        sys.stdout.flush()
-        delay -= 1
-        sleep(1)
 
 def setup(*args, **kwargs):
     from setuptools import setup
@@ -156,15 +162,7 @@ def get_config(schema=None, warn_about_no_config=True):
         print("*** HIT Ctrl-C NOW IF THIS IS NOT WHAT YOU WANT")
         print("*************************************************************")
 
-        delay = 10
-
-        from time import sleep
-        import sys
-        while delay:
-            sys.stdout.write("Continuing in %d seconds...   \r" % delay)
-            sys.stdout.flush()
-            delay -= 1
-            sleep(1)
+        count_down_delay(delay=10)
 
     return schema.read_config()
 
@@ -540,15 +538,7 @@ def set_up_shipped_boost_if_requested(conf):
             print("------------------------------------------------------------------------")
             conf["USE_SHIPPED_BOOST"] = False
 
-            delay = 10
-
-            from time import sleep
-            import sys
-            while delay:
-                sys.stdout.write("Continuing in %d seconds...   \r" % delay)
-                sys.stdout.flush()
-                delay -= 1
-                sleep(1)
+            count_down_delay(delay=10)
 
     if conf["USE_SHIPPED_BOOST"]:
         conf["BOOST_INC_DIR"] = ["bpl-subset/bpl_subset"]
diff --git a/setup.py b/setup.py
index 1e43659b..87895393 100644
--- a/setup.py
+++ b/setup.py
@@ -100,16 +100,27 @@ def main():
         print("[1] http://www.makotemplates.org/")
         print("-------------------------------------------------------------------------")
 
-        delay = 5
-
-        from time import sleep
-        import sys
-        while delay:
-            sys.stdout.write("Continuing in %d seconds...   \r" % delay)
-            sys.stdout.flush()
-            delay -= 1
-            sleep(1)
-        print("")
+        from aksetup_helper import count_down_delay
+        count_down_delay(delay=5)
+
+    might_be_cuda = False
+    for inc_dir in conf["CL_INC_DIR"]:
+        inc_dir = inc_dir.lower()
+        if "nv" in inc_dir or "cuda" in inc_dir:
+            might_be_cuda = True
+
+    if might_be_cuda and conf["CL_ENABLE_DEVICE_FISSION"]:
+        print("-------------------------------------------------------------------------")
+        print("You might be compiling against Nvidia CUDA with device fission enabled.")
+        print("-------------------------------------------------------------------------")
+        print("That is not a problem on CUDA 4.0 and newer. If you are using CUDA 3.2,")
+        print("your build will break, because Nvidia shipped a broken CL header in")
+        print("in your version. The fix is to set CL_ENABLE_DEVICE_FISSION to False")
+        print("in your PyOpenCL configuration.")
+        print("-------------------------------------------------------------------------")
+
+        from aksetup_helper import count_down_delay
+        count_down_delay(delay=5)
 
     setup(name="pyopencl",
             # metadata
-- 
GitLab