[PATCH 1017/1017] support overriding the runtime cpu detection with POCL_LLVM_CPU_NAME
authorAndreas Beckmann <anbe@debian.org>
Tue, 15 Mar 2022 14:59:08 +0000 (15:59 +0100)
committerAndreas Beckmann <anbe@debian.org>
Tue, 13 Dec 2022 03:08:31 +0000 (03:08 +0000)
Gbp-Pq: Name 1017-support-overriding-the-runtime-cpu-detection-with-PO.patch

lib/CL/pocl_llvm_utils.cc

index 018bbb376c09b4bf0b6e78143b1e40cf74291f64..6ab579240966ebd49e345e5d541dfa202e6af5f0 100644 (file)
@@ -122,7 +122,8 @@ static int getModuleTriple(const char *input_stream, size_t size,
 }
 
 char *pocl_get_llvm_cpu_name() {
-  StringRef r = llvm::sys::getHostCPUName();
+  const char *custom = pocl_get_string_option("POCL_LLVM_CPU_NAME", NULL);
+  StringRef r = custom ? StringRef(custom) : llvm::sys::getHostCPUName();
 
   // LLVM may return an empty string -- treat as generic
   if (r.empty())
@@ -132,7 +133,7 @@ char *pocl_get_llvm_cpu_name() {
   if (r.str() == "generic" && strlen(OCL_KERNEL_TARGET_CPU)) {
     POCL_MSG_WARN("LLVM does not recognize your cpu, trying to use "
                    OCL_KERNEL_TARGET_CPU " for -target-cpu\n");
-    r = llvm::StringRef(OCL_KERNEL_TARGET_CPU);
+    r = StringRef(OCL_KERNEL_TARGET_CPU);
   }
 #endif