#1043227 opm-common: test failure on ppc64el with -O3

Package:
src:opm-common
Source:
src:opm-common
Submitter:
Gianfranco Costamagna
Date:
2025-04-03 17:33:03 UTC
Severity:
normal
Tags:
#1043227#5
Date:
2023-08-07 17:31:44 UTC
From:
To:
Hello, as per upstream ticket, there is a build failure (test failure) on ppc64 and ppc64el (confirmed on perotto and platti porter machines)

A simple fix is to make sure that O3 is not used on ppc64el (I don't care about ppc64 because it has ~12 test failures
regardless of the optimization level used).

This is the patch I used in Ubuntu

diff -Nru opm-common-2023.04+ds/debian/changelog opm-common-2023.04+ds/debian/changelog
--- opm-common-2023.04+ds/debian/changelog	2023-07-17 13:05:05.000000000 +0000
+++ opm-common-2023.04+ds/debian/changelog	2023-08-04 06:33:40.000000000 +0000
@@ -1,3 +1,9 @@
+opm-common (2023.04+ds-2.1) unstable; urgency=medium
+
+  * Reduce optimization on ppc64el to -O2 (Closes: #-1)
+
+ -- Gianfranco Costamagna <locutusofborg@debian.org>  Fri, 04 Aug 2023 08:33:40 +0200
+
  opm-common (2023.04+ds-2) unstable; urgency=medium

    * d/control: Correctly reflect the merge of opm-material into opm-common
diff -Nru opm-common-2023.04+ds/debian/rules opm-common-2023.04+ds/debian/rules
--- opm-common-2023.04+ds/debian/rules	2023-07-17 13:05:05.000000000 +0000
+++ opm-common-2023.04+ds/debian/rules	2023-08-04 06:33:40.000000000 +0000
@@ -7,6 +7,13 @@

  OPM_DEBIAN_CMAKE_FLAGS = -DOPM_ENABLE_PYTHON=1 -DOPM_INSTALL_PYTHON=1 -DPYTHON_EXECUTABLE=/usr/bin/python3 -DOPM_INSTALL_COMPILED_PYTHON=OFF -DOPM_ENABLE_EMBEDDED_PYTHON=1

+ifneq (,$(filter $(DEB_HOST_ARCH), ppc64el))
+  export DEB_CFLAGS_MAINT_STRIP = -O3
+  export DEB_CXXFLAGS_MAINT_STRIP = -O3
+  export DEB_CFLAGS_MAINT_APPEND = -O2
+  export DEB_CXXFLAGS_MAINT_APPEND = -O2
+endif
+
  need_gb_ram_per_process=3
  free_ram=$(shell free -g | sed -n 2p| sed "s/ \+/ /g"| cut -d " " -f 2)
  max_procs=$(shell echo "$(free_ram)/$(need_gb_ram_per_process)" | bc)

#1043227#10
Date:
2024-04-02 21:36:42 UTC
From:
To:
Hi,

Concerning the patch: It seems like -O2 is the default in Debian now anyway.
Will the patch still work as it is?

I did some investigations on platti.debian.org. I have no idea what the problem
is. My hunch is that compiler optimization breaks the code here. If I add a
simple print statement like this then the test passes:

(sid_ppc64el-dchroot)blattms@platti:~/opm-common$ git diff  opm/output/data/InterRegFlow.hpp
diff --git a/opm/output/data/InterRegFlow.hpp b/opm/output/data/InterRegFlow.hpp
index 0e1dadcc4..7e2aeabbe 100644
--- a/opm/output/data/InterRegFlow.hpp
+++ b/opm/output/data/InterRegFlow.hpp
@@ -29,7 +29,7 @@
  #include <iterator>
  #include <type_traits>
  #include <utility>
-
+#include <iostream>
  namespace Opm { namespace data {
      /// Intermediary Protocol to Linearise Per-Connection Flow Rates Into Subrange.
@@ -271,7 +271,7 @@ namespace Opm { namespace data {
              using sz_t = decltype(InterRegFlow::bufferSize());
              const auto& [begin, end] = this->elements_;
-
+            std::cout<<"distance=";//<<  std::distance(begin, end);// << " size="<< InterRegFlow::bufferSize()<<std::endl;
              return static_cast<sz_t>(std::distance(begin, end))
                  == InterRegFlow::bufferSize();
          }
(sid_ppc64el-dchroot)blattms@platti:~/opm-common$

Best,

Markus