dmitry-chirkov-dremio commented on code in PR #55506:
URL: https://github.com/apache/arrow/pull/55506#discussion_r4689657883


##########
cpp/src/gandiva/engine_llvm_test.cc:
##########
@@ -133,4 +133,19 @@ TEST_F(TestEngine, TestAddOptimised) {
   EXPECT_EQ(add_func(my_array, 5), 17);
 }
 
+TEST_F(TestEngine, TestAddWithoutHostCpu) {
+  // target_host_cpu=false compiles for the generic CPU of the host triple
+  auto conf = TestConfiguration();

Review Comment:
   TestConfiguration() returns a singleton. 
   Disabling host-CPU targeting leaves subsequent tests using generic 
targeting, making coverage order-dependent.
   
   Use ConfigurationBuilder().build() like in 
cpp/src/gandiva/tests/cache_race_test.cc
   
   p.s.



##########
cpp/src/gandiva/engine.cc:
##########
@@ -330,25 +365,15 @@ void Engine::InitOnce() {
   llvm::InitializeNativeTargetDisassembler();
   llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
 
-  cpu_name = llvm::sys::getHostCPUName();
-#if LLVM_VERSION_MAJOR >= 19
-  auto host_features = llvm::sys::getHostCPUFeatures();
-  const bool have_host_features = true;
-#else
-  llvm::StringMap<bool> host_features;
-  const auto have_host_features = llvm::sys::getHostCPUFeatures(host_features);
-#endif
-  std::string cpu_attrs_str;
-  if (have_host_features) {
-    for (auto& f : host_features) {
-      std::string attr = f.second ? std::string("+") + f.first().str()
-                                  : std::string("-") + f.first().str();
-      cpu_attrs.push_back(attr);
-      cpu_attrs_str += " " + attr;
-    }
+  host_target = DetectHostTarget();
+  if (host_target.ok()) {
+    ARROW_LOG(INFO) << "Detected target triple: " << 
host_target->getTargetTriple().str();
+    ARROW_LOG(INFO) << "Detected CPU Name : " << host_target->getCPU();
+    ARROW_LOG(INFO) << "Detected CPU Features: ["

Review Comment:
   setFeatures() is absent in LLVM 8–9
   getCPU() is absent in LLVM 8–12
   
   Do we care? LLVM is from 2021 so we probably do not but I'm not sure if 
pipelines can enforce this in any way



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • Re: [PR] GH-55505: Gandiva: ... dmitry-chirkov-dremio (via GitHub) via github

Reply via email to