From c6726644b9e1d453503022880b00c73e9ced76f2 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 1 May 2018 16:19:22 -0400 Subject: [PATCH 1/4] Reformat some test code to stop gcc 7.3 from segfaulting. Somehow deducing the parameters to a static function was causing gcc to segfault and crash. Changed around the code to use a free function and everything works properly --- .../TestingArrayHandleVirtualCoordinates.h | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/vtkm/cont/testing/TestingArrayHandleVirtualCoordinates.h b/vtkm/cont/testing/TestingArrayHandleVirtualCoordinates.h index bf61eacb3..3d39e3466 100644 --- a/vtkm/cont/testing/TestingArrayHandleVirtualCoordinates.h +++ b/vtkm/cont/testing/TestingArrayHandleVirtualCoordinates.h @@ -49,6 +49,19 @@ struct CopyWorklet : public vtkm::worklet::WorkletMapField } }; +template +inline void TestVirtualAccess(const vtkm::cont::ArrayHandle& in, + vtkm::cont::ArrayHandle& out, + DeviceAdapter) +{ + vtkm::worklet::DispatcherMapField().Invoke( + vtkm::cont::ArrayHandleVirtualCoordinates(in), vtkm::cont::ArrayHandleVirtualCoordinates(out)); + + VTKM_TEST_ASSERT(test_equal_portals(in.GetPortalConstControl(), out.GetPortalConstControl()), + "Input and output portals don't match"); +} + + } // anonymous namespace template @@ -60,17 +73,7 @@ private: vtkm::cont::ArrayHandle, vtkm::cont::ArrayHandle>; - template - static void TestVirtualAccess(const vtkm::cont::ArrayHandle& in, - vtkm::cont::ArrayHandle& out) - { - vtkm::worklet::DispatcherMapField().Invoke( - vtkm::cont::ArrayHandleVirtualCoordinates(in), - vtkm::cont::ArrayHandleVirtualCoordinates(out)); - VTKM_TEST_ASSERT(test_equal_portals(in.GetPortalConstControl(), out.GetPortalConstControl()), - "Input and output portals don't match"); - } static void TestAll() { @@ -86,10 +89,11 @@ private: { a1.GetPortalControl().Set(i, TestValue(i, PointType())); } - TestVirtualAccess(a1, out); + TestVirtualAccess(a1, out, DeviceAdapter{}); std::cout << "Testing ArrayHandleUniformPointCoordinates as input\n"; - TestVirtualAccess(vtkm::cont::ArrayHandleUniformPointCoordinates(vtkm::Id3(4, 4, 4)), out); + auto t = vtkm::cont::ArrayHandleUniformPointCoordinates(vtkm::Id3(4, 4, 4)); + TestVirtualAccess(t, out, DeviceAdapter{}); std::cout << "Testing ArrayHandleCartesianProduct as input\n"; vtkm::cont::ArrayHandle c1, c2, c3; @@ -103,7 +107,8 @@ private: c2.GetPortalControl().Set(i, p[1]); c3.GetPortalControl().Set(i, p[2]); } - TestVirtualAccess(vtkm::cont::make_ArrayHandleCartesianProduct(c1, c2, c3), out); + TestVirtualAccess( + vtkm::cont::make_ArrayHandleCartesianProduct(c1, c2, c3), out, DeviceAdapter{}); } public: From dac7ab987a30f13842d73bec8659724697415b9e Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 1 May 2018 17:35:26 -0400 Subject: [PATCH 2/4] Correct a bad memcpy in ColorTable that gcc 7 found --- vtkm/cont/ColorTablePrivate.hxx | 2 +- vtkm/cont/testing/TestingComputeRange.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vtkm/cont/ColorTablePrivate.hxx b/vtkm/cont/ColorTablePrivate.hxx index 9080b55ff..70ec8d826 100644 --- a/vtkm/cont/ColorTablePrivate.hxx +++ b/vtkm/cont/ColorTablePrivate.hxx @@ -132,7 +132,7 @@ inline bool rangeAlmostEqual(const vtkm::Range& r) // needs to be a memcpy to avoid strict aliasing issues, doing a count // of 2*sizeof(T) to couple both values at the same time std::memcpy(irange, &r.Min, sizeof(vtkm::Int64)); - std::memcpy(irange, &r.Max, sizeof(vtkm::Int64)); + std::memcpy(irange + 1, &r.Max, sizeof(vtkm::Int64)); // determine the absolute delta between these two numbers. const vtkm::Int64 delta = std::abs(irange[1] - irange[0]); // If the numbers are not nearly equal, we don't touch them. This avoids running into diff --git a/vtkm/cont/testing/TestingComputeRange.h b/vtkm/cont/testing/TestingComputeRange.h index 5a869a8d7..3d3a132f0 100644 --- a/vtkm/cont/testing/TestingComputeRange.h +++ b/vtkm/cont/testing/TestingComputeRange.h @@ -70,7 +70,7 @@ private: "Unexpected scalar field range."); } - template + template static void TestVecField() { const vtkm::Id nvals = 11; From 822d4c61e1fa6f5e87b63993fcede1582a6b46e8 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 1 May 2018 17:35:54 -0400 Subject: [PATCH 3/4] Marching Cubes test doesn't abuse fall through case statements The fall through case statement was causing numerous warnings with gcc 7. --- .../worklet/testing/UnitTestMarchingCubes.cxx | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/vtkm/worklet/testing/UnitTestMarchingCubes.cxx b/vtkm/worklet/testing/UnitTestMarchingCubes.cxx index dd79e51fb..2f300c878 100644 --- a/vtkm/worklet/testing/UnitTestMarchingCubes.cxx +++ b/vtkm/worklet/testing/UnitTestMarchingCubes.cxx @@ -182,25 +182,30 @@ public: switch (localId) { - case 2: - globalId += 1; - case 3: - globalId += this->Dimension; - case 1: - globalId += 1; case 0: break; - case 6: - globalId += 1; - case 7: - globalId += this->Dimension; - case 5: + case 1: globalId += 1; + break; + case 2: + globalId += this->Dimension + 2; + break; + case 3: + globalId += this->Dimension + 1; + break; case 4: globalId += this->DimPlus1Squared; break; + case 5: + globalId += this->DimPlus1Squared + 1; + break; + case 6: + globalId += this->Dimension + this->DimPlus1Squared + 2; + break; + case 7: + globalId += this->Dimension + this->DimPlus1Squared + 1; + break; } - return globalId; } From f025c2187bd61de404a825827986e98d19ff1956 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 2 May 2018 09:23:07 -0400 Subject: [PATCH 4/4] Suppress conversion warning inside Cell Interpolate code When converting integer fields the interpolate code generates lots of warnings that we are promoting into floating point space. The quickest solution is to suppress these conversion warnings all together for all interpolation functions. --- vtkm/exec/CellInterpolate.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vtkm/exec/CellInterpolate.h b/vtkm/exec/CellInterpolate.h index c296c4f69..c888475f2 100644 --- a/vtkm/exec/CellInterpolate.h +++ b/vtkm/exec/CellInterpolate.h @@ -27,6 +27,11 @@ #include #include +#if (defined(VTKM_GCC) || defined(VTKM_CLANG)) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#endif // gcc || clang + namespace vtkm { namespace exec @@ -441,4 +446,8 @@ VTKM_EXEC typename FieldVecType::ComponentType CellInterpolate( } } // namespace vtkm::exec +#if (defined(VTKM_GCC) || defined(VTKM_CLANG)) +#pragma GCC diagnostic pop +#endif // gcc || clang + #endif //vtk_m_exec_Interpolate_h