From f74c0d3c882f06b1a9810146885da666861011c5 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Wed, 9 Mar 2016 14:05:46 -0500 Subject: [PATCH 1/3] Remove type conversion related warnings for GCC --- .../testing/UnitTestArrayPortalFromIterators.cxx | 2 +- .../testing/UnitTestIteratorFromArrayPortal.cxx | 2 +- .../testing/UnitTestArrayPortalToIterators.cxx | 2 +- .../testing/UnitTestDataSetBuilderRectilinear.cxx | 10 +++++----- .../cont/testing/UnitTestDataSetBuilderUniform.cxx | 4 ++-- vtkm/exec/CellDerivative.h | 4 ++-- vtkm/exec/CellInterpolate.h | 14 +++++++------- vtkm/exec/ParametricCoordinates.h | 2 +- vtkm/testing/Testing.h | 2 +- vtkm/worklet/AverageByKey.h | 2 +- vtkm/worklet/VertexClustering.h | 8 ++++---- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/vtkm/cont/internal/testing/UnitTestArrayPortalFromIterators.cxx b/vtkm/cont/internal/testing/UnitTestArrayPortalFromIterators.cxx index 6fcc15fc8..820194886 100644 --- a/vtkm/cont/internal/testing/UnitTestArrayPortalFromIterators.cxx +++ b/vtkm/cont/internal/testing/UnitTestArrayPortalFromIterators.cxx @@ -35,7 +35,7 @@ struct TemplatedTests ValueType ExpectedValue(vtkm::Id index, ComponentType value) { - return ValueType(ComponentType(index) + value); + return ValueType(static_cast(index+static_cast(value))); } template diff --git a/vtkm/cont/internal/testing/UnitTestIteratorFromArrayPortal.cxx b/vtkm/cont/internal/testing/UnitTestIteratorFromArrayPortal.cxx index 583387377..38b3786fc 100644 --- a/vtkm/cont/internal/testing/UnitTestIteratorFromArrayPortal.cxx +++ b/vtkm/cont/internal/testing/UnitTestIteratorFromArrayPortal.cxx @@ -37,7 +37,7 @@ struct TemplatedTests ValueType ExpectedValue(vtkm::Id index, ComponentType value) { - return ValueType(ComponentType(index) + value); + return ValueType(static_cast(index+static_cast(value))); } template diff --git a/vtkm/cont/testing/UnitTestArrayPortalToIterators.cxx b/vtkm/cont/testing/UnitTestArrayPortalToIterators.cxx index beee44fb1..e3ad753a8 100644 --- a/vtkm/cont/testing/UnitTestArrayPortalToIterators.cxx +++ b/vtkm/cont/testing/UnitTestArrayPortalToIterators.cxx @@ -36,7 +36,7 @@ struct TemplatedTests static ValueType ExpectedValue(vtkm::Id index, ComponentType value) { - return ValueType(static_cast(index) + value); + return ValueType(static_cast(index+static_cast(value))); } class ReadOnlyArrayPortal diff --git a/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx b/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx index 1ad12aba3..e5fb8dd36 100644 --- a/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx +++ b/vtkm/cont/testing/UnitTestDataSetBuilderRectilinear.cxx @@ -97,11 +97,11 @@ void FillArray(std::vector &arr, switch (fillMethod) { - case 0: xi = static_cast(i); break; - case 1: xi = static_cast(i) / static_cast(size-1); break; - case 2: xi = static_cast(i*2); break; - case 3: xi = static_cast(i*0.1f); break; - case 4: xi = static_cast(i*i); break; + case 0: break; + case 1: xi /= static_cast(size-1); break; + case 2: xi *= 2; break; + case 3: xi *= 0.1f; break; + case 4: xi *= xi; break; default: VTKM_TEST_FAIL("Bad internal test state: invalid fill method."); } arr[i] = xi; diff --git a/vtkm/cont/testing/UnitTestDataSetBuilderUniform.cxx b/vtkm/cont/testing/UnitTestDataSetBuilderUniform.cxx index cf6696817..021e24062 100644 --- a/vtkm/cont/testing/UnitTestDataSetBuilderUniform.cxx +++ b/vtkm/cont/testing/UnitTestDataSetBuilderUniform.cxx @@ -103,7 +103,7 @@ void FillMethod(vtkm::IdComponent method, break; case 1: origin = 0; - spacing = static_cast(1.0/dimensionSize); + spacing = static_cast(1.0/static_cast(dimensionSize)); break; case 2: origin = 0; @@ -120,7 +120,7 @@ void FillMethod(vtkm::IdComponent method, } boundsMin = static_cast(origin); - boundsMax = static_cast(origin + (dimensionSize-1)*spacing); + boundsMax = static_cast(origin + static_cast(dimensionSize-1)*spacing); } template diff --git a/vtkm/exec/CellDerivative.h b/vtkm/exec/CellDerivative.h index 825833848..5e1dbddaf 100644 --- a/vtkm/exec/CellDerivative.h +++ b/vtkm/exec/CellDerivative.h @@ -849,8 +849,8 @@ CellDerivative(const FieldVecType &field, fieldCenter = fieldCenter + field[pointIndex]; wcoordCenter = wcoordCenter + wCoords[pointIndex]; } - fieldCenter = fieldCenter*FieldType(1.0f/numPoints); - wcoordCenter = wcoordCenter*WCoordType(1.0f/numPoints); + fieldCenter = fieldCenter*FieldType(1.0f/static_cast(numPoints)); + wcoordCenter = wcoordCenter*WCoordType(1.0f/static_cast(numPoints)); ParametricCoordType angle; if ((vtkm::Abs(pcoords[0]-0.5f) < 4*vtkm::Epsilon()) && diff --git a/vtkm/exec/CellInterpolate.h b/vtkm/exec/CellInterpolate.h index e759544ec..0366ef3e0 100644 --- a/vtkm/exec/CellInterpolate.h +++ b/vtkm/exec/CellInterpolate.h @@ -276,7 +276,7 @@ CellInterpolate(const FieldVecType &field, { fieldCenter = fieldCenter + field[pointIndex]; } - fieldCenter = fieldCenter*FieldType(1.0f/numPoints); + fieldCenter = fieldCenter*FieldType(1.0f/static_cast(numPoints)); if ((vtkm::Abs(pcoords[0]-0.5f) < 4*vtkm::Epsilon()) && (vtkm::Abs(pcoords[1]-0.5f) < 4*vtkm::Epsilon())) @@ -305,13 +305,13 @@ CellInterpolate(const FieldVecType &field, polygonCoords[0][1] = 0.5f; polygonCoords[0][2] = 0; - polygonCoords[1][0] = 0.5f*(vtkm::Cos(deltaAngle*firstPointIndex)+1); - polygonCoords[1][1] = 0.5f*(vtkm::Sin(deltaAngle*firstPointIndex)+1); - polygonCoords[1][2] = 0; + polygonCoords[1][0] = 0.5f*(vtkm::Cos(deltaAngle*static_cast(firstPointIndex))+1); + polygonCoords[1][1] = 0.5f*(vtkm::Sin(deltaAngle*static_cast(firstPointIndex))+1); + polygonCoords[1][2] = 0.0f; - polygonCoords[2][0] = 0.5f*(vtkm::Cos(deltaAngle*secondPointIndex)+1); - polygonCoords[2][1] = 0.5f*(vtkm::Sin(deltaAngle*secondPointIndex)+1); - polygonCoords[2][2] = 0; + polygonCoords[2][0] = 0.5f*(vtkm::Cos(deltaAngle*static_cast(secondPointIndex))+1); + polygonCoords[2][1] = 0.5f*(vtkm::Sin(deltaAngle*static_cast(secondPointIndex))+1); + polygonCoords[2][2] = 0.0f; vtkm::Vec trianglePCoords = vtkm::exec::internal::ReverseInterpolateTriangle( diff --git a/vtkm/exec/ParametricCoordinates.h b/vtkm/exec/ParametricCoordinates.h index 72f136ad2..51bf56683 100644 --- a/vtkm/exec/ParametricCoordinates.h +++ b/vtkm/exec/ParametricCoordinates.h @@ -802,7 +802,7 @@ WorldCoordinatesToParametricCoordinates( { wcoordCenter = wcoordCenter + pointWCoords[pointIndex]; } - wcoordCenter = wcoordCenter*WCoordType(1.0f/numPoints); + wcoordCenter = wcoordCenter*WCoordType(1.0f/static_cast(numPoints)); // Find the normal vector to the polygon. If the polygon is planar, convex, // and in general position, any three points will give a normal in the same diff --git a/vtkm/testing/Testing.h b/vtkm/testing/Testing.h index 119b855b0..1e559aa27 100644 --- a/vtkm/testing/Testing.h +++ b/vtkm/testing/Testing.h @@ -411,7 +411,7 @@ template VTKM_EXEC_CONT_EXPORT T TestValue(vtkm::Id index, T, vtkm::TypeTraitsRealTag) { - return T(0.01*index + 1.001); + return T(0.01*static_cast(index) + 1.001); } /// Many tests involve getting and setting values in some index-based structure diff --git a/vtkm/worklet/AverageByKey.h b/vtkm/worklet/AverageByKey.h index d9104f968..c7efb3816 100644 --- a/vtkm/worklet/AverageByKey.h +++ b/vtkm/worklet/AverageByKey.h @@ -46,7 +46,7 @@ struct DivideWorklet: public vtkm::worklet::WorkletMapField void operator()(const ValueType &v, const vtkm::Id &count, ValueType &vout) const { typedef typename VecTraits::ComponentType ComponentType; - vout = v * ComponentType(1./count); + vout = v * ComponentType(1./static_cast(count)); } template diff --git a/vtkm/worklet/VertexClustering.h b/vtkm/worklet/VertexClustering.h index 8e621e57e..5a713cea4 100644 --- a/vtkm/worklet/VertexClustering.h +++ b/vtkm/worklet/VertexClustering.h @@ -330,7 +330,7 @@ public: vtkm::Float64 res[3]; for (vtkm::IdComponent i=0; i<3; i++) { - res[i] = (bounds[i*2+1]-bounds[i*2])/nDivisions[i]; + res[i] = (bounds[i*2+1]-bounds[i*2])/static_cast(nDivisions[i]); } gridInfo.grid_width = vtkm::Max(res[0], vtkm::Max(res[1], res[2])); @@ -342,9 +342,9 @@ public: gridInfo.dim[2] = vtkm::Min((vtkm::Id)vtkm::Ceil((bounds[5]-bounds[4])*inv_grid_width), nDivisions[2]); // center the mesh in the grids - gridInfo.origin[0] = (bounds[1]+bounds[0])*0.5 - gridInfo.grid_width*(gridInfo.dim[0])*.5; - gridInfo.origin[1] = (bounds[3]+bounds[2])*0.5 - gridInfo.grid_width*(gridInfo.dim[1])*.5; - gridInfo.origin[2] = (bounds[5]+bounds[4])*0.5 - gridInfo.grid_width*(gridInfo.dim[2])*.5; + gridInfo.origin[0] = (bounds[1]+bounds[0])*0.5 - gridInfo.grid_width*static_cast(gridInfo.dim[0])*.5; + gridInfo.origin[1] = (bounds[3]+bounds[2])*0.5 - gridInfo.grid_width*static_cast(gridInfo.dim[1])*.5; + gridInfo.origin[2] = (bounds[5]+bounds[4])*0.5 - gridInfo.grid_width*static_cast(gridInfo.dim[2])*.5; } //construct the scheduler that will execute all the worklets From 635f8c7987f5057018b13252139de4a1bca5f20d Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Thu, 17 Mar 2016 13:14:30 -0400 Subject: [PATCH 2/3] Add a CTestCustom file to to filter out warnings that cant be eliminated --- CMakeLists.txt | 2 ++ CTestCustom.cmake.in | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 CTestCustom.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 09cc620db..81b0e4084 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,8 @@ option(VTKm_USE_64BIT_IDS "Use 64-bit indices." ON) if (VTKm_ENABLE_TESTING) enable_testing() include(CTest) + configure_file(${VTKm_SOURCE_DIR}/CTestCustom.cmake.in + ${VTKm_BINARY_DIR}/CTestCustom.cmake @ONLY) endif() #----------------------------------------------------------------------------- diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in new file mode 100644 index 000000000..47487497e --- /dev/null +++ b/CTestCustom.cmake.in @@ -0,0 +1,23 @@ +##============================================================================ +## Copyright (c) Kitware, Inc. +## All rights reserved. +## See LICENSE.txt for details. +## This software is distributed WITHOUT ANY WARRANTY; without even +## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +## PURPOSE. See the above copyright notice for more information. +## +## Copyright 2014 Sandia Corporation. +## Copyright 2014 UT-Battelle, LLC. +## Copyright 2014 Los Alamos National Security. +## +## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +## the U.S. Government retains certain rights in this software. +## +## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +## Laboratory (LANL), the U.S. Government retains certain rights in +## this software. +##============================================================================ + +list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION + "warning: ignoring loop annotation" +) From af7bba062af283151f87c54073e67287db9ca41e Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Fri, 18 Mar 2016 10:54:56 -0400 Subject: [PATCH 3/3] Refactor liner interpolation to use (1-w)*v0+w*v1 Using v0+w*(v1-v0) can be numerically unstaqble due to floating point arithmatic errors. Additionaly, the newer form also resolves type conversion warnings. --- vtkm/VectorAnalysis.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vtkm/VectorAnalysis.h b/vtkm/VectorAnalysis.h index 6c21f01de..4fa409941 100644 --- a/vtkm/VectorAnalysis.h +++ b/vtkm/VectorAnalysis.h @@ -43,10 +43,10 @@ namespace vtkm { template VTKM_EXEC_CONT_EXPORT ValueType Lerp(const ValueType &value0, - const ValueType & value1, + const ValueType &value1, const WeightType &weight) { - return static_cast(value0 + weight * (value1-value0)); + return static_cast((WeightType(1)-weight)*value0+weight*value1); } template VTKM_EXEC_CONT_EXPORT @@ -54,7 +54,7 @@ vtkm::Vec Lerp(const vtkm::Vec &value0, const vtkm::Vec &value1, const WeightType &weight) { - return value0 + static_cast(weight) * (value1-value0); + return (WeightType(1)-weight)*value0+weight*value1; } template VTKM_EXEC_CONT_EXPORT @@ -62,7 +62,8 @@ vtkm::Vec Lerp(const vtkm::Vec &value0, const vtkm::Vec &value1, const vtkm::Vec &weight) { - return value0 + weight * (value1-value0); + static const vtkm::Vec One(ValueType(1)); + return (One-weight)*value0+weight*value1; } // ----------------------------------------------------------------------------