From 838a0086cfc6a80617ebbe28d4a901e5e45dc0a2 Mon Sep 17 00:00:00 2001
From: Ethan Stam <33101855+EthanS94@users.noreply.github.com>
Date: Fri, 4 Mar 2022 09:29:40 -0700
Subject: Initial changes needed to build paraview@5.9.0%xl_r (#22050)

---
 var/spack/repos/builtin/packages/eigen/package.py  |  4 +++
 .../packages/eigen/xlc-compilation-3.3.4.patch     | 12 +++++++
 .../repos/builtin/packages/paraview/package.py     |  7 ++++
 .../packages/paraview/xlc-compilation-pv590.patch  | 39 ++++++++++++++++++++++
 4 files changed, 62 insertions(+)
 create mode 100644 var/spack/repos/builtin/packages/eigen/xlc-compilation-3.3.4.patch
 create mode 100644 var/spack/repos/builtin/packages/paraview/xlc-compilation-pv590.patch

(limited to 'var')

diff --git a/var/spack/repos/builtin/packages/eigen/package.py b/var/spack/repos/builtin/packages/eigen/package.py
index eae3dca0e3..552827ed43 100644
--- a/var/spack/repos/builtin/packages/eigen/package.py
+++ b/var/spack/repos/builtin/packages/eigen/package.py
@@ -39,6 +39,10 @@ class Eigen(CMakePackage):
     patch('https://gitlab.com/libeigen/eigen/-/commit/6d822a1052fc665f06dc51b4729f6a38e0da0546.diff', when='@3.3.8',
           sha256='62590e9b33a8f72b608a72b87147a306e7cb20766ea53c6b8e0a183fa6cb7635')
 
+    # there is a bug in 3.3.4 that provokes a compile error with the xl compiler
+    # See https://gitlab.com/libeigen/eigen/-/issues/1555
+    patch('xlc-compilation-3.3.4.patch', when='@3.3.4%xl_r')
+
     # From http://eigen.tuxfamily.org/index.php?title=Main_Page#Requirements
     # "Eigen doesn't have any dependencies other than the C++ standard
     # library."
diff --git a/var/spack/repos/builtin/packages/eigen/xlc-compilation-3.3.4.patch b/var/spack/repos/builtin/packages/eigen/xlc-compilation-3.3.4.patch
new file mode 100644
index 0000000000..50ccd0f39f
--- /dev/null
+++ b/var/spack/repos/builtin/packages/eigen/xlc-compilation-3.3.4.patch
@@ -0,0 +1,12 @@
+diff -up /Eigen/src/Core/arch/AltiVec/PacketMath.h /Eigen/src/Core/arch/AltiVec/PacketMath.h
+--- /Eigen/src/Core/arch/AltiVec/PacketMath.h
++++ /Eigen/src/Core/arch/AltiVec/PacketMath.h
+@@ -1022,7 +1022,7 @@ ptranspose(PacketBlock<Packet2d,2>& kern
+ 
+ template<> EIGEN_STRONG_INLINE Packet2d pblend(const Selector<2>& ifPacket, const Packet2d& thenPacket, const Packet2d& elsePacket) {
+   Packet2l select = { ifPacket.select[0], ifPacket.select[1] };
+-  Packet2bl mask = vec_cmpeq(reinterpret_cast<Packet2d>(select), reinterpret_cast<Packet2d>(p2l_ONE));
++  Packet2bl mask = reinterpret_cast<Packet2bl>( vec_cmpeq(reinterpret_cast<Packet2d>(select), reinterpret_cast<Packet2d>(p2l_ONE)) );
+   return vec_sel(elsePacket, thenPacket, mask);
+ }
+ #endif // __VSX__
diff --git a/var/spack/repos/builtin/packages/paraview/package.py b/var/spack/repos/builtin/packages/paraview/package.py
index c47392ff63..47244d3983 100644
--- a/var/spack/repos/builtin/packages/paraview/package.py
+++ b/var/spack/repos/builtin/packages/paraview/package.py
@@ -92,6 +92,9 @@ class Paraview(CMakePackage, CudaPackage):
     conflicts('build_edition=core', when='@:5.7')
     # before 5.3.0, ParaView didn't have VTK-m
     conflicts('use_vtkm=on', when='@:5.3')
+    # paraview@5.9.0 is recommended when using the xl compiler
+    # See https://gitlab.kitware.com/paraview/paraview/-/merge_requests/4433
+    conflicts('paraview@:5.8', when='%xl_r', msg='Use paraview@5.9.0 with %xl_r. Earlier versions are not able to build with xl.')
 
     # We only support one single Architecture
     for _arch, _other_arch in itertools.permutations(CudaPackage.cuda_arch_values, 2):
@@ -219,6 +222,10 @@ class Paraview(CMakePackage, CudaPackage):
     # https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8653
     patch('vtk-adios2-module-no-kit.patch', when='@5.8:5.10')
 
+    # Patch for paraview 5.9.0%xl_r
+    # https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7591
+    patch('xlc-compilation-pv590.patch', when='@5.9.0%xl_r')
+
     @property
     def generator(self):
         # https://gitlab.kitware.com/paraview/paraview/-/issues/21223
diff --git a/var/spack/repos/builtin/packages/paraview/xlc-compilation-pv590.patch b/var/spack/repos/builtin/packages/paraview/xlc-compilation-pv590.patch
new file mode 100644
index 0000000000..8105b2010d
--- /dev/null
+++ b/var/spack/repos/builtin/packages/paraview/xlc-compilation-pv590.patch
@@ -0,0 +1,39 @@
+diff --git a/VTK/Common/DataModel/vtkStaticCellLinksTemplate.txx b/VTK/Common/DataModel/vtkStaticCellLinksTemplate.txx
+index 514c0ee..66edca2 100644
+--- a/VTK/Common/DataModel/vtkStaticCellLinksTemplate.txx
++++ b/VTK/Common/DataModel/vtkStaticCellLinksTemplate.txx
+@@ -356,7 +356,7 @@ void vtkStaticCellLinksTemplate<TIds>::ThreadedBuildLinks(
+
+   // Create an array of atomics with initial count=0. This will keep
+   // track of point uses. Count them in parallel.
+-  std::atomic<TIds>* counts = new std::atomic<TIds>[numPts] {};
++  std::atomic<TIds>* counts = new std::atomic<TIds>[numPts] ();
+   CountUses<TIds> count(cellArray, counts);
+   vtkSMPTools::For(0, numCells, count);
+
+diff --git a/VTK/Filters/Core/vtkBinnedDecimation.cxx b/VTK/Filters/Core/vtkBinnedDecimation.cxx
+index 0736c56..8403908 100644
+--- a/VTK/Filters/Core/vtkBinnedDecimation.cxx
++++ b/VTK/Filters/Core/vtkBinnedDecimation.cxx
+@@ -632,7 +632,7 @@ void BinPointsDecimate(int genMode, vtkIdType numPts, PointsT* pts, vtkPointData
+   // is a problem because a ptId can == zero; as a workaround, we'll
+   // initially use negative ids, and convert to positive ids in the
+   // final composition.
+-  std::atomic<TIds>* ptMap = new std::atomic<TIds>[numBins] {};
++  std::atomic<TIds>* ptMap = new std::atomic<TIds>[numBins] ();
+
+   // Is the triangle output? And eventually the offset into the output cell array.
+   TIds* triMap = new TIds[numTris + 1];
+diff --git a/VTK/Filters/Core/vtkWindowedSincPolyDataFilter.cxx b/VTK/Filters/Core/vtkWindowedSincPolyDataFilter.cxx
+index 15e47a1..7baef33 100644
+--- a/VTK/Filters/Core/vtkWindowedSincPolyDataFilter.cxx
++++ b/VTK/Filters/Core/vtkWindowedSincPolyDataFilter.cxx
+@@ -348,7 +348,7 @@ struct PointConnectivity : PointConnectivityBase
+     // accommodate more smoothing edges (although after a certain point,
+     // additional edges make little difference, especially at the cost of
+     // memory and speed).
+-    this->Offsets = new std::atomic<TIds>[this->NumPts + 1] {}; // Initialized to zero
++    this->Offsets = new std::atomic<TIds>[this->NumPts + 1] (); // Initialized to zero
+     this->Edges = nullptr;                                      // initially until constructed
+     this->EdgeCounts = new EDGE_COUNT_TYPE[this->NumPts];       // values set later
+   }
-- 
cgit v1.2.3-70-g09d2