...
 
Commits (1391)

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -17,13 +17,22 @@
list(INSERT 0 CMAKE_MODULE_PATH
"${VTK_SOURCE_DIR}/ThirdParty/vtkm/vtkvtkm/vtk-m/CMake")
set(sources)
set(headers)
set(sources
vtkmlib/ArrayConvertersReal.cxx
vtkmlib/ArrayConvertersSigned.cxx
vtkmlib/ArrayConvertersUnsigned.cxx)
set(headers
vtkmFilterPolicy.h
vtkmTags.h)
set(private_headers
vtkmlib/ArrayConverters.hxx
vtkmlib/DataSetConverters.h
vtkmlib/Portals.hxx
vtkmlib/PortalTraits.h
vtkmlib/Storage.hxx)
vtkmlib/Storage.hxx
vtkmDataArray.hxx)
set(impl_classes
vtkmAverageToCells
......@@ -35,6 +44,8 @@ set(impl_classes
vtkmConnectivityExec
vtkmContour
vtkmCoordinateSystemTransform
vtkmDataArray
vtkmDataSet
vtkmExternalFaces
vtkmExtractVOI
vtkmGradient
......@@ -54,13 +65,13 @@ set(impl_classes
set(private_impl_classes
vtkmlib/ArrayConverters
vtkmlib/CellSetConverters
vtkmlib/DataSetConverters
vtkmlib/ImageDataConverter
vtkmlib/ImplicitFunctionConverter
vtkmlib/PolyDataConverter
vtkmlib/Portals
vtkmlib/Storage
vtkmlib/UnstructuredGridConverter
vtkmlib/DataSetConverters
vtkmlib/ImplicitFunctionConverter
vtkmlib/Portals)
vtkmlib/UnstructuredGridConverter)
foreach (class IN LISTS impl_classes)
list(APPEND sources "${class}.cxx")
......@@ -74,9 +85,6 @@ endforeach ()
if (TARGET vtkm::cuda)
set_source_files_properties(${sources} PROPERTIES LANGUAGE "CUDA")
#The vtkmlib/CellSetConverters need to be built always as CXX
#as the worklets used by them require access to vtk classes
set_source_files_properties(vtkmlib/CellSetConverters.cxx PROPERTIES LANGUAGE "CXX")
endif ()
set(VTKM_FILTER_INCLUDE_AOS ${VTK_DISPATCH_AOS_ARRAYS})
......@@ -117,7 +125,10 @@ if (TARGET vtkm::cuda)
get_property(arch_flags
TARGET vtkm::cuda
PROPERTY VTKm_CUDA_Architecture_Flags)
PROPERTY INTERFACE_CUDA_Architecture_Flags)
if(NOT arch_flags)
message(FATAL_ERROR "VTK-m CUDA Architecture flags can't be found. This means we can't safely compile CUDA code")
endif()
string(APPEND CMAKE_CUDA_FLAGS " ${arch_flags}")
# Temporarily suppress "has address taken but no possible call to it" warnings,
......@@ -127,10 +138,20 @@ if (TARGET vtkm::cuda)
string(APPEND CMAKE_CUDA_FLAGS " -Xnvlink -w")
endif ()
vtk_module_add_module(VTK::AcceleratorsVTKm
SOURCES ${sources}
HEADERS ${headers}
PRIVATE_HEADERS ${private_headers})
if(TARGET vtkm::cuda AND BUILD_SHARED_LIBS)
message("Cuda is enabled. Module VTK::AcceleratorsVTKm will be forced to build as static.")
vtk_module_add_module(VTK::AcceleratorsVTKm
FORCE_STATIC
SOURCES ${sources}
HEADERS ${headers}
PRIVATE_HEADERS ${private_headers})
else()
vtk_module_add_module(VTK::AcceleratorsVTKm
SOURCES ${sources}
HEADERS ${headers}
PRIVATE_HEADERS ${private_headers})
endif()
vtk_module_set_property(VTK::AcceleratorsVTKm
PROPERTY JOB_POOL_COMPILE
VALUE vtkm_pool)
......
vtk_add_test_cxx(vtkAcceleratorsVTKmCxxTests tests
vtk_add_test_cxx(vtkAcceleratorsVTKmCxxTests1 tests1
TestVTKMCleanGrid.cxx
TestVTKMCoordinateSystemTransform.cxx,NO_VALID
TestVTKMClip.cxx
......@@ -24,16 +24,54 @@ vtk_add_test_cxx(vtkAcceleratorsVTKmCxxTests tests
TestVTKMWarpVector.cxx
)
# We are splitting the tests into two executables to workaround an issue in
# cuda. With all the tests in the same executable several tests are failing
# in cuda. We have not identified the root cause of the problem yet.
vtk_add_test_cxx(vtkAcceleratorsVTKmCxxTests2 tests2
TestVTKMDataArray.cxx,NO_VALID
TestVTKMDataSet.cxx,NO_VALID
)
if (TARGET vtkm::cuda)
#the enable_language call is scoped! so we have to re-enable
#cuda in the test directory
enable_language(CUDA)
foreach(src IN LISTS tests)
foreach(src IN LISTS tests1)
set_source_files_properties(${src}.cxx PROPERTIES LANGUAGE "CUDA")
endforeach()
foreach(src IN LISTS tests2)
set_source_files_properties(${src}.cxx PROPERTIES LANGUAGE "CUDA")
endforeach()
#the tests aren't scoped as a child directory of vtkAcceleratorsVTKm
#so we need to redo this logic
get_property(arch_flags
TARGET vtkm::cuda
PROPERTY INTERFACE_CUDA_Architecture_Flags)
if(NOT arch_flags)
message(FATAL_ERROR "VTK-m CUDA Architecture flags can't be found. This means we can't safely compile CUDA code")
endif()
string(APPEND CMAKE_CUDA_FLAGS " ${arch_flags}")
# Temporarily suppress "has address taken but no possible call to it" warnings,
# until we figure out its implications.
# We are disabling all warnings as nvlink has no known way to suppress
# individual warning types.
string(APPEND CMAKE_CUDA_FLAGS " -Xnvlink -w")
endif()
vtk_test_cxx_executable(vtkAcceleratorsVTKmCxxTests tests
vtk_test_cxx_executable(vtkAcceleratorsVTKmCxxTests1 tests1
RENDERING_FACTORY
)
vtk_test_cxx_executable(vtkAcceleratorsVTKmCxxTests2 tests2
RENDERING_FACTORY
)
if (TARGET vtkm::cuda)
# When cuda is enabled VTK::AcceleratorsVTKm is built statically but with fpic
# enabled so the tests are also built with fpic enabled
set_target_properties(vtkAcceleratorsVTKmCxxTests1 PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(vtkAcceleratorsVTKmCxxTests2 PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
#include "vtkmDataArray.h"
#include "vtkSmartPointer.h"
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vector>
namespace
{
//-----------------------------------------------------------------------------
class TestError
{
public:
TestError(const std::string& message, int line)
: Message(message), Line(line)
{
}
void PrintMessage(std::ostream& out) const
{
out << "Error at line " << this->Line << ": " << this->Message << "\n";
}
private:
std::string Message;
int Line;
};
#define RAISE_TEST_ERROR(msg) throw TestError((msg), __LINE__)
#define TEST_VERIFY(cond, msg) if (!(cond)) RAISE_TEST_ERROR((msg))
inline bool IsEqualFloat(double a, double b, double e = 1e-6f)
{
return (std::abs(a - b) <= e);
}
//-----------------------------------------------------------------------------
template <typename ArrayHandleType>
void TestWithArrayHandle(const ArrayHandleType& vtkmArray)
{
vtkSmartPointer<vtkDataArray> vtkArray;
vtkArray.TakeReference(make_vtkmDataArray(vtkmArray));
auto vtkmPortal = vtkmArray.GetPortalConstControl();
vtkIdType length = vtkArray->GetNumberOfTuples();
std::cout << "Length: " << length << "\n";
TEST_VERIFY(length == vtkmArray.GetNumberOfValues(), "Array lengths don't match");
int numberOfComponents = vtkArray->GetNumberOfComponents();
std::cout << "Number of components: " << numberOfComponents << "\n";
TEST_VERIFY(
numberOfComponents ==
internal::FlattenVec<typename ArrayHandleType::ValueType>::GetNumberOfComponents(vtkmPortal.Get(0)),
"Number of components don't match");
for (vtkIdType i = 0; i < length; ++i)
{
double tuple[9];
vtkArray->GetTuple(i, tuple);
auto val = vtkmPortal.Get(i);
for (int j = 0; j < numberOfComponents; ++j)
{
auto comp = internal::FlattenVec<typename ArrayHandleType::ValueType>::GetComponent(val, j);
TEST_VERIFY (IsEqualFloat(tuple[j], static_cast<double>(comp)), "values don't match");
TEST_VERIFY (IsEqualFloat(vtkArray->GetComponent(i, j), static_cast<double>(comp)),
"values don't match");
}
}
}
} // anonymous namespace
//-----------------------------------------------------------------------------
int TestVTKMDataArray(int, char*[])
try
{
static const std::vector<double> testData = { 3.0, 6.0, 2.0, 5.0, 1.0, 0.0, 4.0 };
std::cout << "Testing with Basic ArrayHandle\n";
TestWithArrayHandle(vtkm::cont::make_ArrayHandle(testData));
std::cout << "Passed\n";
std::cout << "Testing with ArrayHandleConstant\n";
TestWithArrayHandle(vtkm::cont::make_ArrayHandleConstant(vtkm::Vec<vtkm::Vec<float, 3>, 3>{{1.0f, 2.0f, 3.0f}}, 10));
std::cout << "Passed\n";
std::cout << "Testing with ArrayHandleUniformPointCoordinates\n";
TestWithArrayHandle(vtkm::cont::ArrayHandleUniformPointCoordinates(vtkm::Id3{3}));
std::cout << "Passed\n";
return EXIT_SUCCESS;
}
catch (const TestError& e)
{
e.PrintMessage(std::cout);
return 1;
}
This diff is collapsed.
......@@ -310,7 +310,7 @@ void RunBenchmark(int gridSize)
#ifdef FORCE_VTKM_DEVICE
vtkm::cont::RuntimeDeviceTracker tracker =
vtkm::cont::GetGlobalRuntimeDeviceTracker();
vtkm::cont::GetRuntimeDeviceTracker();
// Run VTKm
vtkSmartPointer<vtkPolyData> vtkmResultSerial;
......
......@@ -68,7 +68,9 @@ int TestVTKMPolyDataNormals(int argc, char* argv[])
normals->SetInputData(input);
normals->ComputePointNormalsOn();
normals->ComputeCellNormalsOn();
normals->AutoOrientNormalsOn();
normals->FlipNormalsOn();
normals->ConsistencyOn();
// cylinder mapper and actor
vtkNew<vtkPolyDataMapper> cylinderMapper;
......@@ -104,6 +106,7 @@ int TestVTKMPolyDataNormals(int argc, char* argv[])
pnRenderer->AddActor(pnActor);
pnRenderer->ResetCamera();
pnRenderer->GetActiveCamera()->SetPosition(0.0, 4.5, 7.5);
pnRenderer->ResetCameraClippingRange();
// cell normals
......@@ -128,6 +131,7 @@ int TestVTKMPolyDataNormals(int argc, char* argv[])
cnRenderer->AddActor(cnActor);
cnRenderer->ResetCamera();
cnRenderer->GetActiveCamera()->SetPosition(0.0, 8.0, 0.1);
cnRenderer->ResetCameraClippingRange();
// render
......
23cdde8b30b7c3201021ddfb7f9cb573d2730275dda787a15bde59778251890144656c8babce642942987886dfdf35922f48dafcb79ab4198c07860db44e16fc
fe0c2c50c18e1760937f7c2b4984f56471668d058cff6936e790ed0268ddf0098dbf82c9dacbcfc3c39ba74a7643e5fde4e0ddaa84276ffa7bc9950afffcf961
......@@ -69,7 +69,7 @@ rtMin = algs.min(rtData)
rtMax = algs.max(rtData)
clipScalar = 0.5 * (rtMin + rtMax)
print("Testing non-homogenous unstructured grid...")
print("Testing non-homogeneous unstructured grid...")
clip = vtk.vtkClipDataSet()
clip.SetInputData(imgData)
clip.SetValue(clipScalar)
......
......@@ -73,7 +73,7 @@ rtMin = algs.min(rtData)
rtMax = algs.max(rtData)
clipScalar = 0.5 * (rtMin + rtMax)
print("Testing non-homogenous unstructured grid...")
print("Testing non-homogeneous unstructured grid...")
clip = vtk.vtkClipDataSet()
clip.SetInputData(imgData)
clip.SetValue(clipScalar)
......
......@@ -36,7 +36,7 @@ namespace
template <typename Device>
struct ExplicitRConnToConn
{
using OffsetsArray = vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkAOSArrayContainerTag>;
using OffsetsArray = vtkm::cont::ArrayHandle<vtkm::Id>;
using OffsetsPortal = decltype(std::declval<OffsetsArray>().PrepareForInput(Device()));
// Functor that modifies the offsets array so we can compute point id indices
......@@ -132,7 +132,7 @@ private:
template <typename Device>
struct ExplicitCellIdCalc
{
using OffsetsArray = vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkAOSArrayContainerTag>;
using OffsetsArray = vtkm::cont::ArrayHandle<vtkm::Id>;
using OffsetsPortal = decltype(std::declval<OffsetsArray>().PrepareForInput(Device()));
vtkm::Id ConnSize;
......@@ -208,14 +208,53 @@ private:
namespace vtkm {
namespace cont {
//------------------------------------------------------------------------------
vtkm::IdComponent vtkmCellSetExplicitAOS::GetNumberOfPointsInCell(vtkm::Id index) const
{
return this->Connectivity.GetPortalConstControl().Get(
this->IndexOffsets.GetPortalConstControl().Get(index));
}
vtkm::UInt8 vtkmCellSetExplicitAOS::GetCellShape(vtkm::Id index) const
{
return this->Shapes.GetPortalConstControl().Get(index);
}
void vtkmCellSetExplicitAOS::GetCellPointIds(vtkm::Id id, vtkm::Id *ptids) const
{
auto connPortal = this->Connectivity.GetPortalConstControl();
auto start = this->IndexOffsets.GetPortalConstControl().Get(id);
auto count = connPortal.Get(start++);
for (vtkm::Id i = 0; i < count; ++i)
{
ptids[i] = connPortal.Get(i + start);
}
}
std::shared_ptr<CellSet> vtkmCellSetExplicitAOS::NewInstance() const
{
return std::make_shared<vtkmCellSetExplicitAOS>();
}
void vtkmCellSetExplicitAOS::DeepCopy(const CellSet* src)
{
const auto* other = dynamic_cast<const vtkmCellSetExplicitAOS*>(src);
if (!other)
{
throw vtkm::cont::ErrorBadType("Incorrect type passed to CellSetExplicit::DeepCopy");
}
this->Fill(other->NumberOfPoints, other->Shapes, other->Connectivity, other->IndexOffsets);
}
//------------------------------------------------------------------------------
void vtkmCellSetExplicitAOS::Fill(
vtkm::Id numberOfPoints,
const vtkm::cont::ArrayHandle<vtkm::UInt8, tovtkm::vtkAOSArrayContainerTag>&
const vtkm::cont::ArrayHandle<vtkm::UInt8>&
cellTypes,
const vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkCellArrayContainerTag>&
connectivity,
const vtkm::cont::ArrayHandle<vtkm::Id, tovtkm::vtkAOSArrayContainerTag>&
const vtkm::cont::ArrayHandle<vtkm::Id>&
offsets)
{
this->Shapes = cellTypes;
......@@ -240,8 +279,8 @@ void vtkmCellSetExplicitAOS::PrintSummary(std::ostream& out) const
template <typename Device>
typename vtkm::exec::ConnectivityVTKAOS<Device>
vtkmCellSetExplicitAOS::PrepareForInput(Device,
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const
{
return vtkm::exec::ConnectivityVTKAOS<Device>(
this->Shapes.PrepareForInput(Device()),
......@@ -253,8 +292,8 @@ typename vtkm::exec::ConnectivityVTKAOS<Device>
template <typename Device>
typename vtkm::exec::ReverseConnectivityVTK<Device>
vtkmCellSetExplicitAOS::PrepareForInput(Device,
vtkm::TopologyElementTagCell,
vtkm::TopologyElementTagPoint) const
vtkm::TopologyElementTagPoint,
vtkm::TopologyElementTagCell) const
{
//One of the biggest questions when computing the reverse connectivity
//is how are we going to layout the results.
......@@ -308,47 +347,47 @@ typename vtkm::exec::ReverseConnectivityVTK<Device>
template VTKACCELERATORSVTKM_EXPORT
vtkm::exec::ConnectivityVTKAOS<vtkm::cont::DeviceAdapterTagSerial>
vtkmCellSetExplicitAOS::PrepareForInput(vtkm::cont::DeviceAdapterTagSerial,
vtkm::TopologyElementTagPoint, vtkm::TopologyElementTagCell) const;
vtkm::TopologyElementTagCell, vtkm::TopologyElementTagPoint) const;
template VTKACCELERATORSVTKM_EXPORT