[PATCH 1009/1017] rename getX86KernelLibName() to pocl_get_distro_kernellib_name()
authorAndreas Beckmann <anbe@debian.org>
Wed, 23 Mar 2022 12:55:50 +0000 (13:55 +0100)
committerAndreas Beckmann <anbe@debian.org>
Sun, 2 Apr 2023 23:08:50 +0000 (00:08 +0100)
Gbp-Pq: Name 1009-rename-getX86KernelLibName-to-pocl_get_distro_kernel.patch

lib/CL/pocl_llvm.h
lib/CL/pocl_llvm_build.cc

index 039de83200242ec08fab4a22468eb33adcf8128a..31c3d99fa4c37494d219172dd0cc26d0c0392484 100644 (file)
@@ -37,6 +37,11 @@ extern "C" {
   /* Returns the cpu name as reported by LLVM. */
   POCL_EXPORT
   char *pocl_get_llvm_cpu_name ();
+
+  /* For distro builds, return the kernellib name based on the host CPU */
+  POCL_EXPORT
+  const char *pocl_get_distro_kernellib_name ();
+
   /* Returns if the cpu supports FMA instruction (uses LLVM). */
   int cpu_has_fma ();
 
index 3ef6e0c5eacaa3813b079b5a60d6fc2fdc655a90..38d4541cb2d67a6d4c78e35842cce9edb38c1666 100644 (file)
@@ -891,21 +891,17 @@ int pocl_llvm_link_program(cl_program program, unsigned device_i,
 
 /* for "distro" style kernel libs, return which kernellib to use, at runtime */
 #ifdef KERNELLIB_HOST_DISTRO_VARIANTS
-const char *getX86KernelLibName() {
+const char *pocl_get_distro_kernellib_name() {
   StringMap<bool> Features;
   const char *res = NULL;
 
   if (!llvm::sys::getHostCPUFeatures(Features)) {
-    POCL_MSG_WARN ("getX86KernelLibName(): LLVM can't get host CPU flags!\n");
-    /* getX86KernelLibName should only ever be enabled
-       on x86-64, which always has sse2 */
-    return "sse2";
+    POCL_ABORT("LLVM can't get host CPU flags!\n");
   }
 
+#if defined(__x86_64__)
   if (Features["sse2"])
     res = "sse2";
-  else
-    POCL_ABORT("Pocl on x86_64 requires at least SSE2\n");
   if (Features["ssse3"] && Features["cx16"])
     res = "ssse3";
   if (Features["sse4.1"] && Features["cx16"])
@@ -923,6 +919,11 @@ const char *getX86KernelLibName() {
     res = "avx2";
   if (Features["avx512f"] )
     res = "avx512";
+#endif
+
+  if (!res)
+    POCL_ABORT("Can't find a kernellib supported by the host CPU (%s)\n",
+               llvm::sys::getHostCPUName());
 
   return res;
 }
@@ -994,7 +995,7 @@ static llvm::Module *getKernelLibrary(cl_device_id device,
   if (is_host) {
     kernellib += '-';
 #ifdef KERNELLIB_HOST_DISTRO_VARIANTS
-    kernellib += getX86KernelLibName();
+    kernellib += pocl_get_distro_kernellib_name();
 #elif defined(HOST_CPU_FORCED)
     kernellib += OCL_KERNEL_TARGET_CPU;
 #else