[PATCH 40/42] 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>
Mon, 14 Aug 2023 13:53:17 +0000 (14:53 +0100)
Gbp-Pq: Name 0040-support-overriding-the-runtime-cpu-detection-with-PO.patch

lib/CL/pocl_llvm_utils.cc

index df79e2756e642c770b22c6d4c80610ec2d8d6963..61cd41e63f00289aca2e4df91b8ee786a6b2ebe5 100644 (file)
@@ -136,7 +136,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())
@@ -146,7 +147,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