From: Andreas Beckmann Date: Wed, 23 Mar 2022 12:55:50 +0000 (+0100) Subject: [PATCH 35/42] rename getX86KernelLibName() to pocl_get_distro_kernellib_name() X-Git-Tag: archive/raspbian/4.0-3+rpi1^2^2~12 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=35445debf8257699c7309b25524807303a11a097;p=pocl.git [PATCH 35/42] rename getX86KernelLibName() to pocl_get_distro_kernellib_name() Gbp-Pq: Name 0035-rename-getX86KernelLibName-to-pocl_get_distro_kernel.patch --- diff --git a/lib/CL/pocl_llvm.h b/lib/CL/pocl_llvm.h index 7ae6d36..5ed4130 100644 --- a/lib/CL/pocl_llvm.h +++ b/lib/CL/pocl_llvm.h @@ -38,6 +38,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 (); diff --git a/lib/CL/pocl_llvm_build.cc b/lib/CL/pocl_llvm_build.cc index fc3fc4a..1ae2c78 100644 --- a/lib/CL/pocl_llvm_build.cc +++ b/lib/CL/pocl_llvm_build.cc @@ -944,21 +944,18 @@ 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 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_MSG_WARN("LLVM can't get host CPU flags!\n"); + return NULL; } +#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"]) @@ -976,6 +973,11 @@ const char *getX86KernelLibName() { res = "avx2"; if (Features["avx512f"] ) res = "avx512"; +#endif + + if (!res) + POCL_MSG_WARN("Can't find a kernellib supported by the host CPU (%s)\n", + llvm::sys::getHostCPUName()); return res; } @@ -1047,7 +1049,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