Remove device compiler dependencies.

This commit is contained in:
Dave Pugmire 2022-08-01 08:00:46 -04:00
parent 2a4430447a
commit e1fbfea305
26 changed files with 164 additions and 113 deletions

@ -14,6 +14,7 @@
#include <sstream>
#include <vtkm/ImplicitFunction.h>
#include <vtkm/Particle.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>

@ -10,11 +10,9 @@
#include "Benchmarker.h"
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/Particle.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/ErrorInternal.h>
#include <vtkm/cont/Logging.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
#include <vtkm/cont/Timer.h>

@ -14,10 +14,4 @@ project(ParticleAdvection CXX)
find_package(VTKm REQUIRED QUIET)
add_executable(Particle_Advection ParticleAdvection.cxx)
target_link_libraries(Particle_Advection PRIVATE vtkm_filter vtkm_io)
vtkm_add_target_information(Particle_Advection
DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS
DEVICE_SOURCES ParticleAdvection.cxx)
if(TARGET vtkm::tbb)
target_compile_definitions(Particle_Advection PRIVATE BUILDING_TBB_VERSION)
endif()
target_link_libraries(Particle_Advection PRIVATE vtkm_filter_flow vtkm_io)

@ -8,8 +8,7 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/Particle.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/filter/flow/Streamline.h>

@ -16,12 +16,5 @@ find_package(VTKm REQUIRED QUIET)
if (VTKm_ENABLE_MPI)
add_executable(StreamlineMPI StreamlineMPI.cxx)
target_compile_definitions(StreamlineMPI PRIVATE "MPI_ENABLED")
target_link_libraries(StreamlineMPI PRIVATE vtkm_filter vtkm_io MPI::MPI_CXX)
vtkm_add_target_information(StreamlineMPI
DROP_UNUSED_SYMBOLS MODIFY_CUDA_FLAGS
DEVICE_SOURCES StreamlineMPI.cxx)
target_link_libraries(StreamlineMPI PRIVATE vtkm_filter_flow vtkm_io MPI::MPI_CXX)
endif()
#if(TARGET vtkm::tbb)
# target_compile_definitions(streamline_mpi PRIVATE BUILDING_TBB_VERSION)
#endif()

@ -8,9 +8,7 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/Particle.h>
#include <vtkm/cont/AssignerPartitionedDataSet.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/EnvironmentTracker.h>

@ -12,11 +12,12 @@
#include <string>
#include <vector>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/Particle.h>
//#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Timer.h>
//#include <vtkm/cont/Timer.h>
#include <vtkm/filter/flow/Pathline.h>

@ -11,6 +11,7 @@
#ifndef vtk_m_cont_ParticleArrayCopy_hxx
#define vtk_m_cont_ParticleArrayCopy_hxx
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayHandleTransform.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/cont/ParticleArrayCopy.h>

@ -22,19 +22,23 @@ set(flow_headers
set(flow_sources
internal/Messenger.cxx
NewFilterParticleAdvection.cxx
NewFilterParticleAdvectionSteadyState.cxx
NewFilterParticleAdvectionUnsteadyState.cxx
ParticleAdvection.cxx
Pathline.cxx
PathParticle.cxx
Streamline.cxx
)
set(flow_device_sources
NewFilterParticleAdvectionSteadyState.cxx
NewFilterParticleAdvectionUnsteadyState.cxx
StreamSurface.cxx
)
vtkm_library(
NAME vtkm_filter_flow
HEADERS ${flow_headers}
DEVICE_SOURCES ${flow_sources}
SOURCES ${flow_sources}
DEVICE_SOURCES ${flow_device_sources}
USE_VTKM_JOB_POOL
)

@ -8,10 +8,10 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/filter/flow/NewFilterParticleAdvectionSteadyState.h>
#include <vtkm/filter/flow/internal/DataSetIntegratorSteadyState.h>
#include <vtkm/filter/flow/internal/BoundsMap.h>
#include <vtkm/filter/flow/internal/ParticleAdvector.h>
namespace vtkm
@ -21,16 +21,18 @@ namespace filter
namespace flow
{
namespace
{
VTKM_CONT std::vector<vtkm::filter::flow::internal::DataSetIntegratorSteadyState>
NewFilterParticleAdvectionSteadyState::CreateDataSetIntegrators(
const vtkm::cont::PartitionedDataSet& input,
const vtkm::filter::flow::internal::BoundsMap& boundsMap,
const vtkm::filter::flow::FlowResultType& resultType) const
CreateDataSetIntegrators(const vtkm::cont::PartitionedDataSet& input,
const std::string& activeField,
const vtkm::filter::flow::internal::BoundsMap& boundsMap,
const vtkm::filter::flow::IntegrationSolverType solverType,
const vtkm::filter::flow::VectorFieldType vecFieldType,
const vtkm::filter::flow::FlowResultType resultType)
{
using DSIType = vtkm::filter::flow::internal::DataSetIntegratorSteadyState;
std::string activeField = this->GetActiveFieldName();
std::vector<DSIType> dsi;
for (vtkm::Id i = 0; i < input.GetNumberOfPartitions(); i++)
{
@ -39,11 +41,12 @@ NewFilterParticleAdvectionSteadyState::CreateDataSetIntegrators(
if (!ds.HasPointField(activeField) && !ds.HasCellField(activeField))
throw vtkm::cont::ErrorFilterExecution("Unsupported field assocation");
dsi.emplace_back(ds, blockId, activeField, this->SolverType, this->VecFieldType, resultType);
dsi.emplace_back(ds, blockId, activeField, solverType, vecFieldType, resultType);
}
return dsi;
}
} //anonymous namespace
VTKM_CONT vtkm::cont::PartitionedDataSet NewFilterParticleAdvectionSteadyState::DoExecutePartitions(
const vtkm::cont::PartitionedDataSet& input)
@ -52,7 +55,12 @@ VTKM_CONT vtkm::cont::PartitionedDataSet NewFilterParticleAdvectionSteadyState::
this->ValidateOptions();
vtkm::filter::flow::internal::BoundsMap boundsMap(input);
auto dsi = this->CreateDataSetIntegrators(input, boundsMap, this->GetResultType());
auto dsi = CreateDataSetIntegrators(input,
this->GetActiveFieldName(),
boundsMap,
this->SolverType,
this->VecFieldType,
this->GetResultType());
vtkm::filter::flow::internal::ParticleAdvector<DSIType> pav(
boundsMap, dsi, this->UseThreadedAlgorithm, this->GetResultType());

@ -13,9 +13,6 @@
#include <vtkm/filter/flow/FlowTypes.h>
#include <vtkm/filter/flow/NewFilterParticleAdvection.h>
#include <vtkm/filter/flow/internal/BoundsMap.h>
#include <vtkm/filter/flow/internal/DataSetIntegratorSteadyState.h>
#include <vtkm/filter/flow/vtkm_filter_flow_export.h>
namespace vtkm
@ -24,19 +21,9 @@ namespace filter
{
namespace flow
{
// Forward declaration
class DataSetIntegratorSteadyState;
class VTKM_FILTER_FLOW_EXPORT NewFilterParticleAdvectionSteadyState
: public NewFilterParticleAdvection
{
protected:
VTKM_CONT std::vector<vtkm::filter::flow::internal::DataSetIntegratorSteadyState>
CreateDataSetIntegrators(const vtkm::cont::PartitionedDataSet& input,
const vtkm::filter::flow::internal::BoundsMap& boundsMap,
const vtkm::filter::flow::FlowResultType& resultType) const;
private:
VTKM_CONT vtkm::cont::PartitionedDataSet DoExecutePartitions(
const vtkm::cont::PartitionedDataSet& inData) override;

@ -8,8 +8,6 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/filter/flow/NewFilterParticleAdvectionUnsteadyState.h>
#include <vtkm/filter/flow/internal/DataSetIntegratorUnsteadyState.h>
#include <vtkm/filter/flow/internal/ParticleAdvector.h>
@ -20,40 +18,45 @@ namespace filter
{
namespace flow
{
namespace
{
VTKM_CONT std::vector<vtkm::filter::flow::internal::DataSetIntegratorUnsteadyState>
NewFilterParticleAdvectionUnsteadyState::CreateDataSetIntegrators(
const vtkm::cont::PartitionedDataSet& input,
const vtkm::filter::flow::internal::BoundsMap& boundsMap,
const vtkm::filter::flow::FlowResultType& resultType) const
CreateDataSetIntegrators(const vtkm::cont::PartitionedDataSet& input,
const vtkm::cont::PartitionedDataSet& input2,
const std::string& activeField,
const vtkm::FloatDefault timer1,
const vtkm::FloatDefault timer2,
const vtkm::filter::flow::internal::BoundsMap& boundsMap,
const vtkm::filter::flow::IntegrationSolverType solverType,
const vtkm::filter::flow::VectorFieldType vecFieldType,
const vtkm::filter::flow::FlowResultType resultType)
{
using DSIType = vtkm::filter::flow::internal::DataSetIntegratorUnsteadyState;
std::string activeField = this->GetActiveFieldName();
std::vector<DSIType> dsi;
for (vtkm::Id i = 0; i < input.GetNumberOfPartitions(); i++)
{
vtkm::Id blockId = boundsMap.GetLocalBlockId(i);
auto ds1 = input.GetPartition(i);
auto ds2 = this->Input2.GetPartition(i);
auto ds2 = input2.GetPartition(i);
if ((!ds1.HasPointField(activeField) && !ds1.HasCellField(activeField)) ||
(!ds2.HasPointField(activeField) && !ds2.HasCellField(activeField)))
throw vtkm::cont::ErrorFilterExecution("Unsupported field assocation");
dsi.emplace_back(ds1,
ds2,
this->Time1,
this->Time2,
blockId,
activeField,
this->SolverType,
this->VecFieldType,
resultType);
dsi.emplace_back(
ds1, ds2, timer1, timer2, blockId, activeField, solverType, vecFieldType, resultType);
}
return dsi;
}
} // anonymous namespace
VTKM_CONT void NewFilterParticleAdvectionUnsteadyState::ValidateOptions() const
{
this->NewFilterParticleAdvection::ValidateOptions();
if (this->Time1 >= this->Time2)
throw vtkm::cont::ErrorFilterExecution("PreviousTime must be less than NextTime");
}
VTKM_CONT vtkm::cont::PartitionedDataSet
NewFilterParticleAdvectionUnsteadyState::DoExecutePartitions(
@ -63,7 +66,15 @@ NewFilterParticleAdvectionUnsteadyState::DoExecutePartitions(
this->ValidateOptions();
vtkm::filter::flow::internal::BoundsMap boundsMap(input);
auto dsi = this->CreateDataSetIntegrators(input, boundsMap, this->GetResultType());
auto dsi = CreateDataSetIntegrators(input,
this->Input2,
this->GetActiveFieldName(),
this->Time1,
this->Time2,
boundsMap,
this->SolverType,
this->VecFieldType,
this->GetResultType());
vtkm::filter::flow::internal::ParticleAdvector<DSIType> pav(
boundsMap, dsi, this->UseThreadedAlgorithm, this->GetResultType());

@ -12,9 +12,6 @@
#define vtk_m_filter_flow_NewFilterParticleAdvectionUnsteadyState_h
#include <vtkm/filter/flow/NewFilterParticleAdvection.h>
#include <vtkm/filter/flow/internal/BoundsMap.h>
#include <vtkm/filter/flow/internal/DataSetIntegratorUnsteadyState.h>
#include <vtkm/filter/flow/vtkm_filter_flow_export.h>
namespace vtkm
@ -24,9 +21,6 @@ namespace filter
namespace flow
{
// Forward declaration
class DataSetIntegratorUnsteadyState;
class VTKM_FILTER_FLOW_EXPORT NewFilterParticleAdvectionUnsteadyState
: public NewFilterParticleAdvection
{
@ -40,17 +34,7 @@ public:
VTKM_CONT void SetNextDataSet(const vtkm::cont::PartitionedDataSet& pds) { this->Input2 = pds; }
protected:
VTKM_CONT virtual void ValidateOptions() const override
{
this->NewFilterParticleAdvection::ValidateOptions();
if (this->Time1 >= this->Time2)
throw vtkm::cont::ErrorFilterExecution("PreviousTime must be less than NextTime");
}
VTKM_CONT std::vector<vtkm::filter::flow::internal::DataSetIntegratorUnsteadyState>
CreateDataSetIntegrators(const vtkm::cont::PartitionedDataSet& input,
const vtkm::filter::flow::internal::BoundsMap& boundsMap,
const vtkm::filter::flow::FlowResultType& resultType) const;
VTKM_CONT virtual void ValidateOptions() const override;
private:
VTKM_CONT vtkm::cont::PartitionedDataSet DoExecutePartitions(

@ -8,8 +8,6 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/filter/flow/PathParticle.h>
namespace vtkm

@ -8,8 +8,6 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/filter/flow/Pathline.h>
namespace vtkm

@ -8,14 +8,12 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/filter/flow/StreamSurface.h>
#include <vtkm/filter/flow/worklet/Field.h>
#include <vtkm/filter/flow/worklet/GridEvaluators.h>
#include <vtkm/filter/flow/worklet/ParticleAdvection.h>
#include <vtkm/filter/flow/worklet/Particles.h>
#include <vtkm/filter/flow/worklet/RK4Integrator.h>
#include <vtkm/filter/flow/worklet/Stepper.h>
#include <vtkm/filter/flow/worklet/StreamSurface.h>

@ -11,7 +11,6 @@
#ifndef vtk_m_filter_flow_StreamSurface_h
#define vtk_m_filter_flow_StreamSurface_h
#include <vtkm/Particle.h>
#include <vtkm/filter/flow/FlowTypes.h>
#include <vtkm/filter/flow/NewFilterParticleAdvectionSteadyState.h>
#include <vtkm/filter/flow/vtkm_filter_flow_export.h>

@ -11,6 +11,7 @@
#ifndef vtk_m_filter_flow_internal_DataSetIntegratorSteadyState_h
#define vtk_m_filter_flow_internal_DataSetIntegratorSteadyState_h
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/filter/flow/internal/DataSetIntegrator.h>
namespace vtkm

@ -11,6 +11,7 @@
#ifndef vtk_m_filter_flow_internal_DataSetIntegratorUnsteadyState_h
#define vtk_m_filter_flow_internal_DataSetIntegratorUnsteadyState_h
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/filter/flow/internal/DataSetIntegrator.h>
#include <vtkm/filter/flow/worklet/TemporalGridEvaluators.h>

@ -8,21 +8,34 @@
## PURPOSE. See the above copyright notice for more information.
##============================================================================
set(unit_tests
set(filter_unit_tests
UnitTestStreamlineFilter.cxx
UnitTestStreamSurfaceFilter.cxx
)
set(worklet_unit_tests
UnitTestWorkletParticleAdvection.cxx
UnitTestWorkletTemporalAdvection.cxx
UnitTestStreamSurfaceWorklet.cxx
)
set(libraries
vtkm_filter_mesh_info
vtkm_filter_flow
vtkm_io
)
if (VTKm_ENABLE_RENDERING)
list(APPEND libraries vtkm_filter_geometry_refinement vtkm_rendering vtkm_rendering_testing)
list(APPEND filter_unit_tests
RenderTestStreamline.cxx
)
endif()
vtkm_unit_tests(
DEVICE_SOURCES ${unit_tests}
LIBRARIES ${libraries} vtkm_filter vtkm_io
SOURCES ${filter_unit_tests}
DEVICE_SOURCES ${worklet_unit_tests}
LIBRARIES ${libraries}
USE_VTKM_JOB_POOL
)
@ -35,7 +48,7 @@ if (VTKm_ENABLE_MPI)
)
vtkm_unit_tests(
MPI DEVICE_SOURCES ${mpi_unit_tests}
LIBRARIES vtkm_filter vtkm_source vtkm_io
LIBRARIES ${libraries}
ALL_BACKENDS
USE_VTKM_JOB_POOL
)

@ -0,0 +1,74 @@
//============================================================================
// 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.
//============================================================================
#include <vtkm/Math.h>
#include <vtkm/Particle.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/io/VTKDataSetReader.h>
#include <vtkm/filter/flow/Streamline.h>
#include <vtkm/filter/geometry_refinement/Tube.h>
#include <vtkm/rendering/testing/RenderTest.h>
#include <vtkm/rendering/testing/Testing.h>
namespace
{
void TestStreamline()
{
std::cout << "Generate Image for Streamline filter" << std::endl;
auto pathname = vtkm::cont::testing::Testing::DataPath("uniform/StreamlineTestDataSet.vtk");
vtkm::io::VTKDataSetReader reader(pathname);
vtkm::cont::DataSet dataSet = reader.ReadDataSet();
vtkm::cont::ArrayHandle<vtkm::Particle> seedArray =
vtkm::cont::make_ArrayHandle({ vtkm::Particle(vtkm::Vec3f(.2f, 1.0f, .2f), 0),
vtkm::Particle(vtkm::Vec3f(.2f, 2.0f, .2f), 1),
vtkm::Particle(vtkm::Vec3f(.2f, 3.0f, .2f), 2) });
vtkm::filter::flow::Streamline streamline;
streamline.SetStepSize(0.1f);
streamline.SetNumberOfSteps(20);
streamline.SetSeeds(seedArray);
streamline.SetActiveField("vector");
auto result = streamline.Execute(dataSet);
// Some sort of color map is needed when rendering the coordinates of a dataset
// so create a zeroed array for the coordinates.
std::vector<vtkm::FloatDefault> colorMap(static_cast<std::vector<vtkm::FloatDefault>::size_type>(
result.GetCoordinateSystem().GetNumberOfPoints()));
for (std::vector<vtkm::FloatDefault>::size_type i = 0; i < colorMap.size(); i++)
{
colorMap[i] = static_cast<vtkm::FloatDefault>(i);
}
result.AddPointField("pointvar", colorMap);
// The streamline by itself doesn't generate renderable geometry, so surround the
// streamlines in tubes.
vtkm::filter::geometry_refinement::Tube tube;
tube.SetCapping(true);
tube.SetNumberOfSides(3);
tube.SetRadius(static_cast<vtkm::FloatDefault>(0.2));
result = tube.Execute(result);
result.PrintSummary(std::cout);
vtkm::rendering::testing::RenderTestOptions testOptions;
testOptions.ColorTable = vtkm::cont::ColorTable::Preset::Inferno;
testOptions.EnableAnnotations = false;
vtkm::rendering::testing::RenderTest(result, "pointvar", "filter/streamline.png", testOptions);
}
} // namespace
int RenderTestStreamline(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(TestStreamline, argc, argv);
}

@ -8,8 +8,7 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/Particle.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/flow/StreamSurface.h>

@ -9,7 +9,7 @@
//============================================================================
#include <vtkm/CellClassification.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/Particle.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/testing/Testing.h>
@ -18,7 +18,6 @@
#include <vtkm/filter/flow/Pathline.h>
#include <vtkm/filter/flow/Streamline.h>
#include <vtkm/io/VTKDataSetReader.h>
#include <vtkm/io/VTKDataSetWriter.h>
#include <vtkm/worklet/testing/GenerateTestDataSets.h>
namespace

@ -9,8 +9,7 @@
//============================================================================
#include <vtkm/CellClassification.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/Particle.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/flow/ParticleAdvection.h>
#include <vtkm/filter/flow/Pathline.h>

@ -11,6 +11,7 @@
#ifndef vtk_m_filter_flow_worklet_ParticleAdvectionWorklets_h
#define vtk_m_filter_flow_worklet_ParticleAdvectionWorklets_h
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/ConvertNumComponentsToOffsets.h>
#include <vtkm/cont/ExecutionObjectBase.h>

@ -25,14 +25,6 @@ set(libraries
vtkm_source
)
if (VTKm_ENABLE_RENDERING)
list(APPEND libraries vtkm_rendering vtkm_rendering_testing)
list(APPEND unit_tests
RenderTestStreamline.cxx
)
endif()
vtkm_unit_tests(
DEVICE_SOURCES ${unit_tests}
LIBRARIES ${libraries}