Commit 5251091e authored by Haocheng LIU's avatar Haocheng LIU

Remove compile time adapter checks in UnitTestBoundingIntervalHierarchy

parent 169f5516
......@@ -214,7 +214,7 @@ public:
//set up stack size for cuda environment
#ifdef VTKM_CUDA
std::size_t stackSizeBackup;
std::size_t stackSizeBackup(0);
(void)stackSizeBackup;
if (id.GetValue() == VTKM_DEVICE_ADAPTER_CUDA)
{
......
......@@ -20,7 +20,7 @@
set(unit_tests
UnitTestAverageByKey.cxx
#UnitTestBoundingIntervalHierarchy.cxx
UnitTestBoundingIntervalHierarchy.cxx
UnitTestCellAverage.cxx
UnitTestCellDeepCopy.cxx
UnitTestCellGradient.cxx
......
......@@ -23,6 +23,7 @@
#include <vtkm/cont/BoundingIntervalHierarchy.hxx>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/internal/DeviceAdapterTag.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/io/reader/VTKDataSetReader.h>
......@@ -67,7 +68,9 @@ vtkm::cont::DataSet ConstructDataSet(vtkm::Id size)
return vtkm::cont::DataSetBuilderUniform().Create(vtkm::Id3(size, size, size));
}
void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet, vtkm::IdComponent numPlanes)
void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet,
vtkm::IdComponent numPlanes,
const vtkm::cont::DeviceAdapterId& id)
{
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
using Timer = vtkm::cont::Timer<DeviceAdapter>;
......@@ -93,21 +96,27 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet, vtkm::IdComponen
Timer interpolationTimer;
vtkm::cont::ArrayHandle<vtkm::IdComponent> results;
#if VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_CUDA
#ifdef VTKM_CUDA
//set up stack size for cuda envinroment
size_t stackSizeBackup;
cudaDeviceGetLimit(&stackSizeBackup, cudaLimitStackSize);
std::cout << "Default stack size " << stackSizeBackup << "\n";
cudaDeviceSetLimit(cudaLimitStackSize, 1024 * 50);
size_t stackSizeBackup(0);
(void)stackSizeBackup;
if (id.GetValue() == VTKM_DEVICE_ADAPTER_CUDA)
{
cudaDeviceGetLimit(&stackSizeBackup, cudaLimitStackSize);
cudaDeviceSetLimit(cudaLimitStackSize, 1024 * 50);
}
#else
(void)id;
#endif
vtkm::worklet::DispatcherMapField<BoundingIntervalHierarchyTester>().Invoke(
centroids, bih, expectedCellIds, results);
#if VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_CUDA
cudaDeviceSetLimit(cudaLimitStackSize, stackSizeBackup);
#ifdef VTKM_CUDA
if (id.GetValue() == VTKM_DEVICE_ADAPTER_CUDA)
{
cudaDeviceSetLimit(cudaLimitStackSize, stackSizeBackup);
}
#endif
vtkm::Id numDiffs = vtkm::cont::Algorithm::Reduce(results, 0, vtkm::Add());
vtkm::Float64 timeDiff = interpolationTimer.GetElapsedTime();
......@@ -119,17 +128,17 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet, vtkm::IdComponen
VTKM_TEST_ASSERT(numDiffs == 0, "Calculated cell Ids not the same as expected cell Ids");
}
void RunTest()
void RunTest(const vtkm::cont::DeviceAdapterId& id)
{
TestBoundingIntervalHierarchy(ConstructDataSet(16), 3);
TestBoundingIntervalHierarchy(ConstructDataSet(16), 4);
TestBoundingIntervalHierarchy(ConstructDataSet(16), 6);
TestBoundingIntervalHierarchy(ConstructDataSet(16), 9);
TestBoundingIntervalHierarchy(ConstructDataSet(16), 3, id);
TestBoundingIntervalHierarchy(ConstructDataSet(16), 4, id);
TestBoundingIntervalHierarchy(ConstructDataSet(16), 6, id);
TestBoundingIntervalHierarchy(ConstructDataSet(16), 9, id);
}
} // anonymous namespace
int UnitTestBoundingIntervalHierarchy(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(RunTest, argc, argv);
return vtkm::cont::testing::Testing::RunOnDevice(RunTest, argc, argv);
}
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