From 32df4d8d01fa2af76c95838c1fcace8402344e7a Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Keck <jean-baptiste.keck@imag.fr>
Date: Sun, 1 Oct 2017 13:23:00 +0200
Subject: [PATCH] fixed opencl unknown device type while using oclgrind in
 verbose mode

---
 examples/scalar_advection/scalar_advection.py | 2 +-
 hysop/__init__.py                             | 4 ++--
 hysop/backend/device/opencl/opencl_env.py     | 7 ++++++-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/examples/scalar_advection/scalar_advection.py b/examples/scalar_advection/scalar_advection.py
index ee713dfa1..45610c646 100644
--- a/examples/scalar_advection/scalar_advection.py
+++ b/examples/scalar_advection/scalar_advection.py
@@ -35,7 +35,7 @@ def run(npts=64+1, cfl=0.5):
     d3d=(npts,)*dim
     box = Box(length=(2*pi,)*dim)
     
-    # impl = Implementation.PYTHON
+    #impl = Implementation.PYTHON
     impl = Implementation.OPENCL_CODEGEN
 
     if impl is Implementation.OPENCL_CODEGEN:
diff --git a/hysop/__init__.py b/hysop/__init__.py
index 279e86abe..0d496006a 100644
--- a/hysop/__init__.py
+++ b/hysop/__init__.py
@@ -16,11 +16,11 @@ __FFTW_ENABLED__   = "ON"   is "ON"
 __SCALES_ENABLED__ = "ON" is "ON"
 __OPTIMIZE__       = not __debug__
 
-__VERBOSE__        = False
+__VERBOSE__        = True
 __DEBUG__          = False
 __TRACE__          = False
 __TRACE_WARNINGS__ = False
-__KERNEL_DEBUG__   = True
+__KERNEL_DEBUG__   = False
 __PROFILE__        = True
 
 __ENABLE_LONG_TESTS__ = "OFF" is "ON"
diff --git a/hysop/backend/device/opencl/opencl_env.py b/hysop/backend/device/opencl/opencl_env.py
index d9324eb3e..2f6e61bc9 100644
--- a/hysop/backend/device/opencl/opencl_env.py
+++ b/hysop/backend/device/opencl/opencl_env.py
@@ -102,6 +102,11 @@ class OpenClEnvironment(object):
         self._allocator = allocator
         self._mempool   = mempool
 
+        try:
+            device_type_str = cl.device_type.to_string(device.type),
+        except ValueError:
+            device_type_str = 'UNKNOWN DEVICE TYPE {}'.format(device.type)
+
         msg=\
 ''' -- Platform --
   *plat id: {}
@@ -116,7 +121,7 @@ class OpenClEnvironment(object):
   *global mem size: {}
 '''.format(
 platform_id, platform.name, platform.version,
-device_id, device.name, cl.device_type.to_string(device.type),
+device_id, device.name, device_type_str,
 device.opencl_c_version, bytes2str(device.global_mem_size))
         if context.properties:
             msg+='\n -- Context --'
-- 
GitLab