mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Add types appropriate for Ascent
This commit is contained in:
parent
865855ea02
commit
cecd81d5db
@ -29,6 +29,10 @@ foreach(option IN LISTS options)
|
|||||||
elseif(vtk_types STREQUAL option)
|
elseif(vtk_types STREQUAL option)
|
||||||
set(VTKm_USE_DEFAULT_TYPES_FOR_VTK "ON" CACHE STRING "")
|
set(VTKm_USE_DEFAULT_TYPES_FOR_VTK "ON" CACHE STRING "")
|
||||||
|
|
||||||
|
elseif(ascent_types STREQUAL option)
|
||||||
|
# Note: ascent_types also requires 32bit_ids and 64bit_floats
|
||||||
|
set(VTKm_USE_DEFAULT_TYPES_FOR_ASCENT "ON" CACHE STRING "")
|
||||||
|
|
||||||
elseif(32bit_ids STREQUAL option)
|
elseif(32bit_ids STREQUAL option)
|
||||||
set(VTKm_USE_64BIT_IDS "OFF" CACHE STRING "")
|
set(VTKm_USE_64BIT_IDS "OFF" CACHE STRING "")
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ build:ubuntu1604_gcc5:
|
|||||||
CC: "gcc-5"
|
CC: "gcc-5"
|
||||||
CXX: "g++-5"
|
CXX: "g++-5"
|
||||||
CMAKE_BUILD_TYPE: RelWithDebInfo
|
CMAKE_BUILD_TYPE: RelWithDebInfo
|
||||||
VTKM_SETTINGS: "cuda+pascal+no_virtual"
|
VTKM_SETTINGS: "cuda+pascal+no_virtual+ascent_types+32bit_ids+64bit_floats"
|
||||||
|
|
||||||
test:ubuntu1604_gcc5:
|
test:ubuntu1604_gcc5:
|
||||||
tags:
|
tags:
|
||||||
|
@ -217,12 +217,36 @@ endif()
|
|||||||
vtkm_get_kit_name(kit_name kit_dir)
|
vtkm_get_kit_name(kit_name kit_dir)
|
||||||
|
|
||||||
# Some custom types included with VTK-m
|
# Some custom types included with VTK-m
|
||||||
vtkm_option(VTKm_USE_DEFAULT_TYPES_FOR_VTK "Compile VTK-m algorithms for use with types from VTK." OFF)
|
vtkm_option(VTKm_USE_DEFAULT_TYPES_FOR_VTK
|
||||||
|
"Compile VTK-m algorithms for use with types from VTK."
|
||||||
|
OFF
|
||||||
|
)
|
||||||
if (VTKm_USE_DEFAULT_TYPES_FOR_VTK)
|
if (VTKm_USE_DEFAULT_TYPES_FOR_VTK)
|
||||||
set(VTKm_DEFAULT_TYPES_HEADER "internal/DefaultTypesVTK.h.in")
|
set(VTKm_DEFAULT_TYPES_HEADER "internal/DefaultTypesVTK.h.in")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
mark_as_advanced(VTKm_USE_DEFAULT_TYPES_FOR_VTK)
|
vtkm_option(VTKm_USE_DEFAULT_TYPES_FOR_ASCENT
|
||||||
|
"Compile VTK-m algorithms for use with types from Ascent."
|
||||||
|
OFF
|
||||||
|
)
|
||||||
|
if (VTKm_USE_DEFAULT_TYPES_FOR_ASCENT)
|
||||||
|
set(VTKm_DEFAULT_TYPES_HEADER "internal/DefaultTypesAscent.h.in")
|
||||||
|
if (VTKm_USE_64BIT_IDS)
|
||||||
|
message(SEND_ERROR
|
||||||
|
"When VTKm_USE_DEFAULT_TYPES_FOR_ASCENT is ON, VTKm_USE_64BIT_IDS must be set to OFF"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if (NOT VTKm_USE_DOUBLE_PRECISION)
|
||||||
|
message(SEND_ERROR
|
||||||
|
"When VTKm_USE_DEFAULT_TYPES_FOR_ASCENT is ON, VTKm_USE_DOUBLE_PRECISION must be set to ON"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
VTKm_USE_DEFAULT_TYPES_FOR_VTK
|
||||||
|
VTKm_USE_DEFAULT_TYPES_FOR_ASCENT
|
||||||
|
)
|
||||||
|
|
||||||
if (VTKm_DEFAULT_TYPES_HEADER)
|
if (VTKm_DEFAULT_TYPES_HEADER)
|
||||||
set(VTK_M_HAS_DEFAULT_TYPES_HEADER TRUE)
|
set(VTK_M_HAS_DEFAULT_TYPES_HEADER TRUE)
|
||||||
|
69
vtkm/cont/internal/DefaultTypesAscent.h.in
Normal file
69
vtkm/cont/internal/DefaultTypesAscent.h.in
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
//============================================================================
|
||||||
|
// 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.
|
||||||
|
//============================================================================
|
||||||
|
#ifndef vtk_m_cont_internal_DefaultTypesAscent_h
|
||||||
|
#define vtk_m_cont_internal_DefaultTypesAscent_h
|
||||||
|
|
||||||
|
#include <vtkm/TypeList.h>
|
||||||
|
#include <vtkm/Types.h>
|
||||||
|
|
||||||
|
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
|
||||||
|
#include <vtkm/cont/ArrayHandleSOA.h>
|
||||||
|
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||||
|
#include <vtkm/cont/StorageList.h>
|
||||||
|
|
||||||
|
#ifdef VTKM_USE_64BIT_IDS
|
||||||
|
#error "VTK-m must be compiled with VTKM_USE_64BITS_IDS set to OFF for Ascent."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef VTKM_USE_DOUBLE_PRECISION
|
||||||
|
#error "VTK-m must be compiled with VTKM_USE_DOUBLE_PRECISION to ON for Ascent."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
|
||||||
|
// Default value types for fields in Ascent.
|
||||||
|
using TypeListAscent = vtkm::List<vtkm::FloatDefault,
|
||||||
|
vtkm::Vec3f,
|
||||||
|
// We should not need Float32 types, but currently the tests need
|
||||||
|
// them. We should remove these types once we are able to "fix"
|
||||||
|
// the tests by converting to supported default types.
|
||||||
|
vtkm::Float32,
|
||||||
|
vtkm::Vec3f_32>;
|
||||||
|
|
||||||
|
}
|
||||||
|
} // namespace vtkm::internal
|
||||||
|
|
||||||
|
#define VTKM_DEFAULT_TYPE_LIST ::vtkm::internal::TypeListAscent
|
||||||
|
|
||||||
|
namespace vtkm
|
||||||
|
{
|
||||||
|
namespace cont
|
||||||
|
{
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
|
||||||
|
using StorageListAscent = vtkm::List<
|
||||||
|
vtkm::cont::StorageTagBasic, // Basic storage should always be included
|
||||||
|
vtkm::cont::StorageTagSOA, // Support separate arrays for each component
|
||||||
|
vtkm::cont::StorageTagUniformPoints, // Support uniform structured grids
|
||||||
|
vtkm::cont::StorageTagCartesianProduct<vtkm::cont::StorageTagBasic, // Support rectilinear grids
|
||||||
|
vtkm::cont::StorageTagBasic,
|
||||||
|
vtkm::cont::StorageTagBasic>>;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace vtkm::cont::internal
|
||||||
|
|
||||||
|
#define VTKM_DEFAULT_STORAGE_LIST ::vtkm::cont::internal::StorageListAscent
|
||||||
|
|
||||||
|
#endif //vtk_m_cont_internal_DefaultTypesAscent_h
|
@ -7,8 +7,8 @@
|
|||||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
// PURPOSE. See the above copyright notice for more information.
|
// PURPOSE. See the above copyright notice for more information.
|
||||||
//============================================================================
|
//============================================================================
|
||||||
#ifndef vtkmDefaultTypes_h
|
#ifndef vtk_m_cont_internal_DefaultTypesVTK_h
|
||||||
#define vtkmDefaultTypes_h
|
#define vtk_m_cont_internal_DefaultTypesVTK_h
|
||||||
|
|
||||||
// This configures the default types to use when compiling VTK-m for use as an
|
// This configures the default types to use when compiling VTK-m for use as an
|
||||||
// accelerator in VTK.
|
// accelerator in VTK.
|
||||||
@ -105,4 +105,4 @@ using CellListAllOutVTK = vtkm::ListAppend<CellListStructuredOutVTK, CellListUns
|
|||||||
#define VTKM_DEFAULT_CELL_SET_LIST_STRUCTURED ::tovtkm::CellListStructuredInVTK
|
#define VTKM_DEFAULT_CELL_SET_LIST_STRUCTURED ::tovtkm::CellListStructuredInVTK
|
||||||
#define VTKM_DEFAULT_CELL_SET_LIST_UNSTRUCTURED ::tovtkm::CellListUnstructuredInVTK
|
#define VTKM_DEFAULT_CELL_SET_LIST_UNSTRUCTURED ::tovtkm::CellListUnstructuredInVTK
|
||||||
|
|
||||||
#endif //vtkmDefaultTypes_h
|
#endif //vtk_m_cont_internal_DefaultTypesVTK_h
|
||||||
|
@ -416,17 +416,20 @@ void TryAsMultiplexer(T, ArrayVariantType sourceArray)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
struct TryDefaultType
|
||||||
void TryDefaultType(T)
|
|
||||||
{
|
{
|
||||||
vtkm::cont::VariantArrayHandle array = CreateArrayVariant(T());
|
template <typename T>
|
||||||
|
void operator()(T) const
|
||||||
|
{
|
||||||
|
vtkm::cont::VariantArrayHandle array = CreateArrayVariant(T());
|
||||||
|
|
||||||
CheckArrayVariant(array, vtkm::VecTraits<T>::NUM_COMPONENTS, true);
|
CheckArrayVariant(array, vtkm::VecTraits<T>::NUM_COMPONENTS, true);
|
||||||
|
|
||||||
TryNewInstance(T(), array);
|
TryNewInstance(T(), array);
|
||||||
|
|
||||||
TryAsMultiplexer(T(), array);
|
TryAsMultiplexer(T(), array);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct TryBasicVTKmType
|
struct TryBasicVTKmType
|
||||||
{
|
{
|
||||||
@ -471,18 +474,18 @@ void TryCastToArrayHandle(const ArrayHandleType& array)
|
|||||||
void TryCastToArrayHandle()
|
void TryCastToArrayHandle()
|
||||||
{
|
{
|
||||||
std::cout << " Normal array handle." << std::endl;
|
std::cout << " Normal array handle." << std::endl;
|
||||||
vtkm::Id buffer[ARRAY_SIZE];
|
vtkm::FloatDefault buffer[ARRAY_SIZE];
|
||||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||||
{
|
{
|
||||||
buffer[index] = TestValue(index, vtkm::Id());
|
buffer[index] = TestValue(index, vtkm::FloatDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> array =
|
vtkm::cont::ArrayHandle<vtkm::FloatDefault> array =
|
||||||
vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE, vtkm::CopyFlag::On);
|
vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE, vtkm::CopyFlag::On);
|
||||||
TryCastToArrayHandle(array);
|
TryCastToArrayHandle(array);
|
||||||
|
|
||||||
std::cout << " Cast array handle." << std::endl;
|
std::cout << " Cast array handle." << std::endl;
|
||||||
TryCastToArrayHandle(vtkm::cont::make_ArrayHandleCast(array, vtkm::FloatDefault()));
|
TryCastToArrayHandle(vtkm::cont::make_ArrayHandleCast<vtkm::Id>(array));
|
||||||
|
|
||||||
std::cout << " Composite vector array handle." << std::endl;
|
std::cout << " Composite vector array handle." << std::endl;
|
||||||
TryCastToArrayHandle(vtkm::cont::make_ArrayHandleCompositeVector(array, array));
|
TryCastToArrayHandle(vtkm::cont::make_ArrayHandleCompositeVector(array, array));
|
||||||
@ -495,7 +498,8 @@ void TryCastToArrayHandle()
|
|||||||
TryCastToArrayHandle(countingArray);
|
TryCastToArrayHandle(countingArray);
|
||||||
|
|
||||||
std::cout << " Group vec array handle" << std::endl;
|
std::cout << " Group vec array handle" << std::endl;
|
||||||
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<vtkm::Id>, 2> groupVecArray(array);
|
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<vtkm::FloatDefault>, 2> groupVecArray(
|
||||||
|
array);
|
||||||
TryCastToArrayHandle(groupVecArray);
|
TryCastToArrayHandle(groupVecArray);
|
||||||
|
|
||||||
std::cout << " Implicit array handle." << std::endl;
|
std::cout << " Implicit array handle." << std::endl;
|
||||||
@ -522,18 +526,7 @@ void TryCastToArrayHandle()
|
|||||||
void TestVariantArrayHandle()
|
void TestVariantArrayHandle()
|
||||||
{
|
{
|
||||||
std::cout << "Try common types with default type lists." << std::endl;
|
std::cout << "Try common types with default type lists." << std::endl;
|
||||||
std::cout << "*** vtkm::Id **********************" << std::endl;
|
vtkm::testing::Testing::TryTypes(TryDefaultType{}, VTKM_DEFAULT_TYPE_LIST{});
|
||||||
TryDefaultType(vtkm::Id());
|
|
||||||
std::cout << "*** vtkm::FloatDefault ************" << std::endl;
|
|
||||||
TryDefaultType(vtkm::FloatDefault());
|
|
||||||
std::cout << "*** vtkm::Float32 *****************" << std::endl;
|
|
||||||
TryDefaultType(vtkm::Float32());
|
|
||||||
std::cout << "*** vtkm::Float64 *****************" << std::endl;
|
|
||||||
TryDefaultType(vtkm::Float64());
|
|
||||||
std::cout << "*** vtkm::Vec<Float32,3> **********" << std::endl;
|
|
||||||
TryDefaultType(vtkm::Vec3f_32());
|
|
||||||
std::cout << "*** vtkm::Vec<Float64,3> **********" << std::endl;
|
|
||||||
TryDefaultType(vtkm::Vec3f_64());
|
|
||||||
|
|
||||||
std::cout << "Try exemplar VTK-m types." << std::endl;
|
std::cout << "Try exemplar VTK-m types." << std::endl;
|
||||||
vtkm::testing::Testing::TryTypes(TryBasicVTKmType());
|
vtkm::testing::Testing::TryTypes(TryBasicVTKmType());
|
||||||
|
@ -18,7 +18,7 @@ void TestFieldToColors()
|
|||||||
{
|
{
|
||||||
//faux input field
|
//faux input field
|
||||||
constexpr vtkm::Id nvals = 8;
|
constexpr vtkm::Id nvals = 8;
|
||||||
constexpr int data[nvals] = { -1, 0, 10, 20, 30, 40, 50, 60 };
|
constexpr vtkm::FloatDefault data[nvals] = { -1, 0, 10, 20, 30, 40, 50, 60 };
|
||||||
|
|
||||||
//build a color table with clamping off and verify that sampling works
|
//build a color table with clamping off and verify that sampling works
|
||||||
vtkm::Range range{ 0.0, 50.0 };
|
vtkm::Range range{ 0.0, 50.0 };
|
||||||
|
@ -70,7 +70,7 @@ vtkm::cont::PartitionedDataSet PartitionedDataSetBuilder(std::size_t partitionNu
|
|||||||
}
|
}
|
||||||
return partitions;
|
return partitions;
|
||||||
}
|
}
|
||||||
template <typename D>
|
template <typename T, typename D>
|
||||||
void Result_Verify(const vtkm::cont::PartitionedDataSet& result,
|
void Result_Verify(const vtkm::cont::PartitionedDataSet& result,
|
||||||
D& filter,
|
D& filter,
|
||||||
const vtkm::cont::PartitionedDataSet& partitions,
|
const vtkm::cont::PartitionedDataSet& partitions,
|
||||||
@ -88,9 +88,9 @@ void Result_Verify(const vtkm::cont::PartitionedDataSet& result,
|
|||||||
partitionResult.GetField(outputFieldName).GetNumberOfValues(),
|
partitionResult.GetField(outputFieldName).GetNumberOfValues(),
|
||||||
"result vectors' size incorrect");
|
"result vectors' size incorrect");
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> partitionArray;
|
vtkm::cont::ArrayHandle<T> partitionArray;
|
||||||
result.GetPartition(j).GetField(outputFieldName).GetData().CopyTo(partitionArray);
|
result.GetPartition(j).GetField(outputFieldName).GetData().CopyTo(partitionArray);
|
||||||
vtkm::cont::ArrayHandle<vtkm::Id> sDataSetArray;
|
vtkm::cont::ArrayHandle<T> sDataSetArray;
|
||||||
partitionResult.GetField(outputFieldName).GetData().CopyTo(sDataSetArray);
|
partitionResult.GetField(outputFieldName).GetData().CopyTo(sDataSetArray);
|
||||||
|
|
||||||
const vtkm::Id numValues = result.GetPartition(j).GetField(outputFieldName).GetNumberOfValues();
|
const vtkm::Id numValues = result.GetPartition(j).GetField(outputFieldName).GetNumberOfValues();
|
||||||
@ -109,12 +109,12 @@ void TestPartitionedDataSetFilters()
|
|||||||
vtkm::cont::PartitionedDataSet result;
|
vtkm::cont::PartitionedDataSet result;
|
||||||
vtkm::cont::PartitionedDataSet partitions;
|
vtkm::cont::PartitionedDataSet partitions;
|
||||||
|
|
||||||
partitions = PartitionedDataSetBuilder<vtkm::Id>(partitionNum, "pointvar");
|
partitions = PartitionedDataSetBuilder<vtkm::FloatDefault>(partitionNum, "pointvar");
|
||||||
vtkm::filter::CellAverage cellAverage;
|
vtkm::filter::CellAverage cellAverage;
|
||||||
cellAverage.SetOutputFieldName("average");
|
cellAverage.SetOutputFieldName("average");
|
||||||
cellAverage.SetActiveField("pointvar");
|
cellAverage.SetActiveField("pointvar");
|
||||||
result = cellAverage.Execute(partitions);
|
result = cellAverage.Execute(partitions);
|
||||||
Result_Verify(result, cellAverage, partitions, std::string("pointvar"));
|
Result_Verify<vtkm::FloatDefault>(result, cellAverage, partitions, std::string("pointvar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int UnitTestPartitionedDataSetFilters(int argc, char* argv[])
|
int UnitTestPartitionedDataSetFilters(int argc, char* argv[])
|
||||||
|
@ -126,14 +126,16 @@ struct DoVariantTestWorklet
|
|||||||
std::cout << "Create and run dispatcher with unknown arrays." << std::endl;
|
std::cout << "Create and run dispatcher with unknown arrays." << std::endl;
|
||||||
vtkm::worklet::DispatcherMapField<WorkletType> dispatcher;
|
vtkm::worklet::DispatcherMapField<WorkletType> dispatcher;
|
||||||
|
|
||||||
vtkm::cont::UnknownArrayHandle inputVariant(inputHandle);
|
using UncertainArrayType =
|
||||||
|
vtkm::cont::UncertainArrayHandle<vtkm::List<T>, VTKM_DEFAULT_STORAGE_LIST>;
|
||||||
|
UncertainArrayType inputVariant(inputHandle);
|
||||||
|
|
||||||
{ //Verify we can pass by value
|
{ //Verify we can pass by value
|
||||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
|
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
|
||||||
vtkm::cont::UnknownArrayHandle outputVariant(outputHandle);
|
vtkm::cont::UnknownArrayHandle outputVariant(outputHandle);
|
||||||
vtkm::cont::UnknownArrayHandle inoutVariant(inoutHandle);
|
vtkm::cont::UnknownArrayHandle inoutVariant(inoutHandle);
|
||||||
dispatcher.Invoke(
|
dispatcher.Invoke(
|
||||||
inputVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>(),
|
inputVariant.template ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>(),
|
||||||
outputVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>(),
|
outputVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>(),
|
||||||
inoutVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>());
|
inoutVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>());
|
||||||
CheckPortal(outputHandle.ReadPortal());
|
CheckPortal(outputHandle.ReadPortal());
|
||||||
@ -141,8 +143,8 @@ struct DoVariantTestWorklet
|
|||||||
}
|
}
|
||||||
|
|
||||||
{ //Verify we can pass by pointer
|
{ //Verify we can pass by pointer
|
||||||
vtkm::cont::UnknownArrayHandle outputVariant(outputHandle);
|
UncertainArrayType outputVariant(outputHandle);
|
||||||
vtkm::cont::UnknownArrayHandle inoutVariant(inoutHandle);
|
UncertainArrayType inoutVariant(inoutHandle);
|
||||||
|
|
||||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
|
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
|
||||||
dispatcher.Invoke(&inputVariant, outputHandle, inoutHandle);
|
dispatcher.Invoke(&inputVariant, outputHandle, inoutHandle);
|
||||||
|
Loading…
Reference in New Issue
Block a user