Commit a3515f39 authored by Dave Pugmire's avatar Dave Pugmire

Add UInt8 as a default type.

parent 702e2276
......@@ -211,7 +211,8 @@ struct VTKM_ALWAYS_EXPORT TypeListTagAll
/// integers, floating points, and 3 dimensional vectors of floating points.
///
struct VTKM_ALWAYS_EXPORT TypeListTagCommon
: vtkm::ListTagBase<vtkm::Int32,
: vtkm::ListTagBase<vtkm::UInt8,
vtkm::Int32,
vtkm::Int64,
vtkm::Float32,
vtkm::Float64,
......
......@@ -42,7 +42,7 @@ struct TestKernelInOut : public vtkm::exec::FunctorBase
{
using ValueType = typename PortalType::ValueType;
ValueType inValue = this->Portal.Get(index);
this->Portal.Set(index, inValue + inValue);
this->Portal.Set(index, static_cast<ValueType>(inValue + inValue));
}
};
......@@ -76,7 +76,7 @@ struct TryArrayInOutType
"Portal has wrong number of values.");
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
T expectedValue = TestValue(index, T()) + TestValue(index, T());
T expectedValue = static_cast<T>(TestValue(index, T()) + TestValue(index, T()));
T retrievedValue = portal.Get(index);
VTKM_TEST_ASSERT(test_equal(expectedValue, retrievedValue),
"Functor did not modify in place.");
......
......@@ -88,7 +88,7 @@ struct TestInOutKernel : public vtkm::exec::FunctorBase
this->RaiseError("In/Out whole array has wrong size.");
}
using ValueType = typename PortalType::ValueType;
this->Portal.Set(index, this->Portal.Get(index) + ValueType(OFFSET));
this->Portal.Set(index, static_cast<ValueType>(this->Portal.Get(index) + ValueType(OFFSET)));
}
};
......@@ -156,7 +156,7 @@ struct TryWholeArrayType
VTKM_TEST_ASSERT(array.GetNumberOfValues() == ARRAY_SIZE, "Array size wrong?");
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
T expectedValue = TestValue(index, T()) + T(OFFSET);
T expectedValue = static_cast<T>(TestValue(index, T()) + T(OFFSET));
T retrievedValue = array.GetPortalConstControl().Get(index);
VTKM_TEST_ASSERT(test_equal(expectedValue, retrievedValue),
"In/Out array not set correctly.");
......
......@@ -90,7 +90,7 @@ struct InPlacePermutationFunctor : vtkm::exec::FunctorBase
using T = typename PermutedPortalType::ValueType;
T value = this->PermutedPortal.Get(index);
value = value + T(1000);
value = static_cast<T>(value + T(1000));
this->PermutedPortal.Set(index, value);
}
......@@ -117,7 +117,7 @@ VTKM_CONT void CheckInPlaceResult(PortalType portal)
if (permutedIndex % 2 == 0)
{
// This index was part of the permuted array; has a value changed
T expectedValue = TestValue(permutedIndex, T()) + T(1000);
T expectedValue = static_cast<T>(TestValue(permutedIndex, T()) + T(1000));
T retrievedValue = portal.Get(permutedIndex);
VTKM_TEST_ASSERT(test_equal(expectedValue, retrievedValue), "Permuted set unexpected value.");
}
......
......@@ -65,10 +65,10 @@ private:
OutType sum = OutType(pointValues[0]);
for (vtkm::IdComponent pointIndex = 1; pointIndex < numPoints; ++pointIndex)
{
sum = sum + OutType(pointValues[pointIndex]);
sum = static_cast<OutType>(sum + OutType(pointValues[pointIndex]));
}
average = sum / OutType(static_cast<OutComponentType>(numPoints));
average = static_cast<OutType>(sum / OutType(static_cast<OutComponentType>(numPoints)));
}
template <typename PointValueVecType, typename OutType>
......
......@@ -827,7 +827,7 @@ public:
for (vtkm::IdComponent i = 1; i < numValues; i++)
{
MappedValueType value = toReduce[i];
sum = sum + value;
sum = static_cast<MappedValueType>(sum + value);
}
centroid = internal::Scale(sum, 1. / static_cast<vtkm::Float64>(numValues));
}
......
......@@ -72,10 +72,10 @@ private:
OutType sum = OutType(cellValues[0]);
for (vtkm::IdComponent cellIndex = 1; cellIndex < numCells; ++cellIndex)
{
sum = sum + OutType(cellValues[cellIndex]);
sum = static_cast<OutType>(sum + OutType(cellValues[cellIndex]));
}
average = sum / OutType(static_cast<OutComponentType>(numCells));
average = static_cast<OutType>(sum / OutType(static_cast<OutComponentType>(numCells)));
}
template <typename CellValueVecType, typename OutType>
......
......@@ -41,7 +41,7 @@ public:
{
this->RaiseError("Got wrong input value.");
}
out = in - T(100);
out = static_cast<T>(in - T(100));
if (!test_equal(inout, TestValue(workIndex, T()) + T(100)))
{
this->RaiseError("Got wrong in-out value.");
......@@ -49,7 +49,7 @@ public:
// We return the new value of inout. Since _3 is both an arg and return,
// this tests that the return value is set after updating the arg values.
return inout - T(100);
return static_cast<T>(inout - T(100));
}
template <typename T1, typename T2, typename T3>
......@@ -75,7 +75,7 @@ struct DoStaticTestWorklet
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
inputArray[index] = TestValue(index, T()) + T(100);
inputArray[index] = static_cast<T>(TestValue(index, T()) + T(100));
}
vtkm::cont::ArrayHandle<T> inputHandle = vtkm::cont::make_ArrayHandle(inputArray, ARRAY_SIZE);
......@@ -123,7 +123,7 @@ struct DoVariantTestWorklet
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
inputArray[index] = TestValue(index, T()) + T(100);
inputArray[index] = static_cast<T>(TestValue(index, T()) + T(100));
}
vtkm::cont::ArrayHandle<T> inputHandle = vtkm::cont::make_ArrayHandle(inputArray, ARRAY_SIZE);
......
......@@ -46,7 +46,7 @@ struct TestExecObjectWorklet
{
this->RaiseError("Got wrong input value.");
}
out = execIn.Get(index) - T(100);
out = static_cast<T>(execIn.Get(index) - T(100));
execOut.Set(index, out);
}
};
......@@ -68,7 +68,7 @@ struct DoTestWorklet
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
inputArray[index] = TestValue(index, T()) + T(100);
inputArray[index] = static_cast<T>(TestValue(index, T()) + T(100));
}
vtkm::cont::ArrayHandleIndex counting(ARRAY_SIZE);
......
......@@ -76,7 +76,7 @@ struct DoTestWholeArrayWorklet
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
{
inArray[index] = TestValue(index, T());
inOutArray[index] = TestValue(index, T()) + T(100);
inOutArray[index] = static_cast<T>(TestValue(index, T()) + T(100));
}
vtkm::cont::ArrayHandle<T> inHandle = vtkm::cont::make_ArrayHandle(inArray, ARRAY_SIZE);
......
......@@ -349,6 +349,20 @@ struct ZFPBlockEncoder<BlockSize, vtkm::Float64, PortalType>
}
};
template <vtkm::Int32 BlockSize, typename PortalType>
struct ZFPBlockEncoder<BlockSize, vtkm::UInt8, PortalType>
{
VTKM_EXEC void encode(vtkm::UInt8* fblock,
vtkm::Int32 maxbits,
vtkm::UInt32 blockIdx,
PortalType& stream)
{
using Int = typename zfp::zfp_traits<vtkm::UInt8>::Int;
zfp::BlockWriter<BlockSize, PortalType> blockWriter(stream, maxbits, vtkm::Id(blockIdx));
encode_block<BlockSize>(blockWriter, maxbits, get_precision<vtkm::Int32>(), (Int*)fblock);
}
};
template <vtkm::Int32 BlockSize, typename PortalType>
struct ZFPBlockEncoder<BlockSize, vtkm::Int32, PortalType>
{
......
......@@ -199,6 +199,13 @@ struct zfp_traits<int>
typedef int Int;
};
template <>
struct zfp_traits<unsigned char>
{
typedef unsigned char UInt;
typedef int Int;
};
template <typename T>
inline VTKM_EXEC bool is_int()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment