Commit 7ef956a9 authored by Li-Ta Lo's avatar Li-Ta Lo
Browse files

Merge branch 'master' into connected_component

parents a9ed1ecf 3de1717b
......@@ -14,4 +14,4 @@ data/* filter=lfs diff=lfs merge=lfs -text
*.rst whitespace=tab-in-indent conflict-marker-size=79
*.txt whitespace=tab-in-indent
diy/** -format.clang-format -whitespace
vtkm/thirdparty/diy/vtkmdiy/** -format.clang-format -whitespace
......@@ -39,9 +39,7 @@ set(FILES_TO_CHECK
set(EXCEPTIONS
LICENSE.txt
README.txt
diy/include/diy
diy/LEGAL.txt
diy/LICENSE.txt
vtkm/thirdparty/diy/vtkmdiy
)
if (NOT VTKm_SOURCE_DIR)
......
......@@ -39,11 +39,21 @@ set(FILES_TO_CHECK
set(EXCEPTIONS
)
set(DIRECTORY_EXCEPTIONS
${VTKm_SOURCE_DIR}/vtkm/thirdparty/diy/vtkmdiy
)
if (NOT VTKm_SOURCE_DIR)
message(SEND_ERROR "VTKm_SOURCE_DIR not defined.")
endif (NOT VTKm_SOURCE_DIR)
function(check_directory directory parent_CMakeLists_contents)
foreach(exception IN LISTS DIRECTORY_EXCEPTIONS)
if(directory MATCHES "^${exception}$")
return()
endif()
endforeach(exception)
message("Checking directory ${directory}...")
get_filename_component(directory_name "${directory}" NAME)
......
......@@ -221,11 +221,6 @@ find_package(Pyexpander)
#-----------------------------------------------------------------------------
# Add subdirectories
if(VTKm_ENABLE_MPI)
# This `if` is temporary and will be removed once `diy` supports building
# without MPI.
add_subdirectory(diy)
endif()
add_subdirectory(vtkm)
#-----------------------------------------------------------------------------
......
......@@ -104,14 +104,11 @@ int main(int argc, char* argv[])
output.AddCellSet(outputCellSet);
auto inCoords = input.GetCoordinateSystem(0).GetData();
timer.Reset();
vtkm::cont::DynamicArrayHandle coords;
{
FieldMapper<DeviceAdapter> coordMapper(coords, clip, false);
input.GetCoordinateSystem(0).GetData().CastAndCall(coordMapper);
}
auto outCoords = clip.ProcessCellField(inCoords, DeviceAdapter());
vtkm::Float64 processCoordinatesTime = timer.GetElapsedTime();
output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coords));
output.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", outCoords));
timer.Reset();
for (vtkm::Id i = 0; i < input.GetNumberOfFields(); ++i)
......
......@@ -23,6 +23,7 @@
#endif
#include <vtkm/Math.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/worklet/DispatcherMapField.h>
......@@ -68,30 +69,6 @@ Quaternion qrot;
int lastx, lasty;
int mouse_state = 1;
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
//
// Initialize the OpenGL state
//
......@@ -145,16 +122,10 @@ void displayCall()
// Get the cell set, coordinate system and coordinate data
vtkm::cont::CellSetExplicit<> cellSet;
outDataSet.GetCellSet(0).CopyTo(cellSet);
const vtkm::cont::DynamicArrayHandleCoordinateSystem& coordArray =
outDataSet.GetCoordinateSystem().GetData();
auto coordArray = outDataSet.GetCoordinateSystem().GetData();
vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
vtkm::Id numberOfPoints = coordArray.GetNumberOfValues();
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(numberOfPoints);
vtkm::cont::CastAndCall(coordArray, GetVertexArray());
vtkm::cont::ArrayCopy(coordArray, vertexArray);
// Each cell is a polyline
glColor3f(1.0f, 0.0f, 0.0f);
......
......@@ -52,9 +52,6 @@ namespace
// Takes input uniform grid and outputs unstructured grid of tets
static vtkm::cont::DataSet outDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>> vertexArray;
// OpenGL display variables
Quaternion qrot;
int lastx, lasty;
......@@ -123,30 +120,6 @@ vtkm::cont::DataSet MakeTetrahedralizeExplicitDataSet()
return builder.Create();
}
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
//
// Initialize the OpenGL state
//
......@@ -201,10 +174,7 @@ void displayCall()
outDataSet.GetCellSet(0).CopyTo(cellSet);
vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(cellSet.GetNumberOfPoints());
vtkm::cont::CastAndCall(outDataSet.GetCoordinateSystem(), GetVertexArray());
auto vertexArray = outDataSet.GetCoordinateSystem().GetData();
// Draw the five tetrahedra belonging to each hexadron
vtkm::Float32 color[5][3] = { { 1.0f, 0.0f, 0.0f },
......@@ -223,10 +193,10 @@ void displayCall()
cellSet.GetIndices(tetra, tetIndices);
// Get the vertex points for this tetrahedron
vtkm::Vec<vtkm::Float64, 3> pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]);
vtkm::Vec<vtkm::Float64, 3> pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]);
vtkm::Vec<vtkm::Float64, 3> pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]);
vtkm::Vec<vtkm::Float64, 3> pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]);
auto pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]);
auto pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]);
auto pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]);
auto pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]);
// Draw the tetrahedron filled with alternating colors
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
......@@ -323,7 +293,6 @@ int main(int argc, char* argv[])
glutMainLoop();
outDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}
......
......@@ -52,9 +52,6 @@ static vtkm::Id cellsToDisplay = 64;
// Takes input uniform grid and outputs unstructured grid of tets
static vtkm::cont::DataSet tetDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>> vertexArray;
// OpenGL display variables
static Quaternion qrot;
static int lastx, lasty;
......@@ -87,30 +84,6 @@ vtkm::cont::DataSet MakeTetrahedralizeTestDataSet(vtkm::Id3 dim)
return dataSet;
}
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
//
// Initialize the OpenGL state
//
......@@ -165,10 +138,7 @@ void displayCall()
vtkm::cont::CellSetSingleType<> cellSet;
tetDataSet.GetCellSet(0).CopyTo(cellSet);
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(cellSet.GetNumberOfPoints());
vtkm::cont::CastAndCall(tetDataSet.GetCoordinateSystem(), GetVertexArray());
auto vertexArray = tetDataSet.GetCoordinateSystem().GetData();
// Draw the five tetrahedra belonging to each hexadron
vtkm::Id tetra = 0;
......@@ -190,10 +160,10 @@ void displayCall()
cellSet.GetIndices(tetra, tetIndices);
// Get the vertex points for this tetrahedron
vtkm::Vec<vtkm::Float64, 3> pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]);
vtkm::Vec<vtkm::Float64, 3> pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]);
vtkm::Vec<vtkm::Float64, 3> pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]);
vtkm::Vec<vtkm::Float64, 3> pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]);
auto pt0 = vertexArray.GetPortalConstControl().Get(tetIndices[0]);
auto pt1 = vertexArray.GetPortalConstControl().Get(tetIndices[1]);
auto pt2 = vertexArray.GetPortalConstControl().Get(tetIndices[2]);
auto pt3 = vertexArray.GetPortalConstControl().Get(tetIndices[3]);
// Draw the tetrahedron filled with alternating colors
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
......@@ -305,7 +275,6 @@ int main(int argc, char* argv[])
glutMainLoop();
tetDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}
......
......@@ -50,9 +50,6 @@ namespace
static vtkm::cont::DataSet outDataSet;
static vtkm::Id numberOfInPoints;
// Point location of vertices from a CastAndCall but needs a static cast eventually
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>> vertexArray;
} // anonymous namespace
//
......@@ -125,30 +122,6 @@ vtkm::cont::DataSet MakeTriangulateExplicitDataSet()
return builder.Create();
}
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
//
// Initialize the OpenGL state
//
......@@ -173,10 +146,7 @@ void displayCall()
outDataSet.GetCellSet(0).CopyTo(cellSet);
vtkm::Id numberOfCells = cellSet.GetNumberOfCells();
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(numberOfInPoints);
vtkm::cont::CastAndCall(outDataSet.GetCoordinateSystem(), GetVertexArray());
auto vertexArray = outDataSet.GetCoordinateSystem().GetData();
// Draw the two triangles belonging to each quad
vtkm::Float32 color[4][3] = {
......@@ -239,7 +209,6 @@ int main(int argc, char* argv[])
glutMainLoop();
outDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}
......
......@@ -50,9 +50,6 @@ static vtkm::Id cellsToDisplay = 16;
// Takes input uniform grid and outputs unstructured grid of triangles
static vtkm::cont::DataSet triDataSet;
// Point location of vertices from a CastAndCall but needs a static cast eventually
static vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float64, 3>> vertexArray;
//
// Construct an input data set with uniform grid of indicated dimensions, origin and spacing
//
......@@ -78,30 +75,6 @@ vtkm::cont::DataSet MakeTriangulateTestDataSet(vtkm::Id2 dim)
return dataSet;
}
//
// Functor to retrieve vertex locations from the CoordinateSystem
// Actually need a static cast to ArrayHandle from DynamicArrayHandleCoordinateSystem
// but haven't been able to figure out what that is
//
struct GetVertexArray
{
template <typename ArrayHandleType>
VTKM_CONT void operator()(ArrayHandleType array) const
{
this->GetVertexPortal(array.GetPortalConstControl());
}
private:
template <typename PortalType>
VTKM_CONT void GetVertexPortal(const PortalType& portal) const
{
for (vtkm::Id index = 0; index < portal.GetNumberOfValues(); index++)
{
vertexArray.GetPortalControl().Set(index, portal.Get(index));
}
}
};
//
// Initialize the OpenGL state
//
......@@ -125,10 +98,7 @@ void displayCall()
vtkm::cont::CellSetSingleType<> cellSet;
triDataSet.GetCellSet(0).CopyTo(cellSet);
// Need the actual vertex points from a static cast of the dynamic array but can't get it right
// So use cast and call on a functor that stores that dynamic array into static array we created
vertexArray.Allocate(cellSet.GetNumberOfPoints());
vtkm::cont::CastAndCall(triDataSet.GetCoordinateSystem(), GetVertexArray());
auto vertexArray = triDataSet.GetCoordinateSystem().GetData();
// Draw the two triangles belonging to each quad
vtkm::Id triangle = 0;
......@@ -207,7 +177,6 @@ int main(int argc, char* argv[])
glutMainLoop();
triDataSet.Clear();
vertexArray.ReleaseResources();
return 0;
}
......
......@@ -67,6 +67,11 @@ vtkm_declare_headers(${headers})
#-----------------------------------------------------------------------------
#first add all the components vtkm that are shared between control and exec
if(VTKm_ENABLE_MPI)
# This `if` is temporary and will be removed once `diy` supports building
# without MPI.
add_subdirectory(thirdparty/diy)
endif()
add_subdirectory(testing)
add_subdirectory(internal)
......
This diff is collapsed.
......@@ -108,28 +108,30 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
}}
'''.format(vtkmname)
def unary_math_function_no_vec(vtkmname, sysname, returntype = None):
return unary_function(vtkmname,
'T',
'typename detail::FloatingPointReturnType<T>::Type' if returntype == None else returntype,
'VTKM_CUDA_MATH_FUNCTION_64(' + sysname + ')(static_cast<vtkm::Float64>(x))',
'std::' + sysname + '(static_cast<vtkm::Float64>(x))',
'template <typename T>',
'static inline') + \
unary_function(vtkmname,
'vtkm::Float32',
'detail::FloatingPointReturnType<vtkm::Float32>::Type' if returntype == None else returntype,
'VTKM_CUDA_MATH_FUNCTION_32(' + sysname + ')(x)',
'std::' + sysname + '(x)',
'template <>',
'inline') + \
unary_function(vtkmname,
'vtkm::Float64',
'detail::FloatingPointReturnType<vtkm::Float64>::Type' if returntype == None else returntype,
'VTKM_CUDA_MATH_FUNCTION_64(' + sysname + ')(x)',
'std::' + sysname + '(x)',
'template <>',
'inline')
def unary_math_function_no_vec(vtkmname, sysname):
general_type = '''template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type {0}(const T& x)
{{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::{0}(static_cast<RT>(x));
}}
'''.format(vtkmname)
specialization_types = unary_function(vtkmname,
'vtkm::Float32',
'vtkm::Float32',
'VTKM_CUDA_MATH_FUNCTION_32(' + sysname + ')(x)',
'std::' + sysname + '(x)',
'',
'inline')
specialization_types += unary_function(vtkmname,
'vtkm::Float64',
'vtkm::Float64',
'VTKM_CUDA_MATH_FUNCTION_64(' + sysname + ')(x)',
'std::' + sysname + '(x)',
'',
'inline')
return specialization_types + general_type
def unary_math_function(vtkmname, sysname):
return unary_math_function_no_vec(vtkmname, sysname) + \
......@@ -195,6 +197,7 @@ $extend(unary_template_function_no_vec)\
$extend(binary_math_function)\
$extend(binary_template_function)\
\
// clang-format off
namespace vtkm
{
......@@ -235,25 +238,15 @@ static inline VTKM_EXEC_CONT vtkm::Float64 Pi_4()
namespace detail
{
template <typename T>
struct FloatingPointReturnCondition
: std::enable_if<
std::is_same<typename vtkm::VecTraits<T>::ComponentType, vtkm::Float32>::value ||
std::is_same<typename vtkm::VecTraits<T>::ComponentType, const vtkm::Float32>::value>
{
};
template <typename T, typename = void>
struct FloatingPointReturnType
{
using Type = vtkm::Float64;
};
template <typename T>
struct FloatingPointReturnType<T, typename FloatingPointReturnCondition<T>::type>
{
using Type = vtkm::Float32;
using ctype = typename vtkm::VecTraits<T>::ComponentType;
using representable_as_float_type = std::integral_constant<bool,
((sizeof(ctype) < sizeof(float)) || std::is_same<ctype, vtkm::Float32>::value)>;
using Type = typename std::conditional<representable_as_float_type::value,
vtkm::Float32,
vtkm::Float64>::type;
};
} // namespace detail
......@@ -928,7 +921,12 @@ static inline VTKM_EXEC_CONT vtkm::Float32 RemainderQuotient(vtkm::Float32 numer
QType& quotient)
{
int iQuotient;
vtkm::Float32 result = std::remquo(numerator, denominator, &iQuotient);
#ifdef VTKM_CUDA
const vtkm::Float64 result =
VTKM_CUDA_MATH_FUNCTION_32(remquo)(numerator, denominator, &iQuotient);
#else
const vtkm::Float32 result = std::remquo(numerator, denominator, &iQuotient);
#endif
quotient = iQuotient;
return result;
}
......@@ -938,7 +936,12 @@ static inline VTKM_EXEC_CONT vtkm::Float64 RemainderQuotient(vtkm::Float64 numer
QType& quotient)
{
int iQuotient;
vtkm::Float64 result = std::remquo(numerator, denominator, &iQuotient);
#ifdef VTKM_CUDA
const vtkm::Float64 result =
VTKM_CUDA_MATH_FUNCTION_64(remquo)(numerator, denominator, &iQuotient);
#else
const vtkm::Float64 result = std::remquo(numerator, denominator, &iQuotient);
#endif
quotient = iQuotient;
return result;
}
......@@ -1061,5 +1064,6 @@ static inline VTKM_EXEC_CONT vtkm::Vec<T, N> CopySign(const vtkm::Vec<T, N>& x,
}
} // namespace vtkm
// clang-format on
#endif //vtk_m_Math_h
......@@ -27,4 +27,20 @@
static_assert((condition), "Failed static assert: " #condition)
#define VTKM_STATIC_ASSERT_MSG(condition, message) static_assert((condition), message)
namespace vtkm
{
template <bool noError>
struct ReadTheSourceCodeHereForHelpOnThisError;
template <>
struct ReadTheSourceCodeHereForHelpOnThisError<true> : std::true_type
{
};
} // namespace vtkm
#define VTKM_READ_THE_SOURCE_CODE_FOR_HELP(noError) \
VTKM_STATIC_ASSERT(vtkm::ReadTheSourceCodeHereForHelpOnThisError<noError>::value)
#endif //vtk_m_StaticAssert_h
......@@ -516,22 +516,6 @@ public:
VTKM_EXEC_CONT
bool operator!=(const DerivedClass& other) const { return !(this->operator==(other)); }
VTKM_EXEC_CONT
ComponentType Dot(const VecBaseCommon<ComponentType, DerivedClass>& other) const
{
// Why the static_cast here and below? Because * on small integers (char,
// short) promotes the result to a 32-bit int. After helpfully promoting
// the width of the result, some compilers then warn you about casting it
// back to the type you were expecting in the first place. The static_cast
// suppresses this warning.
ComponentType result = static_cast<ComponentType>(this->Component(0) * other.Component(0));
for (vtkm::IdComponent i = 1; i < this->NumComponents(); ++i)
{
result = static_cast<ComponentType>(result + this->Component(i) * other.Component(i));
}
return result;
}
#if (!(defined(VTKM_CUDA) && (__CUDACC_VER_MAJOR__ < 8)))
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
#pragma GCC diagnostic push
......@@ -1241,46 +1225,85 @@ VTKM_EXEC_CONT static inline vtkm::VecCConst<T> make_VecC(const T* array, vtkm::
return vtkm::VecCConst<T>(array, size);
}
// A pre-declaration of vtkm::Pair so that classes templated on them can refer
// to it. The actual implementation is in vtkm/Pair.h.
template <typename U, typename V>