Compile transport on device

Now that it is easier to select which unit tests should be compiled by a
device compiler (and run on a device), allow the transport classes to be
tested on actual devices rather than just the serial device.
This commit is contained in:
Kenneth Moreland 2022-07-13 14:04:08 -06:00
parent b4e6370e9e
commit bedf4bc807
11 changed files with 66 additions and 31 deletions

@ -10,16 +10,19 @@
set(unit_tests
UnitTestControlSignatureTag.cxx
UnitTestTransportArrayIn.cxx
UnitTestTransportArrayInOut.cxx
UnitTestTransportArrayOut.cxx
UnitTestTransportCellSetIn.cxx
UnitTestTransportExecObject.cxx
UnitTestTransportWholeArray.cxx
UnitTestTypeCheckArray.cxx
UnitTestTypeCheckCellSet.cxx
UnitTestTypeCheckExecObject.cxx
UnitTestTypeCheckKeys.cxx
)
vtkm_unit_tests(SOURCES ${unit_tests} DEFINES VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG)
set(unit_tests_device
UnitTestTransportArrayIn.cxx
UnitTestTransportArrayInOut.cxx
UnitTestTransportArrayOut.cxx
UnitTestTransportCellSetIn.cxx
UnitTestTransportExecObject.cxx
UnitTestTransportWholeArray.cxx
)
vtkm_unit_tests(SOURCES ${unit_tests} DEVICE_SOURCES ${unit_tests_device})

@ -8,6 +8,9 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
// This test does not really need a device compiler
#define VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/cont/testing/Testing.h>

@ -13,7 +13,8 @@
#include <vtkm/exec/FunctorBase.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/cont/testing/Testing.h>
@ -68,15 +69,16 @@ struct TryArrayInType
};
template <typename Device>
void TryArrayInTransport(Device)
bool TryArrayInTransport(Device device)
{
std::cout << "Trying ArrayIn transport with " << device.GetName() << std::endl;
vtkm::testing::Testing::TryTypes(TryArrayInType<Device>());
return true;
}
void TestArrayInTransport()
{
std::cout << "Trying ArrayIn transport with serial device." << std::endl;
TryArrayInTransport(vtkm::cont::DeviceAdapterTagSerial());
VTKM_TEST_ASSERT(vtkm::cont::TryExecute([](auto device) { return TryArrayInTransport(device); }));
}
} // Anonymous namespace

@ -14,6 +14,7 @@
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/cont/testing/Testing.h>
@ -78,15 +79,17 @@ struct TryArrayInOutType
};
template <typename Device>
void TryArrayInOutTransport(Device)
bool TryArrayInOutTransport(Device device)
{
std::cout << "Trying ArrayInOut transport with " << device.GetName() << std::endl;
vtkm::testing::Testing::TryTypes(TryArrayInOutType<Device>(), vtkm::TypeListCommon());
return true;
}
void TestArrayInOutTransport()
{
std::cout << "Trying ArrayInOut transport with serial device." << std::endl;
TryArrayInOutTransport(vtkm::cont::DeviceAdapterTagSerial());
VTKM_TEST_ASSERT(
vtkm::cont::TryExecute([](auto device) { return TryArrayInOutTransport(device); }));
}
} // anonymous namespace

@ -14,7 +14,8 @@
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/cont/testing/Testing.h>
@ -67,15 +68,17 @@ struct TryArrayOutType
};
template <typename Device>
void TryArrayOutTransport(Device)
bool TryArrayOutTransport(Device device)
{
std::cout << "Trying ArrayOut transport with " << device.GetName() << std::endl;
vtkm::testing::Testing::TryTypes(TryArrayOutType<Device>());
return true;
}
void TestArrayOutTransport()
{
std::cout << "Trying ArrayOut transport with serial device." << std::endl;
TryArrayOutTransport(vtkm::cont::DeviceAdapterTagSerial());
VTKM_TEST_ASSERT(
vtkm::cont::TryExecute([](auto device) { return TryArrayOutTransport(device); }));
}
} // Anonymous namespace

@ -11,11 +11,11 @@
#include <vtkm/cont/arg/TransportTagCellSetIn.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/exec/FunctorBase.h>
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
@ -49,8 +49,10 @@ struct TestKernel : public vtkm::exec::FunctorBase
};
template <typename Device>
void TransportWholeCellSetIn(Device)
bool TransportWholeCellSetIn(Device device)
{
std::cout << "Trying CellSetIn transport with " << device.GetName() << std::endl;
//build a fake cell set
const int nVerts = 5;
vtkm::cont::CellSetExplicit<> contObject;
@ -78,12 +80,14 @@ void TransportWholeCellSetIn(Device)
kernel.CellSet = transport(contObject, nullptr, 1, 1, token);
vtkm::cont::DeviceAdapterAlgorithm<Device>::Schedule(kernel, 1);
return true;
}
void UnitTestCellSetIn()
{
std::cout << "Trying CellSetIn transport with serial device." << std::endl;
TransportWholeCellSetIn(vtkm::cont::DeviceAdapterTagSerial());
VTKM_TEST_ASSERT(
vtkm::cont::TryExecute([](auto device) { return TransportWholeCellSetIn(device); }));
}
} // Anonymous namespace

@ -12,15 +12,15 @@
#include <vtkm/exec/FunctorBase.h>
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/ExecutionObjectBase.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/cont/testing/Testing.h>
#define EXPECTED_NUMBER 42
namespace
namespace unittesttransportexecobject
{
struct NotAnExecutionObject
@ -65,8 +65,10 @@ struct TestKernel : public vtkm::exec::FunctorBase
};
template <typename Device>
void TryExecObjectTransport(Device)
bool TryExecObjectTransport(Device device)
{
std::cout << "Trying ExecObject transport with " << device.GetName() << std::endl;
TestExecutionObject contObject;
contObject.Number = EXPECTED_NUMBER;
@ -79,6 +81,8 @@ void TryExecObjectTransport(Device)
kernel.Object = transport(contObject, nullptr, 1, 1, token);
vtkm::cont::DeviceAdapterAlgorithm<Device>::Schedule(kernel, 1);
return true;
}
void TestExecObjectTransport()
@ -98,13 +102,14 @@ void TestExecObjectTransport()
VTKM_TEST_ASSERT(vtkm::cont::internal::HasPrepareForExecution<TestExecutionObject>::value,
"Bad query");
std::cout << "Trying ExecObject transport with serial device." << std::endl;
TryExecObjectTransport(vtkm::cont::DeviceAdapterTagSerial());
VTKM_TEST_ASSERT(
vtkm::cont::TryExecute([](auto device) { return TryExecObjectTransport(device); }));
}
} // Anonymous namespace
} // namespace unittesttransportexecobject
int UnitTestTransportExecObject(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(TestExecObjectTransport, argc, argv);
return vtkm::cont::testing::Testing::Run(
unittesttransportexecobject::TestExecObjectTransport, argc, argv);
}

@ -8,6 +8,9 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
// This test does not really need a device compiler
#define VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG
#include <vtkm/cont/arg/TypeCheckTagArrayIn.h>
#include <vtkm/cont/arg/TypeCheckTagArrayInOut.h>
#include <vtkm/cont/arg/TypeCheckTagArrayOut.h>

@ -8,6 +8,9 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
// This test does not really need a device compiler
#define VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG
#include <vtkm/cont/arg/TypeCheckTagCellSet.h>
#include <vtkm/cont/ArrayHandle.h>

@ -8,6 +8,9 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
// This test does not really need a device compiler
#define VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG
#include <vtkm/cont/arg/TypeCheckTagExecObject.h>
#include <vtkm/cont/ArrayHandle.h>

@ -8,6 +8,9 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
// This test does not really need a device compiler
#define VTKM_NO_ERROR_ON_MIXED_CUDA_CXX_TAG
#include <vtkm/cont/arg/TypeCheckTagKeys.h>
#include <vtkm/worklet/Keys.h>