From 50fa6f78d364eb7cf7ada1a669a2813ce73f07f0 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Wed, 22 Jul 2015 13:49:50 -0600 Subject: [PATCH] Fix support for enabling 64bit vtkm::Id and double precision The CMake flag and define differ in their capitalization of the 'm' in VTKm so I've made CMake variables that match those used in Configure.h.in, thereby keeping the original naming of VTKm in CMake code, and VTKM in the C++ code. This fix also revealed some areas in CellSet and CellSetExplicit where ints where used instead of vtkm::Ids which caused errors with child classes who override the methods and returned a vtkm::Id instead of an int. Also fixed issues that appeared in TestOutOfMemory which got out of date due to not being compiled since the `VTKM_USE_64BIT_IDS` flag would never be set. The test now runs and passes when 64bit ids are enabled. --- CMakeLists.txt | 9 +++++++++ vtkm/cont/CellSet.h | 12 ++++++------ vtkm/cont/CellSetExplicit.h | 4 ++-- vtkm/cont/testing/TestingDeviceAdapter.h | 13 +++++++------ 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1471d3756..137735adc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,12 +131,21 @@ check_type_size("long long" VTKm_SIZE_LONG_LONG BUILTIN_TYPES_ONLY) #----------------------------------------------------------------------------- # Build the configure file. +# need to set VTKM_USE_DOUBLE_PRECISION, and VTKM_USE_64BIT_IDS as that +# is the spelling we use for our defines. +set(VTKM_USE_DOUBLE_PRECISION ${VTKm_USE_DOUBLE_PRECISION}) +set(VTKM_USE_64BIT_IDS ${VTKm_USE_64BIT_IDS}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/vtkm/internal/Configure.h.in ${CMAKE_CURRENT_BINARY_DIR}/vtkm/internal/Configure.h @ONLY) vtkm_install_headers( vtkm/internal ${CMAKE_CURRENT_BINARY_DIR}/vtkm/internal/Configure.h) +unset(VTKM_USE_DOUBLE_PRECISION) +unset(VTKM_USE_64BIT_IDS) + +#----------------------------------------------------------------------------- # List of Boost features used: # * Smart Ptr # * Meta programming language diff --git a/vtkm/cont/CellSet.h b/vtkm/cont/CellSet.h index 0c21087d5..65ba99160 100644 --- a/vtkm/cont/CellSet.h +++ b/vtkm/cont/CellSet.h @@ -33,7 +33,7 @@ namespace cont { class CellSet { public: - CellSet(const std::string &n, int d) + CellSet(const std::string &n, vtkm::Id d) : name(n), dimensionality(d), logicalStructure() { } @@ -46,19 +46,19 @@ public: { return name; } - virtual int GetDimensionality() + virtual vtkm::Id GetDimensionality() { return dimensionality; } - virtual int GetNumCells() = 0; + virtual vtkm::Id GetNumCells() = 0; - virtual int GetNumFaces() + virtual vtkm::Id GetNumFaces() { return 0; } - virtual int GetNumEdges() + virtual vtkm::Id GetNumEdges() { return 0; } @@ -67,7 +67,7 @@ public: protected: std::string name; - int dimensionality; + vtkm::Id dimensionality; vtkm::cont::LogicalStructure logicalStructure; }; diff --git a/vtkm/cont/CellSetExplicit.h b/vtkm/cont/CellSetExplicit.h index 8422e4fa9..096e21a33 100644 --- a/vtkm/cont/CellSetExplicit.h +++ b/vtkm/cont/CellSetExplicit.h @@ -37,12 +37,12 @@ public: ConnectivityStorageTag > ExplicitConnectivityType; - CellSetExplicit(const std::string &n, int d) + CellSetExplicit(const std::string &n, vtkm::Id d) : CellSet(n,d) { } - virtual int GetNumCells() + virtual vtkm::Id GetNumCells() { return nodesOfCellsConnectivity.GetNumberOfElements(); } diff --git a/vtkm/cont/testing/TestingDeviceAdapter.h b/vtkm/cont/testing/TestingDeviceAdapter.h index b1f65ebcc..8758b390e 100644 --- a/vtkm/cont/testing/TestingDeviceAdapter.h +++ b/vtkm/cont/testing/TestingDeviceAdapter.h @@ -384,13 +384,14 @@ private: try { std::cout << "Do array allocation that should fail." << std::endl; - vtkm::cont::internal::ArrayManagerExecution< - vtkm::Vector4,StorageTagBasic,DeviceAdapterTag> - bigManager; vtkm::cont::internal::Storage< - vtkm::Vector4, StorageTagBasic> supportArray; + vtkm::Vec, StorageTagBasic> supportArray; + vtkm::cont::internal::ArrayManagerExecution< + vtkm::Vec, StorageTagBasic, DeviceAdapterTag> + bigManager(&supportArray); + const vtkm::Id bigSize = 0x7FFFFFFFFFFFFFFFLL; - bigManager.AllocateArrayForOutput(supportArray, bigSize); + bigManager.PrepareForOutput(bigSize); // It does not seem reasonable to get here. The previous call should fail. VTKM_TEST_FAIL("A ridiculously sized allocation succeeded. Either there " "was a failure that was not reported but should have been " @@ -402,7 +403,7 @@ private: std::cout << "Got the expected error: " << error.GetMessage() << std::endl; } #else - std::cout << "--------- Skiping out of memory test" << std::endl; + std::cout << "--------- Skipping out of memory test" << std::endl; #endif }