Remove testing headers from benchmarking

The code in `vtkm/cont/Testing.h` now requires a library, which is not
built if testing is not built. Thus, the benchmarking code was giving a
compile error if benchmarking was on but testing was off.

Change the benchmarking to not rely on anything in the Testing
framework. This means using classes in `vtkm/source` instead of
`MakeTestData`. Also avoid using the `TestValue` defined for the tests.
(In one case, we have a simple replacement.) Also had to fix a problem
with a header file not defining everything it needed to compile.
This commit is contained in:
Kenneth Moreland 2021-06-09 13:58:39 -06:00
parent 65ad7b3721
commit 9d5d9e38a1
11 changed files with 62 additions and 47 deletions

@ -10,6 +10,7 @@
#include "Benchmarker.h"
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/AtomicArray.h>
#include <vtkm/cont/DeviceAdapterTag.h>

@ -17,8 +17,6 @@
#include <vtkm/internal/Configure.h>
#include <vtkm/testing/Testing.h>
#include <vtkm/List.h>
#include <sstream>

@ -17,6 +17,7 @@
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/BitField.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Invoker.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/worklet/StableSortIndices.h>
@ -28,6 +29,8 @@
#include <string>
#include <utility>
#include <vtkmstd/integer_sequence.h>
#include <vtkm/internal/Windows.h>
#ifdef VTKM_ENABLE_TBB
@ -128,7 +131,37 @@ template <typename T>
struct TestValueFunctor
{
VTKM_EXEC_CONT
T operator()(vtkm::Id i) const { return TestValue(i, T{}); }
T operator()(vtkm::Id i) const { return static_cast<T>(i + 10); }
};
template <typename T>
VTKM_EXEC_CONT T TestValue(vtkm::Id index)
{
return TestValueFunctor<T>{}(index);
}
template <typename T, typename U>
struct TestValueFunctor<vtkm::Pair<T, U>>
{
VTKM_EXEC_CONT vtkm::Pair<T, U> operator()(vtkm::Id i) const
{
return vtkm::make_Pair(TestValue<T>(i), TestValue<U>(i + 1));
}
};
template <typename T, vtkm::IdComponent N>
struct TestValueFunctor<vtkm::Vec<T, N>>
{
template <std::size_t... Ns>
VTKM_EXEC_CONT vtkm::Vec<T, N> FillVec(vtkm::Id i, vtkmstd::index_sequence<Ns...>) const
{
return vtkm::make_Vec(TestValue<T>(i + static_cast<vtkm::Id>(Ns))...);
}
VTKM_EXEC_CONT vtkm::Vec<T, N> operator()(vtkm::Id i) const
{
return FillVec(i, vtkmstd::make_index_sequence<static_cast<std::size_t>(N)>{});
}
};
template <typename ArrayT>
@ -139,28 +172,12 @@ VTKM_CONT void FillTestValue(ArrayT& array, vtkm::Id numValues)
vtkm::cont::make_ArrayHandleImplicit(TestValueFunctor<T>{}, numValues), array);
}
template <typename T>
struct ScaledTestValueFunctor
{
vtkm::Id Scale;
VTKM_EXEC_CONT
T operator()(vtkm::Id i) const { return TestValue(i * this->Scale, T{}); }
};
template <typename ArrayT>
VTKM_CONT void FillScaledTestValue(ArrayT& array, vtkm::Id scale, vtkm::Id numValues)
{
using T = typename ArrayT::ValueType;
vtkm::cont::Algorithm::Copy(
vtkm::cont::make_ArrayHandleImplicit(ScaledTestValueFunctor<T>{ scale }, numValues), array);
}
template <typename T>
struct ModuloTestValueFunctor
{
vtkm::Id Mod;
VTKM_EXEC_CONT
T operator()(vtkm::Id i) const { return TestValue(i % this->Mod, T{}); }
T operator()(vtkm::Id i) const { return TestValue<T>(i % this->Mod); }
};
template <typename ArrayT>
@ -186,7 +203,7 @@ struct BinaryTestValueFunctor
T retVal;
do
{
retVal = TestValue(i++, T{});
retVal = TestValue<T>(i++);
} while (retVal == zero);
return retVal;
}
@ -213,7 +230,7 @@ VTKM_CONT void FillRandomTestValue(ArrayT& array, vtkm::Id numValues)
auto portal = array.WritePortal();
for (vtkm::Id i = 0; i < portal.GetNumberOfValues(); ++i)
{
portal.Set(i, TestValue(static_cast<vtkm::Id>(rng()), ValueType{}));
portal.Set(i, TestValue<ValueType>(static_cast<vtkm::Id>(rng())));
}
}
@ -228,7 +245,7 @@ VTKM_CONT void FillRandomModTestValue(ArrayT& array, vtkm::Id mod, vtkm::Id numV
auto portal = array.WritePortal();
for (vtkm::Id i = 0; i < portal.GetNumberOfValues(); ++i)
{
portal.Set(i, TestValue(static_cast<vtkm::Id>(rng()) % mod, ValueType{}));
portal.Set(i, TestValue<ValueType>(static_cast<vtkm::Id>(rng()) % mod));
}
}
@ -593,7 +610,7 @@ void BenchFillArrayHandle(benchmark::State& state)
{
(void)_;
timer.Start();
vtkm::cont::Algorithm::Fill(device, array, TestValue(19, ValueType{}), numValues);
vtkm::cont::Algorithm::Fill(device, array, TestValue<ValueType>(19), numValues);
timer.Stop();
state.SetIterationTime(timer.GetElapsedTime());

@ -27,7 +27,6 @@
#include <vtkm/worklet/WorkletMapTopology.h>
#include "Benchmarker.h"
#include <vtkm/cont/testing/Testing.h>
#include <cctype>
#include <random>

@ -25,7 +25,6 @@
#include <vtkm/cont/Logging.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/internal/OptionParser.h>

@ -16,7 +16,8 @@
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/source/Tangle.h>
#include <vtkm/rendering/Camera.h>
#include <vtkm/rendering/raytracing/Ray.h>
@ -40,9 +41,9 @@ void BenchRayTracing(::benchmark::State& state)
{
const vtkm::Id3 dims(128, 128, 128);
vtkm::cont::testing::MakeTestDataSet maker;
auto dataset = maker.Make3DUniformDataSet3(dims);
auto coords = dataset.GetCoordinateSystem();
vtkm::source::Tangle maker(dims);
vtkm::cont::DataSet dataset = maker.Execute();
vtkm::cont::CoordinateSystem coords = dataset.GetCoordinateSystem();
vtkm::rendering::Camera camera;
vtkm::Bounds bounds = dataset.GetCoordinateSystem().GetBounds();
@ -68,7 +69,7 @@ void BenchRayTracing(::benchmark::State& state)
rays.Buffers.at(0).InitConst(0.f);
vtkm::cont::Field field = dataset.GetField("pointvar");
vtkm::cont::Field field = dataset.GetField("nodevar");
vtkm::Range range = field.GetRange().ReadPortal().Get(0);
tracer.SetField(field, range);

@ -22,8 +22,6 @@
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/WorkletMapTopology.h>
#include <vtkm/cont/testing/Testing.h>
#include <cctype>
#include <random>
#include <string>

@ -11,11 +11,11 @@
#ifndef vtk_m_benchmarking_Benchmarker_h
#define vtk_m_benchmarking_Benchmarker_h
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/Logging.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/internal/brigand.hpp>
#include <benchmark/benchmark.h>
@ -308,7 +308,7 @@ private:
void operator()(brigand::type_<BenchType<P>>) const
{
std::ostringstream name;
name << this->BenchName << "<" << vtkm::testing::TypeName<P>::Name() << ">";
name << this->BenchName << "<" << vtkm::cont::TypeToString<P>() << ">";
auto bm = ::benchmark::internal::RegisterBenchmarkInternal(
new ::benchmark::internal::FunctionBenchmark(name.str().c_str(),
BenchType<P>::GetFunction()));

@ -60,5 +60,5 @@ target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_LOWER
target_compile_definitions(BenchmarkDeviceAdapter PUBLIC VTKm_BENCHS_RANGE_UPPER_BOUNDARY=${VTKm_BENCHS_RANGE_UPPER_BOUNDARY})
if(TARGET vtkm_rendering)
add_benchmark(NAME BenchmarkRayTracing FILE BenchmarkRayTracing.cxx LIBS vtkm_rendering)
add_benchmark(NAME BenchmarkRayTracing FILE BenchmarkRayTracing.cxx LIBS vtkm_rendering vtkm_source)
endif()

@ -13,7 +13,8 @@
#include <vtkm/exec/ConnectivityExtrude.h>
#include <vtkm/exec/arg/FetchTagArrayDirectIn.h>
#include <vtkm/exec/arg/FetchTagArrayTopologyMapIn.h>
#include <vtkm/exec/arg/IncidentElementIndices.h>
#include <vtkm/cont/ArrayHandleXGCCoordinates.h>
//optimized fetches for ArrayPortalXGCCoordinates for
// - 3D Scheduling
@ -25,6 +26,15 @@ namespace exec
namespace arg
{
/// \brief Aspect tag to use for getting the visited indices.
///
/// The \c AspectTagIncidentElementIndices aspect tag causes the \c Fetch class
/// to obtain the indices that map to the current topology element.
///
struct AspectTagIncidentElementIndices
{
};
//Optimized fetch for point ids when iterating the cells ConnectivityExtrude
template <typename FetchType, typename ExecObjectType>
struct Fetch<FetchType, vtkm::exec::arg::AspectTagIncidentElementIndices, ExecObjectType>

@ -12,6 +12,7 @@
#include <vtkm/exec/arg/ExecutionSignatureTagBase.h>
#include <vtkm/exec/arg/Fetch.h>
#include <vtkm/exec/arg/FetchExtrude.h>
namespace vtkm
{
@ -20,15 +21,6 @@ namespace exec
namespace arg
{
/// \brief Aspect tag to use for getting the visited indices.
///
/// The \c AspectTagIncidentElementIndices aspect tag causes the \c Fetch class
/// to obtain the indices that map to the current topology element.
///
struct AspectTagIncidentElementIndices
{
};
/// \brief The \c ExecutionSignature tag to get the indices of visited elements.
///
/// In a topology map, there are \em visited and \em incident topology elements