From 6165f5c69767f993c89571f3892a5dec7cb07e73 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Wed, 23 Mar 2022 13:55:50 +0100 Subject: [PATCH] [PATCH 1009/1017] rename getX86KernelLibName() to pocl_get_distro_kernellib_name() Gbp-Pq: Name 1009-rename-getX86KernelLibName-to-pocl_get_distro_kernel.patch --- lib/CL/pocl_llvm.h | 5 +++++ lib/CL/pocl_llvm_build.cc | 17 +++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/CL/pocl_llvm.h b/lib/CL/pocl_llvm.h index 039de83..31c3d99 100644 --- a/lib/CL/pocl_llvm.h +++ b/lib/CL/pocl_llvm.h @@ -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 (); diff --git a/lib/CL/pocl_llvm_build.cc b/lib/CL/pocl_llvm_build.cc index 3ef6e0c..38d4541 100644 --- a/lib/CL/pocl_llvm_build.cc +++ b/lib/CL/pocl_llvm_build.cc @@ -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 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 -- 2.30.2