sergesanspaille / rpms / pocl

Forked from rpms/pocl 5 years ago
Clone
Blob Blame History Raw
From 020cd9dbd8e356cc370b090d416c6e8b912c6b47 Mon Sep 17 00:00:00 2001
From: Michal Babej <michal.babej@tut.fi>
Date: Wed, 3 Jan 2018 12:55:54 +0100
Subject: [PATCH 02/14] Try to fix #596 - provide additional pocl build
 information

---
 CMakeLists.txt                   |  6 +++++-
 config.h.in.cmake                |  5 +++++
 lib/CL/clGetPlatformInfo.c       | 43 ++++++++++++++++++++++++++++++++++++++--
 lib/CL/devices/basic/basic.c     |  8 +++++++-
 lib/CL/devices/pthread/pthread.c | 12 ++++++++++-
 tests/runtime/test_version.c     | 12 ++++++-----
 6 files changed, 76 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 44a51c94..a836da90 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -308,7 +308,11 @@ if (OCS_AVAILABLE)
   endif()
 
   if(NOT DEFINED HOST_DEVICE_BUILD_HASH)
-    set(HOST_DEVICE_BUILD_HASH "${LLC_TRIPLE}-${LLC_HOST_CPU}")
+    if(KERNELLIB_HOST_CPU_VARIANTS STREQUAL "distro")
+      set(HOST_DEVICE_BUILD_HASH "${LLC_TRIPLE}")
+    else()
+      set(HOST_DEVICE_BUILD_HASH "${LLC_TRIPLE}-${LLC_HOST_CPU}")
+    endif()
   endif()
 
   if(ARM AND LLVM_3_9)
diff --git a/config.h.in.cmake b/config.h.in.cmake
index 7a6f72a1..cd75d7ce 100644
--- a/config.h.in.cmake
+++ b/config.h.in.cmake
@@ -28,6 +28,11 @@
 
 #define FORCED_CLFLAGS  "@FORCED_CLFLAGS@"
 
+#cmakedefine ENABLE_ASAN
+#cmakedefine ENABLE_LSAN
+#cmakedefine ENABLE_TSAN
+#cmakedefine ENABLE_UBSAN
+
 #cmakedefine ENABLE_CONFORMANCE
 
 #cmakedefine ENABLE_POCL_BUILDING
diff --git a/lib/CL/clGetPlatformInfo.c b/lib/CL/clGetPlatformInfo.c
index 74c15c92..5bb9c0ac 100644
--- a/lib/CL/clGetPlatformInfo.c
+++ b/lib/CL/clGetPlatformInfo.c
@@ -51,8 +51,47 @@ POname(clGetPlatformInfo)(cl_platform_id   platform,
 
     case CL_PLATFORM_VERSION:
 #ifdef OCS_AVAILABLE
-      POCL_RETURN_GETINFO_STR("OpenCL " POCL_CL_VERSION\
-                        " pocl " PACKAGE_VERSION ", LLVM " LLVM_VERSION);
+      POCL_RETURN_GETINFO_STR ("OpenCL " POCL_CL_VERSION
+                               " pocl " PACKAGE_VERSION ", LLVM " LLVM_VERSION
+#ifdef LLVM_BUILD_MODE_DEBUG
+                               " - debug"
+#endif
+
+#ifdef ENABLE_ASAN
+                               ", ASAN"
+#endif
+#ifdef ENABLE_TSAN
+                               ", TSAN"
+#endif
+#ifdef ENABLE_LSAN
+                               ", LSAN"
+#endif
+#ifdef ENABLE_UBSAN
+                               ", UBSAN"
+#endif
+
+#ifdef BUILD_CUDA
+                               ", CUDA"
+#endif
+#ifdef BUILD_HSA
+                               ", HSA"
+#endif
+#ifdef TCE_AVAILABLE
+                               ", TCE"
+#endif
+#ifdef HAVE_LTTNG_UST
+                               ", LTTNG"
+#endif
+#ifdef KERNELLIB_HOST_DISTRO_VARIANTS
+                               ", DISTRO"
+#endif
+#ifdef POCL_DEBUG_MESSAGES
+                               ", POCL_DEBUG"
+#endif
+#ifndef _CL_DISABLE_HALF
+                               ", FP16"
+#endif
+      );
 #else
       POCL_RETURN_GETINFO_STR("OpenCL " POCL_CL_VERSION\
                         " pocl " PACKAGE_VERSION ", no online compiler support");
diff --git a/lib/CL/devices/basic/basic.c b/lib/CL/devices/basic/basic.c
index 433ce943..8d1d8910 100644
--- a/lib/CL/devices/basic/basic.c
+++ b/lib/CL/devices/basic/basic.c
@@ -134,7 +134,13 @@ char *
 pocl_basic_build_hash (cl_device_id device)
 {
   char* res = calloc(1000, sizeof(char));
-  snprintf(res, 1000, "basic-%s", HOST_DEVICE_BUILD_HASH);
+#ifdef KERNELLIB_HOST_DISTRO_VARIANTS
+  char *name = get_cpu_name ();
+  snprintf (res, 1000, "basic-%s-%s", HOST_DEVICE_BUILD_HASH, name);
+  POCL_MEM_FREE (name);
+#else
+  snprintf (res, 1000, "basic-%s", HOST_DEVICE_BUILD_HASH);
+#endif
   return res;
 }
 
diff --git a/lib/CL/devices/pthread/pthread.c b/lib/CL/devices/pthread/pthread.c
index b3d91fdb..0b88a74c 100644
--- a/lib/CL/devices/pthread/pthread.c
+++ b/lib/CL/devices/pthread/pthread.c
@@ -51,6 +51,10 @@
 #include "pocl_util.h"
 #include "pocl_mem_management.h"
 
+#ifdef OCS_AVAILABLE
+#include "pocl_llvm.h"
+#endif
+
 //#define DEBUG_MT
 
 #ifdef CUSTOM_BUFFER_ALLOCATOR
@@ -149,7 +153,13 @@ char *
 pocl_pthread_build_hash (cl_device_id device)
 {
   char* res = calloc(1000, sizeof(char));
-  snprintf(res, 1000, "pthread-%s", HOST_DEVICE_BUILD_HASH);
+#ifdef KERNELLIB_HOST_DISTRO_VARIANTS
+  char *name = get_cpu_name ();
+  snprintf (res, 1000, "pthread-%s-%s", HOST_DEVICE_BUILD_HASH, name);
+  POCL_MEM_FREE (name);
+#else
+  snprintf (res, 1000, "pthread-%s", HOST_DEVICE_BUILD_HASH);
+#endif
   return res;
 }
 
diff --git a/tests/runtime/test_version.c b/tests/runtime/test_version.c
index c41ef515..6bbc70de 100644
--- a/tests/runtime/test_version.c
+++ b/tests/runtime/test_version.c
@@ -33,11 +33,13 @@ int main(void)
 				sizeof(result), result, &rvs));
 
 	result[rvs]=0;	// spec doesn't say it is null-terminated.
-	if( strcmp( result, 
-	            "OpenCL " POCL_CL_VERSION " pocl " PACKAGE_VERSION ", LLVM " LLVM_VERSION) != 0 ) {
-		printf("Error: platform is: %s\n", result);
-		return 2;
-	}
+        const char *expected = "OpenCL " POCL_CL_VERSION
+                               " pocl " PACKAGE_VERSION ", LLVM " LLVM_VERSION;
+        if (strncmp (result, expected, strlen (expected)) != 0)
+          {
+            printf ("Error: platform is: %s\n", result);
+            return 2;
+          }
 
 
 	/* Pocl devices have the form 'type'-'details', if details are
-- 
2.15.1