mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merge worklet testing executables into a device dependent shared library
VTK-m has been updated to replace old per device worklet testing executables with a device dependent shared library so that it's able to accept a device adapter at runtime. Meanwhile, it updates the testing infrastructure APIs. vtkm::cont::testing::Run function would call ForceDevice when needed and if users need the device adapter info at runtime, RunOnDevice function would pass the adapter into the functor. Optional Parser is bumped from 1.3 to 1.7.
This commit is contained in:
parent
88bcd06964
commit
8859636672
@ -346,6 +346,7 @@ endfunction(vtkm_library)
|
||||
# LIBRARIES <dependent_library_list>
|
||||
# TEST_ARGS <argument_list>
|
||||
# MPI
|
||||
# ALL_BACKENDS
|
||||
# <options>
|
||||
# )
|
||||
#
|
||||
@ -363,6 +364,8 @@ endfunction(vtkm_library)
|
||||
#
|
||||
# [MPI] : when specified, the tests should be run in parallel if
|
||||
# MPI is enabled.
|
||||
# [ALL_BACKENDS] : when specified, the tests would test against all enabled
|
||||
# backends. BACKEND argument would be ignored.
|
||||
#
|
||||
function(vtkm_unit_tests)
|
||||
if (NOT VTKm_ENABLE_TESTING)
|
||||
@ -370,7 +373,7 @@ function(vtkm_unit_tests)
|
||||
endif()
|
||||
|
||||
set(options)
|
||||
set(global_options ${options} MPI)
|
||||
set(global_options ${options} MPI ALL_BACKENDS)
|
||||
set(oneValueArgs BACKEND NAME)
|
||||
set(multiValueArgs SOURCES LIBRARIES TEST_ARGS)
|
||||
cmake_parse_arguments(VTKm_UT
|
||||
@ -379,17 +382,36 @@ function(vtkm_unit_tests)
|
||||
)
|
||||
vtkm_parse_test_options(VTKm_UT_SOURCES "${options}" ${VTKm_UT_SOURCES})
|
||||
|
||||
set(test_prog )
|
||||
set(test_prog)
|
||||
set(backend ${VTKm_UT_BACKEND})
|
||||
|
||||
set(enable_all_backends ${VTKm_UT_ALL_BACKENDS})
|
||||
set(all_backends SERIAL)
|
||||
if (VTKm_ENABLE_CUDA)
|
||||
list(APPEND all_backends CUDA)
|
||||
endif()
|
||||
if (VTKm_ENABLE_TBB)
|
||||
list(APPEND all_backends TBB)
|
||||
endif()
|
||||
if (VTKm_ENABLE_OPENMP)
|
||||
list(APPEND all_backends OPENMP)
|
||||
endif()
|
||||
|
||||
if(VTKm_UT_NAME)
|
||||
set(test_prog "${VTKm_UT_NAME}")
|
||||
else()
|
||||
vtkm_get_kit_name(kit)
|
||||
set(test_prog "UnitTests_${kit}")
|
||||
endif()
|
||||
if(backend)
|
||||
|
||||
if(enable_all_backends)
|
||||
string(REPLACE ";" "_" all_backends_name "${all_backends}")
|
||||
set(test_prog "${test_prog}_${all_backends_name}")
|
||||
elseif(backend)
|
||||
set(test_prog "${test_prog}_${backend}")
|
||||
set(all_backends ${backend})
|
||||
else()
|
||||
set (all_backends "NO_BACKEND")
|
||||
endif()
|
||||
|
||||
if(VTKm_UT_MPI)
|
||||
@ -404,7 +426,8 @@ function(vtkm_unit_tests)
|
||||
#the creation of the test source list needs to occur before the labeling as
|
||||
#cuda. This is so that we get the correctly named entry points generated
|
||||
create_test_sourcelist(test_sources ${test_prog}.cxx ${VTKm_UT_SOURCES} ${extraArgs})
|
||||
if(backend STREQUAL "CUDA")
|
||||
#if all backends are enabled, we can use cuda compiler to handle all possible backends.
|
||||
if(backend STREQUAL "CUDA" OR (enable_all_backends AND VTKm_ENABLE_CUDA))
|
||||
vtkm_compile_as_cuda(cu_srcs ${VTKm_UT_SOURCES})
|
||||
set(VTKm_UT_SOURCES ${cu_srcs})
|
||||
endif()
|
||||
@ -415,43 +438,48 @@ function(vtkm_unit_tests)
|
||||
set_property(TARGET ${test_prog} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH})
|
||||
|
||||
target_link_libraries(${test_prog} PRIVATE vtkm_cont ${VTKm_UT_LIBRARIES})
|
||||
if(backend)
|
||||
target_compile_definitions(${test_prog} PRIVATE "VTKM_DEVICE_ADAPTER=VTKM_DEVICE_ADAPTER_${backend}")
|
||||
endif()
|
||||
|
||||
#determine the timeout for all the tests based on the backend. CUDA tests
|
||||
#generally require more time because of kernel generation.
|
||||
set(timeout 180)
|
||||
set(run_serial False)
|
||||
if(backend STREQUAL "CUDA")
|
||||
set(timeout 1500)
|
||||
elseif(backend STREQUAL "OPENMP")
|
||||
#We need to have all OpenMP tests run serially as they
|
||||
#will uses all the system cores, and we will cause a N*N thread
|
||||
#explosion which causes the tests to run slower than when run
|
||||
#serially
|
||||
set(run_serial True)
|
||||
endif()
|
||||
|
||||
|
||||
foreach (test ${VTKm_UT_SOURCES})
|
||||
get_filename_component(tname ${test} NAME_WE)
|
||||
if(VTKm_UT_MPI AND VTKm_ENABLE_MPI)
|
||||
add_test(NAME ${tname}${backend}
|
||||
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 3 ${MPIEXEC_PREFLAGS}
|
||||
$<TARGET_FILE:${test_prog}> ${tname} ${VTKm_UT_TEST_ARGS}
|
||||
${MPIEXEC_POSTFLAGS}
|
||||
)
|
||||
else()
|
||||
add_test(NAME ${tname}${backend}
|
||||
COMMAND ${test_prog} ${tname} ${VTKm_UT_TEST_ARGS}
|
||||
)
|
||||
foreach(current_backend ${all_backends})
|
||||
if (current_backend STREQUAL "NO_BACKEND")
|
||||
set (current_backend "")
|
||||
endif()
|
||||
set_tests_properties("${tname}${backend}" PROPERTIES
|
||||
TIMEOUT ${timeout}
|
||||
RUN_SERIAL ${run_serial}
|
||||
)
|
||||
endforeach (test)
|
||||
foreach (test ${VTKm_UT_SOURCES})
|
||||
get_filename_component(tname ${test} NAME_WE)
|
||||
if(VTKm_UT_MPI AND VTKm_ENABLE_MPI)
|
||||
add_test(NAME ${tname}${current_backend}
|
||||
COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 3 ${MPIEXEC_PREFLAGS}
|
||||
$<TARGET_FILE:${test_prog}> ${tname} --device=${current_backend} ${VTKm_UT_TEST_ARGS}
|
||||
${MPIEXEC_POSTFLAGS}
|
||||
)
|
||||
else()
|
||||
add_test(NAME ${tname}${current_backend}
|
||||
COMMAND ${test_prog} ${tname} --device=${current_backend} ${VTKm_UT_TEST_ARGS}
|
||||
)
|
||||
endif()
|
||||
|
||||
#determine the timeout for all the tests based on the backend. CUDA tests
|
||||
#generally require more time because of kernel generation.
|
||||
if (current_backend STREQUAL "CUDA")
|
||||
set(timeout 1500)
|
||||
else()
|
||||
set(timeout 180)
|
||||
endif()
|
||||
if(current_backend STREQUAL "OPENMP")
|
||||
#We need to have all OpenMP tests run serially as they
|
||||
#will uses all the system cores, and we will cause a N*N thread
|
||||
#explosion which causes the tests to run slower than when run
|
||||
#serially
|
||||
set(run_serial True)
|
||||
else()
|
||||
set(run_serial False)
|
||||
endif()
|
||||
|
||||
set_tests_properties("${tname}${current_backend}" PROPERTIES
|
||||
TIMEOUT ${timeout}
|
||||
RUN_SERIAL ${run_serial}
|
||||
)
|
||||
endforeach (test)
|
||||
endforeach(current_backend)
|
||||
|
||||
endfunction(vtkm_unit_tests)
|
||||
|
||||
|
11
docs/changelog/merge-worklet-testing-executables.md
Normal file
11
docs/changelog/merge-worklet-testing-executables.md
Normal file
@ -0,0 +1,11 @@
|
||||
Merge worklet testing executables into a device dependent shared library
|
||||
|
||||
VTK-m has been updated to replace old per device worklet testing executables with a device
|
||||
dependent shared library so that it's able to accept a device adapter
|
||||
at runtime.
|
||||
Meanwhile, it updates the testing infrastructure APIs. vtkm::cont::testing::Run
|
||||
function would call ForceDevice when needed and if users need the device
|
||||
adapter info at runtime, RunOnDevice function would pass the adapter into the functor.
|
||||
|
||||
Optional Parser is bumped from 1.3 to 1.7.
|
||||
|
@ -187,6 +187,54 @@ struct StreamingScanExclusiveFunctor
|
||||
vtkm::cont::DeviceAdapterAlgorithm<Device>::StreamingScanExclusive(numBlocks, input, output);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Device, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT bool operator()(Device,
|
||||
const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binary_functor,
|
||||
const T& initialValue)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
result = vtkm::cont::DeviceAdapterAlgorithm<Device>::StreamingScanExclusive(
|
||||
numBlocks, input, output, binary_functor, initialValue);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename U>
|
||||
struct StreamingReduceFunctor
|
||||
{
|
||||
U result;
|
||||
StreamingReduceFunctor()
|
||||
: result(U(0))
|
||||
{
|
||||
}
|
||||
template <typename Device, typename T, class CIn>
|
||||
VTKM_CONT bool operator()(Device,
|
||||
const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U initialValue)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
result =
|
||||
vtkm::cont::DeviceAdapterAlgorithm<Device>::StreamingReduce(numBlocks, input, initialValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Device, typename T, class CIn, class BinaryFunctor>
|
||||
VTKM_CONT bool operator()(Device,
|
||||
const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U InitialValue,
|
||||
BinaryFunctor binaryFunctor)
|
||||
{
|
||||
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
|
||||
result = vtkm::cont::DeviceAdapterAlgorithm<Device>::StreamingReduce(
|
||||
numBlocks, input, InitialValue, binaryFunctor);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
struct ScanInclusiveByKeyFunctor
|
||||
@ -559,6 +607,7 @@ struct Algorithm
|
||||
vtkm::cont::TryExecuteOnDevice(devId, functor, numBlocks, input, output);
|
||||
return functor.result;
|
||||
}
|
||||
|
||||
template <typename T, class CIn, class COut>
|
||||
VTKM_CONT static T StreamingScanExclusive(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
@ -567,6 +616,46 @@ struct Algorithm
|
||||
return StreamingScanExclusive(vtkm::cont::DeviceAdapterTagAny(), numBlocks, input, output);
|
||||
}
|
||||
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static T StreamingScanExclusive(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
vtkm::cont::ArrayHandle<T, COut>& output,
|
||||
BinaryFunctor binary_functor,
|
||||
const T& initialValue)
|
||||
{
|
||||
detail::StreamingScanExclusiveFunctor<T> functor;
|
||||
vtkm::cont::TryExecuteOnDevice(vtkm::cont::DeviceAdapterTagAny(),
|
||||
functor,
|
||||
numBlocks,
|
||||
input,
|
||||
output,
|
||||
binary_functor,
|
||||
initialValue);
|
||||
return functor.result;
|
||||
}
|
||||
|
||||
template <typename T, typename U, class CIn>
|
||||
VTKM_CONT static U StreamingReduce(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U initialValue)
|
||||
{
|
||||
detail::StreamingReduceFunctor<U> functor;
|
||||
vtkm::cont::TryExecuteOnDevice(
|
||||
vtkm::cont::DeviceAdapterTagAny(), functor, numBlocks, input, initialValue);
|
||||
return functor.result;
|
||||
}
|
||||
|
||||
template <typename T, typename U, class CIn, class BinaryFunctor>
|
||||
VTKM_CONT static U StreamingReduce(const vtkm::Id numBlocks,
|
||||
const vtkm::cont::ArrayHandle<T, CIn>& input,
|
||||
U initialValue,
|
||||
BinaryFunctor binaryFunctor)
|
||||
{
|
||||
detail::StreamingReduceFunctor<U> functor;
|
||||
vtkm::cont::TryExecuteOnDevice(
|
||||
vtkm::cont::DeviceAdapterTagAny(), functor, numBlocks, input, initialValue, binaryFunctor);
|
||||
return functor.result;
|
||||
}
|
||||
|
||||
template <typename T, class CIn, class COut, class BinaryFunctor>
|
||||
VTKM_CONT static T ScanInclusive(vtkm::cont::DeviceAdapterId devId,
|
||||
|
@ -29,6 +29,14 @@
|
||||
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
||||
#include <vtkm/cont/tbb/DeviceAdapterTBB.h>
|
||||
|
||||
//Bring in each device adapters runtime class
|
||||
#include <vtkm/cont/cuda/internal/DeviceAdapterRuntimeDetectorCuda.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterError.h>
|
||||
#include <vtkm/cont/openmp/internal/DeviceAdapterRuntimeDetectorOpenMP.h>
|
||||
#include <vtkm/cont/serial/internal/DeviceAdapterRuntimeDetectorSerial.h>
|
||||
#include <vtkm/cont/tbb/internal/DeviceAdapterRuntimeDetectorTBB.h>
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
@ -76,6 +84,19 @@ struct RuntimeDeviceTrackerInternals
|
||||
bool RuntimeValid[VTKM_MAX_DEVICE_ADAPTER_ID];
|
||||
DeviceAdapterNameType DeviceNames[VTKM_MAX_DEVICE_ADAPTER_ID];
|
||||
};
|
||||
|
||||
struct RuntimeDeviceTrackerFunctor
|
||||
{
|
||||
template <typename DeviceAdapter>
|
||||
VTKM_CONT void operator()(DeviceAdapter, DeviceAdapterId id, RuntimeDeviceTracker* rdt)
|
||||
{
|
||||
vtkm::cont::RuntimeDeviceInformation runtimeDevice;
|
||||
if (DeviceAdapter() == id)
|
||||
{
|
||||
rdt->ForceDeviceImpl(DeviceAdapter(), runtimeDevice.Exists(DeviceAdapter()));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
@ -206,6 +227,13 @@ vtkm::cont::RuntimeDeviceTracker GetGlobalRuntimeDeviceTracker()
|
||||
#endif
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void RuntimeDeviceTracker::ForceDevice(DeviceAdapterId id)
|
||||
{
|
||||
detail::RuntimeDeviceTrackerFunctor functor;
|
||||
vtkm::ListForEach(functor, VTKM_DEFAULT_DEVICE_ADAPTER_LIST_TAG(), id, this);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
DeviceAdapterNameType RuntimeDeviceTracker::GetDeviceName(DeviceAdapterId device) const
|
||||
{
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <vtkm/cont/vtkm_cont_export.h>
|
||||
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/DeviceAdapterListTag.h>
|
||||
#include <vtkm/cont/ErrorBadAllocation.h>
|
||||
#include <vtkm/cont/ErrorBadDevice.h>
|
||||
#include <vtkm/cont/RuntimeDeviceInformation.h>
|
||||
@ -34,10 +35,12 @@ namespace vtkm
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class RuntimeDeviceTracker;
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct RuntimeDeviceTrackerInternals;
|
||||
struct RuntimeDeviceTrackerFunctor;
|
||||
}
|
||||
|
||||
/// A class that can be used to determine if a given device adapter
|
||||
@ -49,6 +52,8 @@ struct RuntimeDeviceTrackerInternals;
|
||||
///
|
||||
class VTKM_ALWAYS_EXPORT RuntimeDeviceTracker
|
||||
{
|
||||
friend struct detail::RuntimeDeviceTrackerFunctor;
|
||||
|
||||
public:
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
@ -196,6 +201,9 @@ public:
|
||||
this->ForceDeviceImpl(device, runtimeDevice.Exists(DeviceAdapterTag()));
|
||||
}
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT void ForceDevice(DeviceAdapterId id);
|
||||
|
||||
VTKM_CONT_EXPORT
|
||||
VTKM_CONT
|
||||
DeviceAdapterNameType GetDeviceName(DeviceAdapterId id) const;
|
||||
|
@ -64,6 +64,7 @@ struct DeviceAdapterId
|
||||
|
||||
protected:
|
||||
friend DeviceAdapterId make_DeviceAdapterId(vtkm::Int8 id);
|
||||
friend DeviceAdapterId make_DeviceAdapterIdFromName(const std::string& name);
|
||||
|
||||
constexpr explicit DeviceAdapterId(vtkm::Int8 id)
|
||||
: Value(id)
|
||||
@ -74,6 +75,28 @@ private:
|
||||
vtkm::Int8 Value;
|
||||
};
|
||||
|
||||
inline DeviceAdapterId make_DeviceAdapterIdFromName(const std::string& name)
|
||||
{
|
||||
vtkm::Int8 deviceId(VTKM_DEVICE_ADAPTER_ERROR);
|
||||
if (name == "SERIAL")
|
||||
{
|
||||
deviceId = VTKM_DEVICE_ADAPTER_SERIAL;
|
||||
}
|
||||
else if (name == "CUDA")
|
||||
{
|
||||
deviceId = VTKM_DEVICE_ADAPTER_CUDA;
|
||||
}
|
||||
else if (name == "TBB")
|
||||
{
|
||||
deviceId = VTKM_DEVICE_ADAPTER_TBB;
|
||||
}
|
||||
else if (name == "OPENMP")
|
||||
{
|
||||
deviceId = VTKM_DEVICE_ADAPTER_OPENMP;
|
||||
}
|
||||
return DeviceAdapterId(deviceId);
|
||||
}
|
||||
|
||||
inline DeviceAdapterId make_DeviceAdapterId(vtkm::Int8 id)
|
||||
{
|
||||
return DeviceAdapterId(id);
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include <vtkm/cont/EnvironmentTracker.h>
|
||||
#include <vtkm/cont/Error.h>
|
||||
#include <vtkm/testing/OptionParser.h>
|
||||
#include <vtkm/testing/Testing.h>
|
||||
#include <vtkm/thirdparty/diy/Configure.h>
|
||||
|
||||
@ -44,13 +45,59 @@ namespace cont
|
||||
{
|
||||
namespace testing
|
||||
{
|
||||
namespace {
|
||||
using namespace vtkm::testing::option;
|
||||
// Lean parser related code
|
||||
enum optionIndex {DEVICE};
|
||||
struct Arg: public vtkm::testing::option::Arg
|
||||
{
|
||||
static ArgStatus Required(const Option& option, bool)
|
||||
{
|
||||
return option.arg == 0 ? vtkm::testing::option::ARG_ILLEGAL : vtkm::testing::option::ARG_OK;
|
||||
}
|
||||
};
|
||||
static Descriptor Usage[] =
|
||||
{
|
||||
{DEVICE, 0, "d", "device", Arg::Required, " -- device \t specify a device to run on."},
|
||||
{0,0,0,0,0,0}
|
||||
};
|
||||
}
|
||||
|
||||
struct Testing
|
||||
{
|
||||
public:
|
||||
|
||||
template <class Func>
|
||||
static VTKM_CONT int Run(Func function)
|
||||
static VTKM_CONT int Run(Func function, int argc = 0, char* argv[] = nullptr)
|
||||
{
|
||||
argc-=(argc>0); argv+=(argc>0); // skip program name argv[0] if present
|
||||
Stats stats(Usage, argc, argv);
|
||||
Option* options = new Option[stats.options_max];
|
||||
Option* buffer = new Option[stats.buffer_max];
|
||||
|
||||
Parser parse(Usage, argc, argv, options, buffer);
|
||||
|
||||
if (parse.error())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (options[DEVICE])
|
||||
{
|
||||
Option* deviceOption = options[DEVICE];
|
||||
vtkm::cont::DeviceAdapterId deviceId = vtkm::cont::make_DeviceAdapterIdFromName(std::string(deviceOption->arg));
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(deviceId);
|
||||
}
|
||||
|
||||
std::vector<std::string> nonOptions;
|
||||
for (int i = 0; i < parse.nonOptionsCount();i++)
|
||||
{
|
||||
nonOptions.push_back(std::string(parse.nonOption(i)));
|
||||
}
|
||||
|
||||
delete[] options;
|
||||
delete[] buffer;
|
||||
|
||||
try
|
||||
{
|
||||
function();
|
||||
@ -78,6 +125,66 @@ public:
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class Func>
|
||||
static VTKM_CONT int RunOnDevice(Func function, int argc = 0, char* argv[] = nullptr)
|
||||
{
|
||||
argc-=(argc>0); argv+=(argc>0); // skip program name argv[0] if present
|
||||
Stats stats(Usage, argc, argv);
|
||||
Option* options = new Option[stats.options_max];
|
||||
Option* buffer = new Option[stats.buffer_max];
|
||||
|
||||
Parser parse(Usage, argc, argv, options, buffer);
|
||||
|
||||
if (parse.error())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
vtkm::cont::DeviceAdapterId deviceId = vtkm::cont::make_DeviceAdapterId(VTKM_DEVICE_ADAPTER_ERROR);
|
||||
if (options[DEVICE])
|
||||
{
|
||||
Option* deviceOption = options[DEVICE];
|
||||
deviceId = vtkm::cont::make_DeviceAdapterIdFromName(std::string(deviceOption->arg));
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(deviceId);
|
||||
}
|
||||
|
||||
std::vector<std::string> nonOptions;
|
||||
for (int i = 0; i < parse.nonOptionsCount();i++)
|
||||
{
|
||||
nonOptions.push_back(std::string(parse.nonOption(i)));
|
||||
}
|
||||
|
||||
delete[] options;
|
||||
delete[] buffer;
|
||||
|
||||
try
|
||||
{
|
||||
function(deviceId);
|
||||
}
|
||||
catch (vtkm::testing::Testing::TestFailure& error)
|
||||
{
|
||||
std::cout << "***** Test failed @ " << error.GetFile() << ":" << error.GetLine() << std::endl
|
||||
<< error.GetMessage() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
catch (vtkm::cont::Error& error)
|
||||
{
|
||||
std::cout << "***** Uncaught VTKm exception thrown." << std::endl
|
||||
<< error.GetMessage() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
catch (std::exception& error)
|
||||
{
|
||||
std::cout << "***** STL exception throw." << std::endl << error.what() << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cout << "***** Unidentified exception thrown." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct Environment
|
||||
|
@ -1556,7 +1556,7 @@ public:
|
||||
return false; // overflow protection: don't accept number of options that doesn't fit signed int
|
||||
|
||||
buffer[parser.op_count] = option;
|
||||
int idx = buffer[parser.op_count].desc->index;
|
||||
int idx = static_cast<int>(buffer[parser.op_count].desc->index);
|
||||
if (options[idx])
|
||||
options[idx].append(buffer[parser.op_count]);
|
||||
else
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <vtkm/testing/TestingMath.h>
|
||||
|
||||
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
int UnitTestMath(int, char* [])
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ class CosmoTools
|
||||
{
|
||||
public:
|
||||
// Run the halo finder and then the NxN MBP center finder
|
||||
template <typename FieldType, typename StorageType, typename DeviceAdapter>
|
||||
template <typename FieldType, typename StorageType>
|
||||
void RunHaloFinder(vtkm::cont::ArrayHandle<FieldType, StorageType>& xLocation,
|
||||
vtkm::cont::ArrayHandle<FieldType, StorageType>& yLocation,
|
||||
vtkm::cont::ArrayHandle<FieldType, StorageType>& zLocation,
|
||||
@ -88,11 +88,10 @@ public:
|
||||
const FieldType linkingLen,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& resultHaloId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& resultMBP,
|
||||
vtkm::cont::ArrayHandle<FieldType>& resultPot,
|
||||
const DeviceAdapter&)
|
||||
vtkm::cont::ArrayHandle<FieldType>& resultPot)
|
||||
{
|
||||
// Constructor gets particle locations, particle mass and min halo size
|
||||
cosmotools::CosmoTools<FieldType, StorageType, DeviceAdapter> cosmo(
|
||||
cosmotools::CosmoTools<FieldType, StorageType> cosmo(
|
||||
nParticles, particleMass, minHaloSize, linkingLen, xLocation, yLocation, zLocation);
|
||||
|
||||
// Find the halos within the particles and the MBP center of each halo
|
||||
@ -100,17 +99,16 @@ public:
|
||||
}
|
||||
|
||||
// Run MBP on a single halo of particles using the N^2 algorithm
|
||||
template <typename FieldType, typename StorageType, typename DeviceAdapter>
|
||||
template <typename FieldType, typename StorageType>
|
||||
void RunMBPCenterFinderNxN(vtkm::cont::ArrayHandle<FieldType, StorageType> xLocation,
|
||||
vtkm::cont::ArrayHandle<FieldType, StorageType> yLocation,
|
||||
vtkm::cont::ArrayHandle<FieldType, StorageType> zLocation,
|
||||
const vtkm::Id nParticles,
|
||||
const FieldType particleMass,
|
||||
vtkm::Pair<vtkm::Id, FieldType>& nxnResult,
|
||||
const DeviceAdapter&)
|
||||
vtkm::Pair<vtkm::Id, FieldType>& nxnResult)
|
||||
{
|
||||
// Constructor gets particle locations and particle mass
|
||||
cosmotools::CosmoTools<FieldType, StorageType, DeviceAdapter> cosmo(
|
||||
cosmotools::CosmoTools<FieldType, StorageType> cosmo(
|
||||
nParticles, particleMass, xLocation, yLocation, zLocation);
|
||||
|
||||
// Most Bound Particle N x N algorithm
|
||||
@ -122,17 +120,16 @@ public:
|
||||
}
|
||||
|
||||
// Run MBP on a single halo of particles using MxN estimation algorithm
|
||||
template <typename FieldType, typename StorageType, typename DeviceAdapter>
|
||||
template <typename FieldType, typename StorageType>
|
||||
void RunMBPCenterFinderMxN(vtkm::cont::ArrayHandle<FieldType, StorageType> xLocation,
|
||||
vtkm::cont::ArrayHandle<FieldType, StorageType> yLocation,
|
||||
vtkm::cont::ArrayHandle<FieldType, StorageType> zLocation,
|
||||
const vtkm::Id nParticles,
|
||||
const FieldType particleMass,
|
||||
vtkm::Pair<vtkm::Id, FieldType>& mxnResult,
|
||||
const DeviceAdapter&)
|
||||
vtkm::Pair<vtkm::Id, FieldType>& mxnResult)
|
||||
{
|
||||
// Constructor gets particle locations and particle mass
|
||||
cosmotools::CosmoTools<FieldType, StorageType, DeviceAdapter> cosmo(
|
||||
cosmotools::CosmoTools<FieldType, StorageType> cosmo(
|
||||
nParticles, particleMass, xLocation, yLocation, zLocation);
|
||||
|
||||
// Most Bound Particle M x N algorithm with binning estimates
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define vtk_m_worklet_FieldStatistics_h
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
@ -37,7 +38,7 @@ namespace worklet
|
||||
{
|
||||
|
||||
//simple functor that prints basic statistics
|
||||
template <typename FieldType, typename DeviceAdapter>
|
||||
template <typename FieldType>
|
||||
class FieldStatistics
|
||||
{
|
||||
public:
|
||||
@ -117,7 +118,7 @@ public:
|
||||
template <typename Storage>
|
||||
void Run(vtkm::cont::ArrayHandle<FieldType, Storage> fieldArray, StatInfo& statinfo)
|
||||
{
|
||||
using DeviceAlgorithms = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using DeviceAlgorithms = vtkm::cont::Algorithm;
|
||||
using FieldPortal = typename vtkm::cont::ArrayHandle<FieldType, Storage>::PortalConstControl;
|
||||
|
||||
// Copy original data to array for sorting
|
||||
@ -154,7 +155,6 @@ public:
|
||||
// Raw moments via Worklet
|
||||
vtkm::worklet::DispatcherMapField<CalculatePowers> calculatePowersDispatcher(
|
||||
CalculatePowers(4));
|
||||
calculatePowersDispatcher.SetDevice(DeviceAdapter());
|
||||
calculatePowersDispatcher.Invoke(fieldArray, pow1Array, pow2Array, pow3Array, pow4Array);
|
||||
|
||||
// Accumulate the results using ScanInclusive
|
||||
@ -166,7 +166,6 @@ public:
|
||||
// Subtract the mean from every value and leave in tempArray
|
||||
vtkm::worklet::DispatcherMapField<SubtractConst> subtractConstDispatcher(
|
||||
SubtractConst(statinfo.mean));
|
||||
subtractConstDispatcher.SetDevice(DeviceAdapter());
|
||||
subtractConstDispatcher.Invoke(fieldArray, tempArray);
|
||||
|
||||
// Calculate sums of powers on the (value - mean) array
|
||||
|
@ -37,16 +37,13 @@ public:
|
||||
///
|
||||
/// \tparam CoordType type of the x, y, z component of the point coordinates.
|
||||
/// \tparam CoordStorageTag
|
||||
/// \tparam DeviceAdapter
|
||||
/// \param coords An ArrayHandle of x, y, z coordinates of input points.
|
||||
/// \param device Tag for selecting device adapter.
|
||||
///
|
||||
template <typename CoordType, typename CoordStorageTag, typename DeviceAdapter>
|
||||
void Build(const vtkm::cont::ArrayHandle<vtkm::Vec<CoordType, 3>, CoordStorageTag>& coords,
|
||||
DeviceAdapter device)
|
||||
template <typename CoordType, typename CoordStorageTag>
|
||||
void Build(const vtkm::cont::ArrayHandle<vtkm::Vec<CoordType, 3>, CoordStorageTag>& coords)
|
||||
{
|
||||
vtkm::worklet::spatialstructure::KdTree3DConstruction().Run(
|
||||
coords, this->PointIds, this->SplitIds, device);
|
||||
coords, this->PointIds, this->SplitIds);
|
||||
}
|
||||
|
||||
/// \brief Nearest neighbor search using KD-Tree
|
||||
@ -73,10 +70,10 @@ public:
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<CoordType, 3>, CoordStorageTag2>& queryPoints,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& nearestNeighborIds,
|
||||
vtkm::cont::ArrayHandle<CoordType>& distances,
|
||||
DeviceAdapter device)
|
||||
DeviceAdapter deviceId)
|
||||
{
|
||||
vtkm::worklet::spatialstructure::KdTree3DNNSearch().Run(
|
||||
coords, this->PointIds, this->SplitIds, queryPoints, nearestNeighborIds, distances, device);
|
||||
coords, this->PointIds, this->SplitIds, queryPoints, nearestNeighborIds, distances, deviceId);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -93,48 +93,42 @@ public:
|
||||
|
||||
/// \brief Use each component to generate RGBA colors
|
||||
///
|
||||
template <typename T, typename S, typename Device>
|
||||
template <typename T, typename S>
|
||||
void Run(const vtkm::cont::ArrayHandle<T, S>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut,
|
||||
Device) const;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut) const;
|
||||
|
||||
/// \brief Use each component to generate RGB colors
|
||||
///
|
||||
template <typename T, typename S, typename Device>
|
||||
template <typename T, typename S>
|
||||
void Run(const vtkm::cont::ArrayHandle<T, S>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut,
|
||||
Device) const;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut) const;
|
||||
|
||||
|
||||
/// \brief Use magnitude of a vector to generate RGBA colors
|
||||
///
|
||||
template <typename T, int N, typename S, typename Device>
|
||||
template <typename T, int N, typename S>
|
||||
void RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut,
|
||||
Device) const;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut) const;
|
||||
|
||||
/// \brief Use magnitude of a vector to generate RGB colors
|
||||
///
|
||||
template <typename T, int N, typename S, typename Device>
|
||||
template <typename T, int N, typename S>
|
||||
void RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut,
|
||||
Device) const;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut) const;
|
||||
|
||||
/// \brief Use a single component of a vector to generate RGBA colors
|
||||
///
|
||||
template <typename T, int N, typename S, typename Device>
|
||||
template <typename T, int N, typename S>
|
||||
void RunComponent(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::IdComponent comp,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut,
|
||||
Device) const;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut) const;
|
||||
|
||||
/// \brief Use a single component of a vector to generate RGB colors
|
||||
///
|
||||
template <typename T, int N, typename S, typename Device>
|
||||
template <typename T, int N, typename S>
|
||||
void RunComponent(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::IdComponent comp,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut,
|
||||
Device) const;
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -60,10 +60,9 @@ inline bool needShiftScale(T, vtkm::Float32, vtkm::Float32)
|
||||
}
|
||||
/// \brief Use each component to generate RGBA colors
|
||||
///
|
||||
template <typename T, typename S, typename Device>
|
||||
template <typename T, typename S>
|
||||
void ScalarsToColors::Run(const vtkm::cont::ArrayHandle<T, S>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut,
|
||||
Device) const
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut) const
|
||||
{
|
||||
using namespace vtkm::worklet::colorconversion;
|
||||
//If our shift is 0 and our scale == 1 no need to apply them
|
||||
@ -73,23 +72,20 @@ void ScalarsToColors::Run(const vtkm::cont::ArrayHandle<T, S>& values,
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<ShiftScaleToRGBA> dispatcher(
|
||||
ShiftScaleToRGBA(this->Shift, this->Scale, this->Alpha));
|
||||
dispatcher.SetDevice(Device());
|
||||
dispatcher.Invoke(values, rgbaOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<ConvertToRGBA> dispatcher(ConvertToRGBA(this->Alpha));
|
||||
dispatcher.SetDevice(Device());
|
||||
dispatcher.Invoke(values, rgbaOut);
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Use each component to generate RGB colors
|
||||
///
|
||||
template <typename T, typename S, typename Device>
|
||||
template <typename T, typename S>
|
||||
void ScalarsToColors::Run(const vtkm::cont::ArrayHandle<T, S>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut,
|
||||
Device) const
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut) const
|
||||
{
|
||||
using namespace vtkm::worklet::colorconversion;
|
||||
using BaseT = typename vtkm::BaseComponent<T>::Type;
|
||||
@ -98,23 +94,21 @@ void ScalarsToColors::Run(const vtkm::cont::ArrayHandle<T, S>& values,
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<ShiftScaleToRGB> dispatcher(
|
||||
ShiftScaleToRGB(this->Shift, this->Scale));
|
||||
dispatcher.SetDevice(Device());
|
||||
dispatcher.Invoke(values, rgbOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<ConvertToRGB> dispatcher;
|
||||
dispatcher.SetDevice(Device());
|
||||
dispatcher.Invoke(values, rgbOut);
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Use magnitude of a vector to generate RGBA colors
|
||||
///
|
||||
template <typename T, int N, typename S, typename Device>
|
||||
void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut,
|
||||
Device) const
|
||||
template <typename T, int N, typename S>
|
||||
void ScalarsToColors::RunMagnitude(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut) const
|
||||
{
|
||||
//magnitude is a complex situation. the default scale factor is incorrect
|
||||
//
|
||||
@ -126,14 +120,12 @@ void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<ShiftScaleToRGBA> dispatcher(
|
||||
ShiftScaleToRGBA(this->Shift, this->Scale, this->Alpha));
|
||||
dispatcher.SetDevice(Device());
|
||||
dispatcher.Invoke(
|
||||
vtkm::cont::make_ArrayHandleTransform(values, colorconversion::MagnitudePortal()), rgbaOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<ConvertToRGBA> dispatcher(ConvertToRGBA(this->Alpha));
|
||||
dispatcher.SetDevice(Device());
|
||||
dispatcher.Invoke(
|
||||
vtkm::cont::make_ArrayHandleTransform(values, colorconversion::MagnitudePortal()), rgbaOut);
|
||||
}
|
||||
@ -141,10 +133,9 @@ void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>
|
||||
|
||||
/// \brief Use magnitude of a vector to generate RGB colors
|
||||
///
|
||||
template <typename T, int N, typename S, typename Device>
|
||||
template <typename T, int N, typename S>
|
||||
void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut,
|
||||
Device) const
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut) const
|
||||
{
|
||||
|
||||
using namespace vtkm::worklet::colorconversion;
|
||||
@ -154,14 +145,12 @@ void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<ShiftScaleToRGB> dispatcher(
|
||||
ShiftScaleToRGB(this->Shift, this->Scale));
|
||||
dispatcher.SetDevice(Device());
|
||||
dispatcher.Invoke(
|
||||
vtkm::cont::make_ArrayHandleTransform(values, colorconversion::MagnitudePortal()), rgbOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<ConvertToRGB> dispatcher;
|
||||
dispatcher.SetDevice(Device());
|
||||
dispatcher.Invoke(
|
||||
vtkm::cont::make_ArrayHandleTransform(values, colorconversion::MagnitudePortal()), rgbOut);
|
||||
}
|
||||
@ -169,28 +158,25 @@ void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>
|
||||
|
||||
/// \brief Use a single component of a vector to generate RGBA colors
|
||||
///
|
||||
template <typename T, int N, typename S, typename Device>
|
||||
void ScalarsToColors::RunComponent(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::IdComponent comp,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut,
|
||||
Device device) const
|
||||
template <typename T, int N, typename S>
|
||||
void ScalarsToColors::RunComponent(
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::IdComponent comp,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& rgbaOut) const
|
||||
{
|
||||
this->Run(vtkm::cont::make_ArrayHandleTransform(values, colorconversion::ComponentPortal(comp)),
|
||||
rgbaOut,
|
||||
device);
|
||||
rgbaOut);
|
||||
}
|
||||
|
||||
/// \brief Use a single component of a vector to generate RGB colors
|
||||
///
|
||||
template <typename T, int N, typename S, typename Device>
|
||||
template <typename T, int N, typename S>
|
||||
void ScalarsToColors::RunComponent(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>, S>& values,
|
||||
vtkm::IdComponent comp,
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut,
|
||||
Device device) const
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>>& rgbOut) const
|
||||
{
|
||||
this->Run(vtkm::cont::make_ArrayHandleTransform(values, colorconversion::ComponentPortal(comp)),
|
||||
rgbOut,
|
||||
device);
|
||||
rgbOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#ifndef vtk_m_worklet_StreamLineUniformGrid_h
|
||||
#define vtk_m_worklet_StreamLineUniformGrid_h
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/CellSetExplicit.h>
|
||||
@ -344,7 +345,7 @@ public:
|
||||
vtkm::Id maxSteps,
|
||||
FieldType timeStep)
|
||||
{
|
||||
using DeviceAlgorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using DeviceAlgorithm = vtkm::cont::Algorithm;
|
||||
|
||||
// Get information from input dataset
|
||||
vtkm::cont::CellSetStructured<3> inCellSet;
|
||||
@ -398,7 +399,6 @@ public:
|
||||
timeStep, streamMode, maxSteps, vdims, fieldArray.PrepareForInput(DeviceAdapter()));
|
||||
using MakeStreamLinesDispatcher = vtkm::worklet::DispatcherMapField<MakeStreamLines>;
|
||||
MakeStreamLinesDispatcher makeStreamLinesDispatcher(makeStreamLines);
|
||||
makeStreamLinesDispatcher.SetDevice(DeviceAdapter());
|
||||
makeStreamLinesDispatcher.Invoke(
|
||||
seedIdArray, seedPosArray, numIndices, validPoint, streamArray);
|
||||
|
||||
|
@ -40,12 +40,11 @@ public:
|
||||
}
|
||||
|
||||
// Multi-level 1D wavelet decomposition
|
||||
template <typename SignalArrayType, typename CoeffArrayType, typename DeviceTag>
|
||||
template <typename SignalArrayType, typename CoeffArrayType>
|
||||
VTKM_CONT vtkm::Id WaveDecompose(const SignalArrayType& sigIn, // Input
|
||||
vtkm::Id nLevels, // n levels of DWT
|
||||
CoeffArrayType& coeffOut,
|
||||
std::vector<vtkm::Id>& L,
|
||||
DeviceTag)
|
||||
std::vector<vtkm::Id>& L)
|
||||
{
|
||||
vtkm::Id sigInLen = sigIn.GetNumberOfValues();
|
||||
if (nLevels < 0 || nLevels > WaveletBase::GetWaveletMaxLevel(sigInLen))
|
||||
@ -54,7 +53,7 @@ public:
|
||||
}
|
||||
if (nLevels == 0) // 0 levels means no transform
|
||||
{
|
||||
vtkm::cont::ArrayCopy(sigIn, coeffOut, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(sigIn, coeffOut);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -77,7 +76,7 @@ public:
|
||||
using IdArrayType = vtkm::cont::ArrayHandleCounting<vtkm::Id>;
|
||||
using PermutArrayType = vtkm::cont::ArrayHandlePermutation<IdArrayType, CoeffArrayType>;
|
||||
|
||||
vtkm::cont::ArrayCopy(sigIn, coeffOut, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(sigIn, coeffOut);
|
||||
|
||||
for (vtkm::Id i = nLevels; i > 0; i--)
|
||||
{
|
||||
@ -90,10 +89,10 @@ public:
|
||||
// make output array
|
||||
InterArrayType output;
|
||||
|
||||
WaveletDWT::DWT1D(input, output, L1d, DeviceTag());
|
||||
WaveletDWT::DWT1D(input, output, L1d);
|
||||
|
||||
// move intermediate results to final array
|
||||
WaveletBase::DeviceCopyStartX(output, coeffOut, cptr, DeviceTag());
|
||||
WaveletBase::DeviceCopyStartX(output, coeffOut, cptr);
|
||||
|
||||
// update pseudo pointers
|
||||
len = cALen;
|
||||
@ -105,12 +104,11 @@ public:
|
||||
}
|
||||
|
||||
// Multi-level 1D wavelet reconstruction
|
||||
template <typename CoeffArrayType, typename SignalArrayType, typename DeviceTag>
|
||||
template <typename CoeffArrayType, typename SignalArrayType>
|
||||
VTKM_CONT vtkm::Id WaveReconstruct(const CoeffArrayType& coeffIn, // Input
|
||||
vtkm::Id nLevels, // n levels of DWT
|
||||
std::vector<vtkm::Id>& L,
|
||||
SignalArrayType& sigOut,
|
||||
DeviceTag)
|
||||
SignalArrayType& sigOut)
|
||||
{
|
||||
VTKM_ASSERT(nLevels > 0);
|
||||
vtkm::Id LLength = nLevels + 2;
|
||||
@ -125,7 +123,7 @@ public:
|
||||
using IdArrayType = vtkm::cont::ArrayHandleCounting<vtkm::Id>;
|
||||
using PermutArrayType = vtkm::cont::ArrayHandlePermutation<IdArrayType, SignalArrayType>;
|
||||
|
||||
vtkm::cont::ArrayCopy(coeffIn, sigOut, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(coeffIn, sigOut);
|
||||
|
||||
for (vtkm::Id i = 1; i <= nLevels; i++)
|
||||
{
|
||||
@ -138,11 +136,11 @@ public:
|
||||
// Make an output array
|
||||
OutArrayBasic output;
|
||||
|
||||
WaveletDWT::IDWT1D(input, L1d, output, DeviceTag());
|
||||
WaveletDWT::IDWT1D(input, L1d, output);
|
||||
VTKM_ASSERT(output.GetNumberOfValues() == L1d[2]);
|
||||
|
||||
// Move output to intermediate array
|
||||
WaveletBase::DeviceCopyStartX(output, sigOut, 0, DeviceTag());
|
||||
WaveletBase::DeviceCopyStartX(output, sigOut, 0);
|
||||
|
||||
L1d[0] = L1d[2];
|
||||
L1d[1] = L[size_t(i + 1)];
|
||||
@ -152,15 +150,14 @@ public:
|
||||
}
|
||||
|
||||
// Multi-level 3D wavelet decomposition
|
||||
template <typename InArrayType, typename OutArrayType, typename DeviceTag>
|
||||
template <typename InArrayType, typename OutArrayType>
|
||||
VTKM_CONT vtkm::Float64 WaveDecompose3D(InArrayType& sigIn, // Input
|
||||
vtkm::Id nLevels, // n levels of DWT
|
||||
vtkm::Id inX,
|
||||
vtkm::Id inY,
|
||||
vtkm::Id inZ,
|
||||
OutArrayType& coeffOut,
|
||||
bool discardSigIn, // can we discard sigIn on devices?
|
||||
DeviceTag)
|
||||
bool discardSigIn) // can we discard sigIn on devices?
|
||||
{
|
||||
vtkm::Id sigInLen = sigIn.GetNumberOfValues();
|
||||
VTKM_ASSERT(inX * inY * inZ == sigInLen);
|
||||
@ -172,32 +169,20 @@ public:
|
||||
}
|
||||
if (nLevels == 0) // 0 levels means no transform
|
||||
{
|
||||
vtkm::cont::ArrayCopy(sigIn, coeffOut, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(sigIn, coeffOut);
|
||||
return 0;
|
||||
}
|
||||
|
||||
vtkm::Id currentLenX = inX;
|
||||
vtkm::Id currentLenY = inY;
|
||||
vtkm::Id currentLenZ = inZ;
|
||||
std::vector<vtkm::Id> L3d(27, 0);
|
||||
|
||||
using OutValueType = typename OutArrayType::ValueType;
|
||||
using OutBasicArray = vtkm::cont::ArrayHandle<OutValueType>;
|
||||
|
||||
// First level transform writes to the output array
|
||||
vtkm::Float64 computationTime = WaveletDWT::DWT3D(sigIn,
|
||||
inX,
|
||||
inY,
|
||||
inZ,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
currentLenX,
|
||||
currentLenY,
|
||||
currentLenZ,
|
||||
coeffOut,
|
||||
discardSigIn,
|
||||
DeviceTag());
|
||||
vtkm::Float64 computationTime = WaveletDWT::DWT3D(
|
||||
sigIn, inX, inY, inZ, 0, 0, 0, currentLenX, currentLenY, currentLenZ, coeffOut, discardSigIn);
|
||||
|
||||
// Successor transforms writes to a temporary array
|
||||
for (vtkm::Id i = nLevels - 1; i > 0; i--)
|
||||
@ -208,40 +193,19 @@ public:
|
||||
|
||||
OutBasicArray tempOutput;
|
||||
|
||||
computationTime += WaveletDWT::DWT3D(coeffOut,
|
||||
inX,
|
||||
inY,
|
||||
inZ,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
currentLenX,
|
||||
currentLenY,
|
||||
currentLenZ,
|
||||
tempOutput,
|
||||
false,
|
||||
DeviceTag());
|
||||
computationTime += WaveletDWT::DWT3D(
|
||||
coeffOut, inX, inY, inZ, 0, 0, 0, currentLenX, currentLenY, currentLenZ, tempOutput, false);
|
||||
|
||||
// copy results to coeffOut
|
||||
WaveletBase::DeviceCubeCopyTo(tempOutput,
|
||||
currentLenX,
|
||||
currentLenY,
|
||||
currentLenZ,
|
||||
coeffOut,
|
||||
inX,
|
||||
inY,
|
||||
inZ,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
DeviceTag());
|
||||
WaveletBase::DeviceCubeCopyTo(
|
||||
tempOutput, currentLenX, currentLenY, currentLenZ, coeffOut, inX, inY, inZ, 0, 0, 0);
|
||||
}
|
||||
|
||||
return computationTime;
|
||||
}
|
||||
|
||||
// Multi-level 3D wavelet reconstruction
|
||||
template <typename InArrayType, typename OutArrayType, typename DeviceTag>
|
||||
template <typename InArrayType, typename OutArrayType>
|
||||
VTKM_CONT vtkm::Float64 WaveReconstruct3D(
|
||||
InArrayType& arrIn, // Input
|
||||
vtkm::Id nLevels, // n levels of DWT
|
||||
@ -249,8 +213,7 @@ public:
|
||||
vtkm::Id inY,
|
||||
vtkm::Id inZ,
|
||||
OutArrayType& arrOut,
|
||||
bool discardArrIn, // can we discard input for more memory?
|
||||
DeviceTag)
|
||||
bool discardArrIn) // can we discard input for more memory?
|
||||
{
|
||||
vtkm::Id arrInLen = arrIn.GetNumberOfValues();
|
||||
VTKM_ASSERT(inX * inY * inZ == arrInLen);
|
||||
@ -267,7 +230,7 @@ public:
|
||||
OutBasicArray outBuffer;
|
||||
if (nLevels == 0) // 0 levels means no transform
|
||||
{
|
||||
vtkm::cont::ArrayCopy(arrIn, arrOut, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(arrIn, arrOut);
|
||||
return 0;
|
||||
}
|
||||
else if (discardArrIn)
|
||||
@ -276,7 +239,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::ArrayCopy(arrIn, outBuffer, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(arrIn, outBuffer);
|
||||
}
|
||||
|
||||
std::vector<vtkm::Id> L;
|
||||
@ -298,11 +261,11 @@ public:
|
||||
|
||||
// IDWT
|
||||
computationTime +=
|
||||
WaveletDWT::IDWT3D(outBuffer, inX, inY, inZ, 0, 0, 0, L3d, tempOutput, false, DeviceTag());
|
||||
WaveletDWT::IDWT3D(outBuffer, inX, inY, inZ, 0, 0, 0, L3d, tempOutput, false);
|
||||
|
||||
// copy back reconstructed block
|
||||
WaveletBase::DeviceCubeCopyTo(
|
||||
tempOutput, L3d[24], L3d[25], L3d[26], outBuffer, inX, inY, inZ, 0, 0, 0, DeviceTag());
|
||||
tempOutput, L3d[24], L3d[25], L3d[26], outBuffer, inX, inY, inZ, 0, 0, 0);
|
||||
|
||||
// update L3d array
|
||||
L3d[0] = L3d[24];
|
||||
@ -318,21 +281,19 @@ public:
|
||||
L3d[24] = L3d[0] + L3d[12];
|
||||
L3d[25] = L3d[1] + L3d[7];
|
||||
L3d[26] = L3d[2] + L3d[5];
|
||||
computationTime +=
|
||||
WaveletDWT::IDWT3D(outBuffer, inX, inY, inZ, 0, 0, 0, L3d, arrOut, true, DeviceTag());
|
||||
computationTime += WaveletDWT::IDWT3D(outBuffer, inX, inY, inZ, 0, 0, 0, L3d, arrOut, true);
|
||||
|
||||
return computationTime;
|
||||
}
|
||||
|
||||
// Multi-level 2D wavelet decomposition
|
||||
template <typename InArrayType, typename OutArrayType, typename DeviceTag>
|
||||
template <typename InArrayType, typename OutArrayType>
|
||||
VTKM_CONT vtkm::Float64 WaveDecompose2D(const InArrayType& sigIn, // Input
|
||||
vtkm::Id nLevels, // n levels of DWT
|
||||
vtkm::Id inX, // Input X dim
|
||||
vtkm::Id inY, // Input Y dim
|
||||
OutArrayType& coeffOut,
|
||||
std::vector<vtkm::Id>& L,
|
||||
DeviceTag)
|
||||
std::vector<vtkm::Id>& L)
|
||||
{
|
||||
vtkm::Id sigInLen = sigIn.GetNumberOfValues();
|
||||
VTKM_ASSERT(inX * inY == sigInLen);
|
||||
@ -343,7 +304,7 @@ public:
|
||||
}
|
||||
if (nLevels == 0) // 0 levels means no transform
|
||||
{
|
||||
vtkm::cont::ArrayCopy(sigIn, coeffOut, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(sigIn, coeffOut);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -361,7 +322,7 @@ public:
|
||||
|
||||
// First level transform operates writes to the output array
|
||||
computationTime += WaveletDWT::DWT2D(
|
||||
sigIn, currentLenX, currentLenY, 0, 0, currentLenX, currentLenY, coeffOut, L2d, DeviceTag());
|
||||
sigIn, currentLenX, currentLenY, 0, 0, currentLenX, currentLenY, coeffOut, L2d);
|
||||
VTKM_ASSERT(coeffOut.GetNumberOfValues() == currentLenX * currentLenY);
|
||||
currentLenX = WaveletBase::GetApproxLength(currentLenX);
|
||||
currentLenY = WaveletBase::GetApproxLength(currentLenY);
|
||||
@ -371,12 +332,12 @@ public:
|
||||
{
|
||||
OutBasicArray tempOutput;
|
||||
|
||||
computationTime += WaveletDWT::DWT2D(
|
||||
coeffOut, inX, inY, 0, 0, currentLenX, currentLenY, tempOutput, L2d, DeviceTag());
|
||||
computationTime +=
|
||||
WaveletDWT::DWT2D(coeffOut, inX, inY, 0, 0, currentLenX, currentLenY, tempOutput, L2d);
|
||||
|
||||
// copy results to coeffOut
|
||||
WaveletBase::DeviceRectangleCopyTo(
|
||||
tempOutput, currentLenX, currentLenY, coeffOut, inX, inY, 0, 0, DeviceTag());
|
||||
tempOutput, currentLenX, currentLenY, coeffOut, inX, inY, 0, 0);
|
||||
|
||||
// update currentLen
|
||||
currentLenX = WaveletBase::GetApproxLength(currentLenX);
|
||||
@ -387,14 +348,13 @@ public:
|
||||
}
|
||||
|
||||
// Multi-level 2D wavelet reconstruction
|
||||
template <typename InArrayType, typename OutArrayType, typename DeviceTag>
|
||||
template <typename InArrayType, typename OutArrayType>
|
||||
VTKM_CONT vtkm::Float64 WaveReconstruct2D(const InArrayType& arrIn, // Input
|
||||
vtkm::Id nLevels, // n levels of DWT
|
||||
vtkm::Id inX, // Input X dim
|
||||
vtkm::Id inY, // Input Y dim
|
||||
OutArrayType& arrOut,
|
||||
std::vector<vtkm::Id>& L,
|
||||
DeviceTag)
|
||||
std::vector<vtkm::Id>& L)
|
||||
{
|
||||
vtkm::Id arrInLen = arrIn.GetNumberOfValues();
|
||||
VTKM_ASSERT(inX * inY == arrInLen);
|
||||
@ -410,12 +370,12 @@ public:
|
||||
OutBasicArray outBuffer;
|
||||
if (nLevels == 0) // 0 levels means no transform
|
||||
{
|
||||
vtkm::cont::ArrayCopy(arrIn, arrOut, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(arrIn, arrOut);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::cont::ArrayCopy(arrIn, outBuffer, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(arrIn, outBuffer);
|
||||
}
|
||||
|
||||
VTKM_ASSERT(vtkm::Id(L.size()) == 6 * nLevels + 4);
|
||||
@ -439,12 +399,10 @@ public:
|
||||
OutBasicArray tempOutput;
|
||||
|
||||
// IDWT
|
||||
computationTime +=
|
||||
WaveletDWT::IDWT2D(outBuffer, inX, inY, 0, 0, L2d, tempOutput, DeviceTag());
|
||||
computationTime += WaveletDWT::IDWT2D(outBuffer, inX, inY, 0, 0, L2d, tempOutput);
|
||||
|
||||
// copy back reconstructed block
|
||||
WaveletBase::DeviceRectangleCopyTo(
|
||||
tempOutput, L2d[8], L2d[9], outBuffer, inX, inY, 0, 0, DeviceTag());
|
||||
WaveletBase::DeviceRectangleCopyTo(tempOutput, L2d[8], L2d[9], outBuffer, inX, inY, 0, 0);
|
||||
|
||||
// update L2d array
|
||||
L2d[0] = L2d[8];
|
||||
@ -460,14 +418,14 @@ public:
|
||||
// The last transform outputs to the final output
|
||||
L2d[8] = L2d[0] + L2d[4];
|
||||
L2d[9] = L2d[1] + L2d[3];
|
||||
computationTime += WaveletDWT::IDWT2D(outBuffer, inX, inY, 0, 0, L2d, arrOut, DeviceTag());
|
||||
computationTime += WaveletDWT::IDWT2D(outBuffer, inX, inY, 0, 0, L2d, arrOut);
|
||||
|
||||
return computationTime;
|
||||
}
|
||||
|
||||
// Squash coefficients smaller than a threshold
|
||||
template <typename CoeffArrayType, typename DeviceTag>
|
||||
vtkm::Id SquashCoefficients(CoeffArrayType& coeffIn, vtkm::Float64 ratio, DeviceTag)
|
||||
template <typename CoeffArrayType>
|
||||
vtkm::Id SquashCoefficients(CoeffArrayType& coeffIn, vtkm::Float64 ratio)
|
||||
{
|
||||
if (ratio > 1.0)
|
||||
{
|
||||
@ -475,9 +433,9 @@ public:
|
||||
using ValueType = typename CoeffArrayType::ValueType;
|
||||
using CoeffArrayBasic = vtkm::cont::ArrayHandle<ValueType>;
|
||||
CoeffArrayBasic sortedArray;
|
||||
vtkm::cont::ArrayCopy(coeffIn, sortedArray, DeviceTag());
|
||||
vtkm::cont::ArrayCopy(coeffIn, sortedArray);
|
||||
|
||||
WaveletBase::DeviceSort(sortedArray, DeviceTag());
|
||||
WaveletBase::DeviceSort(sortedArray);
|
||||
|
||||
vtkm::Id n = coeffLen - static_cast<vtkm::Id>(static_cast<vtkm::Float64>(coeffLen) / ratio);
|
||||
vtkm::Float64 nthVal = static_cast<vtkm::Float64>(sortedArray.GetPortalConstControl().Get(n));
|
||||
@ -489,7 +447,6 @@ public:
|
||||
using ThresholdType = vtkm::worklet::wavelets::ThresholdWorklet;
|
||||
ThresholdType thresholdWorklet(nthVal);
|
||||
vtkm::worklet::DispatcherMapField<ThresholdType> dispatcher(thresholdWorklet);
|
||||
dispatcher.SetDevice(DeviceTag());
|
||||
dispatcher.Invoke(coeffIn);
|
||||
}
|
||||
|
||||
@ -497,14 +454,12 @@ public:
|
||||
}
|
||||
|
||||
// Report statistics on reconstructed array
|
||||
template <typename ArrayType, typename DeviceTag>
|
||||
vtkm::Id EvaluateReconstruction(const ArrayType& original,
|
||||
const ArrayType& reconstruct,
|
||||
DeviceTag)
|
||||
template <typename ArrayType>
|
||||
vtkm::Id EvaluateReconstruction(const ArrayType& original, const ArrayType& reconstruct)
|
||||
{
|
||||
#define VAL vtkm::Float64
|
||||
#define MAKEVAL(a) (static_cast<VAL>(a))
|
||||
VAL VarOrig = WaveletBase::DeviceCalculateVariance(original, DeviceTag());
|
||||
VAL VarOrig = WaveletBase::DeviceCalculateVariance(original);
|
||||
|
||||
using ValueType = typename ArrayType::ValueType;
|
||||
using ArrayBasic = vtkm::cont::ArrayHandle<ValueType>;
|
||||
@ -514,16 +469,14 @@ public:
|
||||
using DifferencerWorklet = vtkm::worklet::wavelets::Differencer;
|
||||
DifferencerWorklet dw;
|
||||
vtkm::worklet::DispatcherMapField<DifferencerWorklet> dwDispatcher(dw);
|
||||
dwDispatcher.SetDevice(DeviceTag());
|
||||
dwDispatcher.Invoke(original, reconstruct, errorArray);
|
||||
|
||||
using SquareWorklet = vtkm::worklet::wavelets::SquareWorklet;
|
||||
SquareWorklet sw;
|
||||
vtkm::worklet::DispatcherMapField<SquareWorklet> swDispatcher(sw);
|
||||
swDispatcher.SetDevice(DeviceTag());
|
||||
swDispatcher.Invoke(errorArray, errorSquare);
|
||||
|
||||
VAL varErr = WaveletBase::DeviceCalculateVariance(errorArray, DeviceTag());
|
||||
VAL varErr = WaveletBase::DeviceCalculateVariance(errorArray);
|
||||
VAL snr, decibels;
|
||||
if (varErr != 0.0)
|
||||
{
|
||||
@ -536,12 +489,12 @@ public:
|
||||
decibels = vtkm::Infinity64();
|
||||
}
|
||||
|
||||
VAL origMax = WaveletBase::DeviceMax(original, DeviceTag());
|
||||
VAL origMin = WaveletBase::DeviceMin(original, DeviceTag());
|
||||
VAL errorMax = WaveletBase::DeviceMaxAbs(errorArray, DeviceTag());
|
||||
VAL origMax = WaveletBase::DeviceMax(original);
|
||||
VAL origMin = WaveletBase::DeviceMin(original);
|
||||
VAL errorMax = WaveletBase::DeviceMaxAbs(errorArray);
|
||||
VAL range = origMax - origMin;
|
||||
|
||||
VAL squareSum = WaveletBase::DeviceSum(errorSquare, DeviceTag());
|
||||
VAL squareSum = WaveletBase::DeviceSum(errorSquare);
|
||||
VAL rmse = vtkm::Sqrt(MAKEVAL(squareSum) / MAKEVAL(errorArray.GetNumberOfValues()));
|
||||
|
||||
std::cout << "Data range = " << range << std::endl;
|
||||
|
@ -35,21 +35,17 @@ namespace connectivity
|
||||
class CellSetConnectivity
|
||||
{
|
||||
public:
|
||||
template <typename CellSetType, typename DeviceAdapter>
|
||||
void Run(const CellSetType& cellSet,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& componentArray,
|
||||
DeviceAdapter) const
|
||||
template <typename CellSetType>
|
||||
void Run(const CellSetType& cellSet, vtkm::cont::ArrayHandle<vtkm::Id>& componentArray) const
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> numIndicesArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> indexOffsetArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> connectivityArray;
|
||||
|
||||
// create cell to cell connectivity graph (dual graph)
|
||||
CellSetDualGraph<DeviceAdapter>().Run(
|
||||
cellSet, numIndicesArray, indexOffsetArray, connectivityArray);
|
||||
CellSetDualGraph().Run(cellSet, numIndicesArray, indexOffsetArray, connectivityArray);
|
||||
// find the connected component of the dual graph
|
||||
GraphConnectivity<DeviceAdapter>().Run(
|
||||
numIndicesArray, indexOffsetArray, connectivityArray, componentArray);
|
||||
GraphConnectivity().Run(numIndicesArray, indexOffsetArray, connectivityArray, componentArray);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -104,11 +104,10 @@ struct CellToCellConnectivity : public vtkm::worklet::WorkletMapField
|
||||
};
|
||||
} // vtkm::worklet::connectivity::detail
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
class CellSetDualGraph
|
||||
{
|
||||
public:
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
struct degree2
|
||||
{
|
||||
@ -124,13 +123,11 @@ public:
|
||||
// Get number of edges for each cell and use it as scatter count.
|
||||
vtkm::cont::ArrayHandle<vtkm::IdComponent> numEdgesPerCell;
|
||||
vtkm::worklet::DispatcherMapTopology<detail::EdgeCount> edgesPerCellDisp;
|
||||
edgesPerCellDisp.SetDevice(DeviceAdapter());
|
||||
edgesPerCellDisp.Invoke(cellSet, numEdgesPerCell);
|
||||
|
||||
// Get uncompress Cell to Edge mapping
|
||||
vtkm::worklet::ScatterCounting scatter{ numEdgesPerCell, DeviceAdapter() };
|
||||
vtkm::worklet::ScatterCounting scatter{ numEdgesPerCell };
|
||||
vtkm::worklet::DispatcherMapTopology<detail::EdgeExtract> edgeExtractDisp{ scatter };
|
||||
edgeExtractDisp.SetDevice(DeviceAdapter());
|
||||
edgeExtractDisp.Invoke(cellSet, cellIds, cellEdges);
|
||||
}
|
||||
|
||||
@ -173,7 +170,6 @@ public:
|
||||
connFrom.Allocate(sharedEdges.GetNumberOfValues() * 2);
|
||||
connTo.Allocate(sharedEdges.GetNumberOfValues() * 2);
|
||||
vtkm::worklet::DispatcherMapField<detail::CellToCellConnectivity> c2cDisp;
|
||||
c2cDisp.SetDevice(DeviceAdapter());
|
||||
c2cDisp.Invoke(lb, cellIds, connFrom, connTo);
|
||||
|
||||
// Turn dual graph into Compressed Sparse Row format
|
||||
|
@ -68,11 +68,10 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
class GraphConnectivity
|
||||
{
|
||||
public:
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
template <typename InputPortalType, typename OutputPortalType>
|
||||
void Run(const InputPortalType& numIndexArray,
|
||||
@ -91,18 +90,15 @@ public:
|
||||
do
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<detail::Graft> graftDispatcher;
|
||||
graftDispatcher.SetDevice(DeviceAdapter());
|
||||
graftDispatcher.Invoke(
|
||||
cellIds, indexOffsetArray, numIndexArray, connectivityArray, components);
|
||||
|
||||
// Detection of allStar has to come before pointer jumping. Don't try to rearrange it.
|
||||
vtkm::worklet::DispatcherMapField<IsStar> isStarDisp;
|
||||
isStarDisp.SetDevice(DeviceAdapter());
|
||||
isStarDisp.Invoke(cellIds, components, isStar);
|
||||
allStar = Algorithm::Reduce(isStar, true, vtkm::LogicalAnd());
|
||||
|
||||
vtkm::worklet::DispatcherMapField<PointerJumping> pointJumpingDispatcher;
|
||||
pointJumpingDispatcher.SetDevice(DeviceAdapter());
|
||||
pointJumpingDispatcher.Invoke(cellIds, components);
|
||||
} while (!allStar);
|
||||
|
||||
@ -118,7 +114,7 @@ public:
|
||||
uniqueColor);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellColors;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellIdsOut;
|
||||
InnerJoin<DeviceAdapter>().Run(
|
||||
InnerJoin().Run(
|
||||
components, cellIds, uniqueComponents, uniqueColor, cellColors, cellIdsOut, componentsOut);
|
||||
|
||||
Algorithm::SortByKey(cellIdsOut, componentsOut);
|
||||
|
@ -80,13 +80,12 @@ public:
|
||||
class RunImpl
|
||||
{
|
||||
public:
|
||||
template <typename StorageT, typename OutputPortalType, typename Device>
|
||||
template <typename StorageT, typename OutputPortalType>
|
||||
void operator()(const vtkm::cont::ArrayHandle<vtkm::UInt8, StorageT>& pixels,
|
||||
const vtkm::cont::CellSetStructured<2>& input,
|
||||
OutputPortalType& componentsOut,
|
||||
Device) const
|
||||
OutputPortalType& componentsOut) const
|
||||
{
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<Device>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
// TODO: template pixel type?
|
||||
|
||||
@ -105,17 +104,14 @@ public:
|
||||
do
|
||||
{
|
||||
vtkm::worklet::DispatcherPointNeighborhood<detail::ImageGraft<2>> imageGraftDispatcher;
|
||||
imageGraftDispatcher.SetDevice(Device());
|
||||
imageGraftDispatcher.Invoke(input, componentsOut, pixels, newComponents);
|
||||
|
||||
// Detection of allStar has to come before pointer jumping. Don't try to rearrange it.
|
||||
vtkm::worklet::DispatcherMapField<IsStar> isStarDisp;
|
||||
isStarDisp.SetDevice(Device());
|
||||
isStarDisp.Invoke(pixelIds, newComponents, isStar);
|
||||
allStar = Algorithm::Reduce(isStar, true, vtkm::LogicalAnd());
|
||||
|
||||
vtkm::worklet::DispatcherMapField<PointerJumping> pointJumpingDispatcher;
|
||||
pointJumpingDispatcher.SetDevice(Device());
|
||||
pointJumpingDispatcher.Invoke(pixelIds, newComponents);
|
||||
|
||||
Algorithm::Copy(newComponents, componentsOut);
|
||||
@ -134,35 +130,33 @@ public:
|
||||
uniqueColor);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> cellColors;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> pixelIdsOut;
|
||||
InnerJoin<Device>().Run(componentsOut,
|
||||
pixelIds,
|
||||
uniqueComponents,
|
||||
uniqueColor,
|
||||
cellColors,
|
||||
pixelIdsOut,
|
||||
componentsOut);
|
||||
InnerJoin().Run(componentsOut,
|
||||
pixelIds,
|
||||
uniqueComponents,
|
||||
uniqueColor,
|
||||
cellColors,
|
||||
pixelIdsOut,
|
||||
componentsOut);
|
||||
|
||||
Algorithm::SortByKey(pixelIdsOut, componentsOut);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename S, typename OutputPortalType, typename Device>
|
||||
template <typename T, typename S, typename OutputPortalType>
|
||||
void Run(const vtkm::cont::CellSetStructured<2>& input,
|
||||
const vtkm::cont::DynamicArrayHandleBase<T, S>& pixels,
|
||||
OutputPortalType& componentsOut,
|
||||
Device device) const
|
||||
OutputPortalType& componentsOut) const
|
||||
{
|
||||
using Types = vtkm::ListTagBase<vtkm::UInt8>;
|
||||
vtkm::cont::CastAndCall(pixels.ResetTypeList(Types{}), RunImpl(), input, componentsOut, device);
|
||||
vtkm::cont::CastAndCall(pixels.ResetTypeList(Types{}), RunImpl(), input, componentsOut);
|
||||
}
|
||||
|
||||
template <typename T, typename S, typename OutputPortalType, typename Device>
|
||||
template <typename T, typename S, typename OutputPortalType>
|
||||
void Run(const vtkm::cont::CellSetStructured<2>& input,
|
||||
const vtkm::cont::ArrayHandle<T, S>& pixels,
|
||||
OutputPortalType& componentsOut,
|
||||
Device device) const
|
||||
OutputPortalType& componentsOut) const
|
||||
{
|
||||
vtkm::cont::CastAndCall(pixels, RunImpl(), input, componentsOut, device);
|
||||
vtkm::cont::CastAndCall(pixels, RunImpl(), input, componentsOut);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#define vtk_m_worklet_connectivity_InnerJoin_h
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/ScatterCounting.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
@ -35,7 +34,6 @@ namespace worklet
|
||||
{
|
||||
namespace connectivity
|
||||
{
|
||||
template <typename DeviceAdapter>
|
||||
class InnerJoin
|
||||
{
|
||||
public:
|
||||
@ -66,7 +64,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
// TODO: not mutating input keys and values?
|
||||
template <typename Key, typename Value1, typename Value2>
|
||||
@ -89,9 +87,8 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> counts;
|
||||
Algorithm::Transform(ubs, lbs, counts, vtkm::Subtract());
|
||||
|
||||
vtkm::worklet::ScatterCounting scatter{ counts, DeviceAdapter() };
|
||||
vtkm::worklet::ScatterCounting scatter{ counts };
|
||||
vtkm::worklet::DispatcherMapField<Merge> mergeDisp(scatter);
|
||||
mergeDisp.SetDevice(DeviceAdapter());
|
||||
mergeDisp.Invoke(key1, value1, lbs, value2, keyOut, value1Out, value2Out);
|
||||
}
|
||||
};
|
||||
|
@ -178,11 +178,11 @@ struct ScaleBiasFunctor
|
||||
T operator()(T value) const { return (Scale * value + Bias); }
|
||||
};
|
||||
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
template <typename T, typename StorageType>
|
||||
class CosmoTools
|
||||
{
|
||||
public:
|
||||
using DeviceAlgorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using DeviceAlgorithm = vtkm::cont::Algorithm;
|
||||
const vtkm::Id NUM_NEIGHBORS = 9;
|
||||
|
||||
// geometry of domain
|
||||
@ -254,14 +254,14 @@ public:
|
||||
// Constructor for all particles in the system
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
CosmoTools<T, StorageType, DeviceAdapter>::CosmoTools(const vtkm::Id NParticles,
|
||||
const T mass,
|
||||
const vtkm::Id pmin,
|
||||
const T bb,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& X,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& Y,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& Z)
|
||||
template <typename T, typename StorageType>
|
||||
CosmoTools<T, StorageType>::CosmoTools(const vtkm::Id NParticles,
|
||||
const T mass,
|
||||
const vtkm::Id pmin,
|
||||
const T bb,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& X,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& Y,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& Z)
|
||||
: nParticles(NParticles)
|
||||
, particleMass(mass)
|
||||
, minPartPerHalo(pmin)
|
||||
@ -277,12 +277,12 @@ CosmoTools<T, StorageType, DeviceAdapter>::CosmoTools(const vtkm::Id NParticles,
|
||||
// Constructor for particles in a single halo
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
CosmoTools<T, StorageType, DeviceAdapter>::CosmoTools(const vtkm::Id NParticles,
|
||||
const T mass,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& X,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& Y,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& Z)
|
||||
template <typename T, typename StorageType>
|
||||
CosmoTools<T, StorageType>::CosmoTools(const vtkm::Id NParticles,
|
||||
const T mass,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& X,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& Y,
|
||||
vtkm::cont::ArrayHandle<T, StorageType>& Z)
|
||||
: nParticles(NParticles)
|
||||
, particleMass(mass)
|
||||
, minPartPerHalo(10)
|
||||
|
@ -77,8 +77,8 @@ namespace cosmotools
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderMxN(T* mxnPotential)
|
||||
template <typename T, typename StorageType>
|
||||
vtkm::Id CosmoTools<T, StorageType>::MBPCenterFinderMxN(T* mxnPotential)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> partId;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> binId;
|
||||
@ -129,7 +129,6 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderMxN(T* mxnPot
|
||||
ComputePotentialBin<T> computePotentialBin(uniqueBins.GetNumberOfValues(), particleMass, linkLen);
|
||||
vtkm::worklet::DispatcherMapField<ComputePotentialBin<T>> computePotentialBinDispatcher(
|
||||
computePotentialBin);
|
||||
computePotentialBinDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
computePotentialBinDispatcher.Invoke(uniqueIndex, // input
|
||||
partPerBin, // input (whole array)
|
||||
@ -160,7 +159,6 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderMxN(T* mxnPot
|
||||
SetCandidateParticles<T> setCandidateParticles(cutoffPotential);
|
||||
vtkm::worklet::DispatcherMapField<SetCandidateParticles<T>> setCandidateParticlesDispatcher(
|
||||
setCandidateParticles);
|
||||
setCandidateParticlesDispatcher.SetDevice(DeviceAdapter());
|
||||
setCandidateParticlesDispatcher.Invoke(bestEstPotential, // input
|
||||
particleOffset, // input
|
||||
partPerBin, // input
|
||||
@ -175,7 +173,6 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderMxN(T* mxnPot
|
||||
ComputePotentialOnCandidates<T> computePotentialOnCandidates(nParticles, particleMass);
|
||||
vtkm::worklet::DispatcherMapField<ComputePotentialOnCandidates<T>>
|
||||
computePotentialOnCandidatesDispatcher(computePotentialOnCandidates);
|
||||
computePotentialOnCandidatesDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
computePotentialOnCandidatesDispatcher.Invoke(mparticles,
|
||||
xLoc, // input (whole array)
|
||||
@ -202,16 +199,15 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderMxN(T* mxnPot
|
||||
// Bin particles in one halo for quick MBP finding
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesHalo(
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& partId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& uniqueBins,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& partPerBin,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& particleOffset,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binX,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binY,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binZ)
|
||||
template <typename T, typename StorageType>
|
||||
void CosmoTools<T, StorageType>::BinParticlesHalo(vtkm::cont::ArrayHandle<vtkm::Id>& partId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& uniqueBins,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& partPerBin,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& particleOffset,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binX,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binY,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binZ)
|
||||
{
|
||||
// Compute number of bins and ranges for each bin
|
||||
vtkm::Vec<T, 2> xRange(xLoc.GetPortalConstControl().Get(0));
|
||||
@ -259,7 +255,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesHalo(
|
||||
numBinsY,
|
||||
numBinsZ); // Size of superimposed mesh
|
||||
vtkm::worklet::DispatcherMapField<ComputeBins<T>> computeBinsDispatcher(computeBins);
|
||||
computeBinsDispatcher.SetDevice(DeviceAdapter());
|
||||
computeBinsDispatcher.Invoke(xLoc, // input
|
||||
yLoc, // input
|
||||
zLoc, // input
|
||||
@ -290,11 +285,9 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesHalo(
|
||||
#endif
|
||||
|
||||
// Calculate the bin indices
|
||||
vtkm::cont::ArrayHandleIndex uniqueIndex(uniqueBins.GetNumberOfValues());
|
||||
ComputeBinIndices<T> computeBinIndices(numBinsX, numBinsY, numBinsZ);
|
||||
vtkm::worklet::DispatcherMapField<ComputeBinIndices<T>> computeBinIndicesDispatcher(
|
||||
computeBinIndices);
|
||||
computeBinIndicesDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
computeBinIndicesDispatcher.Invoke(uniqueBins, // input
|
||||
binX, // input
|
||||
@ -312,11 +305,10 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesHalo(
|
||||
// Method uses ScanInclusiveByKey() and ArrayHandleReverse
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByKey(
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& keyId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& partId,
|
||||
vtkm::cont::ArrayHandle<T>& minPotential)
|
||||
template <typename T, typename StorageType>
|
||||
void CosmoTools<T, StorageType>::MBPCenterFindingByKey(vtkm::cont::ArrayHandle<vtkm::Id>& keyId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& partId,
|
||||
vtkm::cont::ArrayHandle<T>& minPotential)
|
||||
{
|
||||
// Compute starting and ending indices of each key (bin or halo)
|
||||
vtkm::cont::ArrayHandleIndex indexArray(nParticles);
|
||||
@ -335,13 +327,11 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByKey(
|
||||
ComputeNeighborBins computeNeighborBins(numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS);
|
||||
vtkm::worklet::DispatcherMapField<ComputeNeighborBins> computeNeighborBinsDispatcher(
|
||||
computeNeighborBins);
|
||||
computeNeighborBinsDispatcher.SetDevice(DeviceAdapter());
|
||||
computeNeighborBinsDispatcher.Invoke(countArray, keyId, leftNeighbor);
|
||||
|
||||
// Compute indices of all right neighbor bins
|
||||
ComputeBinRange computeBinRange(numBinsX);
|
||||
vtkm::worklet::DispatcherMapField<ComputeBinRange> computeBinRangeDispatcher(computeBinRange);
|
||||
computeBinRangeDispatcher.SetDevice(DeviceAdapter());
|
||||
computeBinRangeDispatcher.Invoke(leftNeighbor, rightNeighbor);
|
||||
|
||||
// Convert bin range to particle range within the bins
|
||||
@ -358,7 +348,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByKey(
|
||||
numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS, particleMass);
|
||||
vtkm::worklet::DispatcherMapField<ComputePotentialNeighbors<T>>
|
||||
computePotentialNeighborsDispatcher(computePotentialNeighbors);
|
||||
computePotentialNeighborsDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
computePotentialNeighborsDispatcher.Invoke(indexArray,
|
||||
keyId, // input (whole array)
|
||||
@ -383,7 +372,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByKey(
|
||||
EqualsMinimumPotential<T> equalsMinimumPotential;
|
||||
vtkm::worklet::DispatcherMapField<EqualsMinimumPotential<T>> equalsMinimumPotentialDispatcher(
|
||||
equalsMinimumPotential);
|
||||
equalsMinimumPotentialDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
equalsMinimumPotentialDispatcher.Invoke(partId, potential, minPotential, centerId);
|
||||
}
|
||||
@ -395,8 +383,8 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByKey(
|
||||
// Method uses ScanInclusiveByKey() and ArrayHandleReverse
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderNxN(T* nxnPotential)
|
||||
template <typename T, typename StorageType>
|
||||
vtkm::Id CosmoTools<T, StorageType>::MBPCenterFinderNxN(T* nxnPotential)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> potential;
|
||||
vtkm::cont::ArrayHandle<T> minPotential;
|
||||
@ -409,7 +397,6 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderNxN(T* nxnPot
|
||||
ComputePotentialNxN<T> computePotentialHalo(nParticles, particleMass);
|
||||
vtkm::worklet::DispatcherMapField<ComputePotentialNxN<T>> computePotentialHaloDispatcher(
|
||||
computePotentialHalo);
|
||||
computePotentialHaloDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
computePotentialHaloDispatcher.Invoke(particleIndex, // input
|
||||
xLoc, // input (whole array)
|
||||
@ -426,7 +413,6 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderNxN(T* nxnPot
|
||||
EqualsMinimumPotential<T> equalsMinimumPotential;
|
||||
vtkm::worklet::DispatcherMapField<EqualsMinimumPotential<T>> equalsMinimumPotentialDispatcher(
|
||||
equalsMinimumPotential);
|
||||
equalsMinimumPotentialDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
equalsMinimumPotentialDispatcher.Invoke(particleIndex, potential, minPotential, centerId);
|
||||
|
||||
|
@ -76,11 +76,10 @@ namespace cosmotools
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& resultHaloId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& resultMBP,
|
||||
vtkm::cont::ArrayHandle<T>& resultPot)
|
||||
template <typename T, typename StorageType>
|
||||
void CosmoTools<T, StorageType>::HaloFinder(vtkm::cont::ArrayHandle<vtkm::Id>& resultHaloId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& resultMBP,
|
||||
vtkm::cont::ArrayHandle<T>& resultPot)
|
||||
{
|
||||
// Package locations for worklets
|
||||
using CompositeLocationType =
|
||||
@ -109,7 +108,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
|
||||
MarkActiveNeighbors<T> markActiveNeighbors(numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS, linkLen);
|
||||
vtkm::worklet::DispatcherMapField<MarkActiveNeighbors<T>> markActiveNeighborsDispatcher(
|
||||
markActiveNeighbors);
|
||||
markActiveNeighborsDispatcher.SetDevice(DeviceAdapter());
|
||||
markActiveNeighborsDispatcher.Invoke(
|
||||
indexArray, // (input) index into all particles
|
||||
partId, // (input) particle id sorted by bin
|
||||
@ -135,7 +133,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
|
||||
// Connect each particle to another close particle to build halos
|
||||
GraftParticles<T> graftParticles(numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS, linkLen);
|
||||
vtkm::worklet::DispatcherMapField<GraftParticles<T>> graftParticlesDispatcher(graftParticles);
|
||||
graftParticlesDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
graftParticlesDispatcher.Invoke(indexArray, // (input) index into particles
|
||||
partId, // (input) particle id sorted by bin
|
||||
@ -157,7 +154,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
|
||||
// determine if any particles are still migrating to halos
|
||||
IsStar isStar;
|
||||
vtkm::worklet::DispatcherMapField<IsStar> isStarDispatcher(isStar);
|
||||
isStarDispatcher.SetDevice(DeviceAdapter());
|
||||
isStarDispatcher.Invoke(indexArray,
|
||||
haloIdCurrent, // input (whole array)
|
||||
haloIdLast, // input (whole array)
|
||||
@ -174,7 +170,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
|
||||
{
|
||||
PointerJump pointerJump;
|
||||
vtkm::worklet::DispatcherMapField<PointerJump> pointerJumpDispatcher(pointerJump);
|
||||
pointerJumpDispatcher.SetDevice(DeviceAdapter());
|
||||
pointerJumpDispatcher.Invoke(indexArray, haloIdCurrent); // input (whole array)
|
||||
DeviceAlgorithm::Copy(haloIdCurrent, haloIdLast);
|
||||
}
|
||||
@ -198,12 +193,11 @@ void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
|
||||
// Bin all particles in the system for halo finding
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesAll(
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& partId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& leftNeighbor,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& rightNeighbor)
|
||||
template <typename T, typename StorageType>
|
||||
void CosmoTools<T, StorageType>::BinParticlesAll(vtkm::cont::ArrayHandle<vtkm::Id>& partId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& binId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& leftNeighbor,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& rightNeighbor)
|
||||
{
|
||||
// Compute number of bins and ranges for each bin
|
||||
vtkm::Vec<T, 2> result;
|
||||
@ -246,7 +240,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesAll(
|
||||
numBinsY,
|
||||
numBinsZ); // Size of superimposed mesh
|
||||
vtkm::worklet::DispatcherMapField<ComputeBins<T>> computeBinsDispatcher(computeBins);
|
||||
computeBinsDispatcher.SetDevice(DeviceAdapter());
|
||||
computeBinsDispatcher.Invoke(xLoc, // input
|
||||
yLoc, // input
|
||||
zLoc, // input
|
||||
@ -279,13 +272,11 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesAll(
|
||||
ComputeNeighborBins computeNeighborBins(numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS);
|
||||
vtkm::worklet::DispatcherMapField<ComputeNeighborBins> computeNeighborBinsDispatcher(
|
||||
computeNeighborBins);
|
||||
computeNeighborBinsDispatcher.SetDevice(DeviceAdapter());
|
||||
computeNeighborBinsDispatcher.Invoke(countArray, binId, leftNeighbor);
|
||||
|
||||
// Compute indices of all right neighbor bins
|
||||
ComputeBinRange computeBinRange(numBinsX);
|
||||
vtkm::worklet::DispatcherMapField<ComputeBinRange> computeBinRangeDispatcher(computeBinRange);
|
||||
computeBinRangeDispatcher.SetDevice(DeviceAdapter());
|
||||
computeBinRangeDispatcher.Invoke(leftNeighbor, rightNeighbor);
|
||||
|
||||
// Convert bin range to particle range within the bins
|
||||
@ -300,12 +291,11 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesAll(
|
||||
// Method uses ReduceByKey() and Scatter()
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T, typename StorageType, typename DeviceAdapter>
|
||||
void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByHalo(
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& partId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& haloId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& mbpId,
|
||||
vtkm::cont::ArrayHandle<T>& minPotential)
|
||||
template <typename T, typename StorageType>
|
||||
void CosmoTools<T, StorageType>::MBPCenterFindingByHalo(vtkm::cont::ArrayHandle<vtkm::Id>& partId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& haloId,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& mbpId,
|
||||
vtkm::cont::ArrayHandle<T>& minPotential)
|
||||
{
|
||||
// Sort particles into groups according to halo id using an index into WholeArrays
|
||||
DeviceAlgorithm::SortByKey(haloId, partId);
|
||||
@ -335,10 +325,9 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByHalo(
|
||||
#endif
|
||||
|
||||
// Setup the ScatterCounting worklets needed to expand the ReduceByKeyResults
|
||||
vtkm::worklet::ScatterCounting scatter(particlesPerHalo, DeviceAdapter());
|
||||
vtkm::worklet::ScatterCounting scatter(particlesPerHalo);
|
||||
vtkm::worklet::DispatcherMapField<ScatterWorklet<vtkm::Id>> scatterWorkletIdDispatcher(scatter);
|
||||
vtkm::worklet::DispatcherMapField<ScatterWorklet<T>> scatterWorkletDispatcher(scatter);
|
||||
scatterWorkletDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
// Calculate the minimum particle index per halo id and scatter
|
||||
DeviceAlgorithm::ScanExclusive(particlesPerHalo, tempI);
|
||||
@ -363,7 +352,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByHalo(
|
||||
ComputePotential<T> computePotential(particleMass);
|
||||
vtkm::worklet::DispatcherMapField<ComputePotential<T>> computePotentialDispatcher(
|
||||
computePotential);
|
||||
computePotentialDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
computePotentialDispatcher.Invoke(indexArray,
|
||||
partId, // input (whole array)
|
||||
@ -386,7 +374,6 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByHalo(
|
||||
EqualsMinimumPotential<T> equalsMinimumPotential;
|
||||
vtkm::worklet::DispatcherMapField<EqualsMinimumPotential<T>> equalsMinimumPotentialDispatcher(
|
||||
equalsMinimumPotential);
|
||||
equalsMinimumPotentialDispatcher.SetDevice(DeviceAdapter());
|
||||
|
||||
equalsMinimumPotentialDispatcher.Invoke(partId, potential, minPotential, mbpId);
|
||||
|
||||
|
@ -22,10 +22,10 @@
|
||||
#define vtk_m_worklet_KdTree3DConstruction_h
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/ArrayHandleReverse.h>
|
||||
#include <vtkm/cont/DeviceAdapter.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/arg/ControlSignatureTagBase.h>
|
||||
#include <vtkm/cont/serial/DeviceAdapterSerial.h>
|
||||
@ -228,13 +228,12 @@ public:
|
||||
};
|
||||
|
||||
////////// General worklet WRAPPER for Kd-tree //////
|
||||
template <typename T, class BinaryFunctor, typename DeviceAdapter>
|
||||
template <typename T, class BinaryFunctor>
|
||||
vtkm::cont::ArrayHandle<T> ReverseScanInclusiveByKey(vtkm::cont::ArrayHandle<T>& keyHandle,
|
||||
vtkm::cont::ArrayHandle<T>& dataHandle,
|
||||
BinaryFunctor binary_functor,
|
||||
DeviceAdapter vtkmNotUsed(device))
|
||||
BinaryFunctor binary_functor)
|
||||
{
|
||||
using Algorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
vtkm::cont::ArrayHandle<T> resultHandle;
|
||||
|
||||
@ -248,82 +247,71 @@ public:
|
||||
return resultHandle;
|
||||
}
|
||||
|
||||
template <typename T, typename DeviceAdapter>
|
||||
vtkm::cont::ArrayHandle<T> Inverse01ArrayWrapper(vtkm::cont::ArrayHandle<T>& inputHandle,
|
||||
DeviceAdapter vtkmNotUsed(device))
|
||||
template <typename T>
|
||||
vtkm::cont::ArrayHandle<T> Inverse01ArrayWrapper(vtkm::cont::ArrayHandle<T>& inputHandle)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> InverseHandle;
|
||||
InverseArray invWorklet;
|
||||
vtkm::worklet::DispatcherMapField<InverseArray> inverseArrayDispatcher(invWorklet);
|
||||
inverseArrayDispatcher.SetDevice(DeviceAdapter());
|
||||
inverseArrayDispatcher.Invoke(inputHandle, InverseHandle);
|
||||
return InverseHandle;
|
||||
}
|
||||
|
||||
template <typename T, typename DeviceAdapter>
|
||||
template <typename T>
|
||||
vtkm::cont::ArrayHandle<T> ScatterArrayWrapper(vtkm::cont::ArrayHandle<T>& inputHandle,
|
||||
vtkm::cont::ArrayHandle<T>& indexHandle,
|
||||
DeviceAdapter vtkmNotUsed(device))
|
||||
vtkm::cont::ArrayHandle<T>& indexHandle)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> outputHandle;
|
||||
outputHandle.Allocate(inputHandle.GetNumberOfValues());
|
||||
ScatterArray scatterWorklet;
|
||||
vtkm::worklet::DispatcherMapField<ScatterArray> scatterArrayDispatcher(scatterWorklet);
|
||||
scatterArrayDispatcher.SetDevice(DeviceAdapter());
|
||||
scatterArrayDispatcher.Invoke(inputHandle, indexHandle, outputHandle);
|
||||
return outputHandle;
|
||||
}
|
||||
|
||||
template <typename T, typename DeviceAdapter>
|
||||
template <typename T>
|
||||
vtkm::cont::ArrayHandle<T> NewKeyWrapper(vtkm::cont::ArrayHandle<T>& oldSegIdHandle,
|
||||
vtkm::cont::ArrayHandle<T>& flagHandle,
|
||||
DeviceAdapter vtkmNotUsed(device))
|
||||
vtkm::cont::ArrayHandle<T>& flagHandle)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> newSegIdHandle;
|
||||
NewSegmentId newsegidWorklet;
|
||||
vtkm::worklet::DispatcherMapField<NewSegmentId> newSegIdDispatcher(newsegidWorklet);
|
||||
newSegIdDispatcher.SetDevice(DeviceAdapter());
|
||||
newSegIdDispatcher.Invoke(oldSegIdHandle, flagHandle, newSegIdHandle);
|
||||
return newSegIdHandle;
|
||||
}
|
||||
|
||||
template <typename T, typename DeviceAdapter>
|
||||
template <typename T>
|
||||
vtkm::cont::ArrayHandle<T> SaveSplitPointIdWrapper(vtkm::cont::ArrayHandle<T>& pointIdHandle,
|
||||
vtkm::cont::ArrayHandle<T>& flagHandle,
|
||||
vtkm::cont::ArrayHandle<T>& rankHandle,
|
||||
vtkm::cont::ArrayHandle<T>& oldSplitIdHandle,
|
||||
DeviceAdapter device)
|
||||
vtkm::cont::ArrayHandle<T>& oldSplitIdHandle)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> splitIdInSegmentHandle;
|
||||
FindSplitPointId findSplitPointIdWorklet;
|
||||
vtkm::worklet::DispatcherMapField<FindSplitPointId> findSplitPointIdWorkletDispatcher(
|
||||
findSplitPointIdWorklet);
|
||||
findSplitPointIdWorkletDispatcher.SetDevice(DeviceAdapter());
|
||||
findSplitPointIdWorkletDispatcher.Invoke(pointIdHandle, rankHandle, splitIdInSegmentHandle);
|
||||
|
||||
vtkm::cont::ArrayHandle<T> splitIdInSegmentByScanHandle =
|
||||
ReverseScanInclusiveByKey(flagHandle, splitIdInSegmentHandle, vtkm::Maximum(), device);
|
||||
ReverseScanInclusiveByKey(flagHandle, splitIdInSegmentHandle, vtkm::Maximum());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> splitIdHandle;
|
||||
SaveSplitPointId saveSplitPointIdWorklet;
|
||||
vtkm::worklet::DispatcherMapField<SaveSplitPointId> saveSplitPointIdWorkletDispatcher(
|
||||
saveSplitPointIdWorklet);
|
||||
saveSplitPointIdWorkletDispatcher.SetDevice(DeviceAdapter());
|
||||
saveSplitPointIdWorkletDispatcher.Invoke(
|
||||
splitIdInSegmentByScanHandle, flagHandle, oldSplitIdHandle, splitIdHandle);
|
||||
|
||||
return splitIdHandle;
|
||||
}
|
||||
|
||||
template <typename T, typename DeviceAdapter>
|
||||
template <typename T>
|
||||
vtkm::cont::ArrayHandle<T> ArrayAddWrapper(vtkm::cont::ArrayHandle<T>& array0Handle,
|
||||
vtkm::cont::ArrayHandle<T>& array1Handle,
|
||||
DeviceAdapter vtkmNotUsed(device))
|
||||
vtkm::cont::ArrayHandle<T>& array1Handle)
|
||||
{
|
||||
vtkm::cont::ArrayHandle<T> resultHandle;
|
||||
ArrayAdd arrayAddWorklet;
|
||||
vtkm::worklet::DispatcherMapField<ArrayAdd> arrayAddDispatcher(arrayAddWorklet);
|
||||
arrayAddDispatcher.SetDevice(DeviceAdapter());
|
||||
arrayAddDispatcher.Invoke(array0Handle, array1Handle, resultHandle);
|
||||
return resultHandle;
|
||||
}
|
||||
@ -331,12 +319,11 @@ public:
|
||||
///////////////////////////////////////////////////
|
||||
////////General Kd tree function //////////////////
|
||||
///////////////////////////////////////////////////
|
||||
template <typename T, typename DeviceAdapter>
|
||||
template <typename T>
|
||||
vtkm::cont::ArrayHandle<T> ComputeFlagProcedure(vtkm::cont::ArrayHandle<T>& rankHandle,
|
||||
vtkm::cont::ArrayHandle<T>& segIdHandle,
|
||||
DeviceAdapter device)
|
||||
vtkm::cont::ArrayHandle<T>& segIdHandle)
|
||||
{
|
||||
using Algorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
vtkm::cont::ArrayHandle<T> segCountAryHandle;
|
||||
{
|
||||
@ -345,25 +332,22 @@ public:
|
||||
Algorithm::ScanInclusiveByKey(
|
||||
segIdHandle, constHandle, tmpAryHandle, vtkm::Add()); //compute ttl segs in segment
|
||||
|
||||
segCountAryHandle =
|
||||
ReverseScanInclusiveByKey(segIdHandle, tmpAryHandle, vtkm::Maximum(), device);
|
||||
segCountAryHandle = ReverseScanInclusiveByKey(segIdHandle, tmpAryHandle, vtkm::Maximum());
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<T> flagHandle;
|
||||
vtkm::worklet::DispatcherMapField<ComputeFlag> computeFlagDispatcher;
|
||||
computeFlagDispatcher.SetDevice(DeviceAdapter());
|
||||
computeFlagDispatcher.Invoke(rankHandle, segCountAryHandle, flagHandle);
|
||||
|
||||
return flagHandle;
|
||||
}
|
||||
|
||||
template <typename T, typename DeviceAdapter>
|
||||
template <typename T>
|
||||
vtkm::cont::ArrayHandle<T> SegmentedSplitProcedure(vtkm::cont::ArrayHandle<T>& A_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& B_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& C_Handle,
|
||||
DeviceAdapter device)
|
||||
vtkm::cont::ArrayHandle<T>& C_Handle)
|
||||
{
|
||||
using Algorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
vtkm::cont::ArrayHandle<T> D_Handle;
|
||||
T initValue = 0;
|
||||
@ -376,32 +360,30 @@ public:
|
||||
vtkm::cont::ArrayHandle<T> F_Handle;
|
||||
Algorithm::ScanInclusiveByKey(C_Handle, E_Handle, F_Handle, vtkm::Minimum());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> InvB_Handle = Inverse01ArrayWrapper(B_Handle, device);
|
||||
vtkm::cont::ArrayHandle<T> InvB_Handle = Inverse01ArrayWrapper(B_Handle);
|
||||
vtkm::cont::ArrayHandle<T> G_Handle;
|
||||
Algorithm::ScanInclusiveByKey(C_Handle, InvB_Handle, G_Handle, vtkm::Add());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> H_Handle =
|
||||
ReverseScanInclusiveByKey(C_Handle, G_Handle, vtkm::Maximum(), device);
|
||||
ReverseScanInclusiveByKey(C_Handle, G_Handle, vtkm::Maximum());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> I_Handle;
|
||||
SegmentedSplitTransform sstWorklet;
|
||||
vtkm::worklet::DispatcherMapField<SegmentedSplitTransform> segmentedSplitTransformDispatcher(
|
||||
sstWorklet);
|
||||
segmentedSplitTransformDispatcher.SetDevice(DeviceAdapter());
|
||||
segmentedSplitTransformDispatcher.Invoke(
|
||||
B_Handle, D_Handle, F_Handle, G_Handle, H_Handle, I_Handle);
|
||||
|
||||
return ScatterArrayWrapper(A_Handle, I_Handle, device);
|
||||
return ScatterArrayWrapper(A_Handle, I_Handle);
|
||||
}
|
||||
|
||||
template <typename T, typename DeviceAdapter>
|
||||
template <typename T>
|
||||
void RenumberRanksProcedure(vtkm::cont::ArrayHandle<T>& A_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& B_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& C_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& D_Handle,
|
||||
DeviceAdapter device)
|
||||
vtkm::cont::ArrayHandle<T>& D_Handle)
|
||||
{
|
||||
using Algorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
vtkm::Id nPoints = A_Handle.GetNumberOfValues();
|
||||
|
||||
@ -413,7 +395,7 @@ public:
|
||||
Algorithm::ScanInclusiveByKey(D_Handle, E_Handle, F_Handle, vtkm::Minimum());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> G_Handle;
|
||||
G_Handle = ArrayAddWrapper(A_Handle, F_Handle, device);
|
||||
G_Handle = ArrayAddWrapper(A_Handle, F_Handle);
|
||||
|
||||
vtkm::cont::ArrayHandleConstant<T> HConstant_Handle(1, nPoints);
|
||||
vtkm::cont::ArrayHandle<T> H_Handle;
|
||||
@ -424,21 +406,21 @@ public:
|
||||
Algorithm::ScanExclusiveByKey(C_Handle, H_Handle, I_Handle, initValue, vtkm::Add());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> J_Handle;
|
||||
J_Handle = ScatterArrayWrapper(I_Handle, G_Handle, device);
|
||||
J_Handle = ScatterArrayWrapper(I_Handle, G_Handle);
|
||||
|
||||
vtkm::cont::ArrayHandle<T> K_Handle;
|
||||
K_Handle = ScatterArrayWrapper(B_Handle, G_Handle, device);
|
||||
K_Handle = ScatterArrayWrapper(B_Handle, G_Handle);
|
||||
|
||||
vtkm::cont::ArrayHandle<T> L_Handle;
|
||||
L_Handle = SegmentedSplitProcedure(J_Handle, K_Handle, D_Handle, device);
|
||||
L_Handle = SegmentedSplitProcedure(J_Handle, K_Handle, D_Handle);
|
||||
|
||||
vtkm::cont::ArrayHandle<T> M_Handle;
|
||||
Algorithm::ScanInclusiveByKey(C_Handle, E_Handle, M_Handle, vtkm::Minimum());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> N_Handle;
|
||||
N_Handle = ArrayAddWrapper(L_Handle, M_Handle, device);
|
||||
N_Handle = ArrayAddWrapper(L_Handle, M_Handle);
|
||||
|
||||
A_Handle = ScatterArrayWrapper(I_Handle, N_Handle, device);
|
||||
A_Handle = ScatterArrayWrapper(I_Handle, N_Handle);
|
||||
}
|
||||
|
||||
/////////////3D construction /////////////////////
|
||||
@ -448,24 +430,21 @@ public:
|
||||
/// as indicated by \c segId_Handle according to flags in \c flag_Handle.
|
||||
///
|
||||
/// \tparam T
|
||||
/// \tparam DeviceAdapter
|
||||
/// \param pointId_Handle
|
||||
/// \param flag_Handle
|
||||
/// \param segId_Handle
|
||||
/// \param X_Handle
|
||||
/// \param Y_Handle
|
||||
/// \param Z_Handle
|
||||
/// \param device
|
||||
template <typename T, typename DeviceAdapter>
|
||||
template <typename T>
|
||||
void SegmentedSplitProcedure3D(vtkm::cont::ArrayHandle<T>& pointId_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& flag_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& segId_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& X_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& Y_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& Z_Handle,
|
||||
DeviceAdapter device)
|
||||
vtkm::cont::ArrayHandle<T>& Z_Handle)
|
||||
{
|
||||
using Algorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
vtkm::cont::ArrayHandle<T> D_Handle;
|
||||
T initValue = 0;
|
||||
@ -478,30 +457,29 @@ public:
|
||||
vtkm::cont::ArrayHandle<T> F_Handle;
|
||||
Algorithm::ScanInclusiveByKey(segId_Handle, E_Handle, F_Handle, vtkm::Minimum());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> InvB_Handle = Inverse01ArrayWrapper(flag_Handle, device);
|
||||
vtkm::cont::ArrayHandle<T> InvB_Handle = Inverse01ArrayWrapper(flag_Handle);
|
||||
vtkm::cont::ArrayHandle<T> G_Handle;
|
||||
Algorithm::ScanInclusiveByKey(segId_Handle, InvB_Handle, G_Handle, vtkm::Add());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> H_Handle =
|
||||
ReverseScanInclusiveByKey(segId_Handle, G_Handle, vtkm::Maximum(), device);
|
||||
ReverseScanInclusiveByKey(segId_Handle, G_Handle, vtkm::Maximum());
|
||||
|
||||
vtkm::cont::ArrayHandle<T> I_Handle;
|
||||
SegmentedSplitTransform sstWorklet;
|
||||
vtkm::worklet::DispatcherMapField<SegmentedSplitTransform> segmentedSplitTransformDispatcher(
|
||||
sstWorklet);
|
||||
segmentedSplitTransformDispatcher.SetDevice(DeviceAdapter());
|
||||
segmentedSplitTransformDispatcher.Invoke(
|
||||
flag_Handle, D_Handle, F_Handle, G_Handle, H_Handle, I_Handle);
|
||||
|
||||
pointId_Handle = ScatterArrayWrapper(pointId_Handle, I_Handle, device);
|
||||
pointId_Handle = ScatterArrayWrapper(pointId_Handle, I_Handle);
|
||||
|
||||
flag_Handle = ScatterArrayWrapper(flag_Handle, I_Handle, device);
|
||||
flag_Handle = ScatterArrayWrapper(flag_Handle, I_Handle);
|
||||
|
||||
X_Handle = ScatterArrayWrapper(X_Handle, I_Handle, device);
|
||||
X_Handle = ScatterArrayWrapper(X_Handle, I_Handle);
|
||||
|
||||
Y_Handle = ScatterArrayWrapper(Y_Handle, I_Handle, device);
|
||||
Y_Handle = ScatterArrayWrapper(Y_Handle, I_Handle);
|
||||
|
||||
Z_Handle = ScatterArrayWrapper(Z_Handle, I_Handle, device);
|
||||
Z_Handle = ScatterArrayWrapper(Z_Handle, I_Handle);
|
||||
}
|
||||
|
||||
/// \brief Perform one level of KD-Tree construction
|
||||
@ -510,57 +488,56 @@ public:
|
||||
/// \c xrank_Handle, \c yrank_Handle and \c zrank_Handle according to the medium element
|
||||
/// in each segment as indicated by \c segId_Handle alone the axis determined by \c level.
|
||||
/// The split point of each segment will be updated in \c splitId_Handle.
|
||||
template <typename T, typename DeviceAdapter>
|
||||
template <typename T>
|
||||
void OneLevelSplit3D(vtkm::cont::ArrayHandle<T>& pointId_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& xrank_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& yrank_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& zrank_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& segId_Handle,
|
||||
vtkm::cont::ArrayHandle<T>& splitId_Handle,
|
||||
vtkm::Int32 level,
|
||||
DeviceAdapter device)
|
||||
vtkm::Int32 level)
|
||||
{
|
||||
using Algorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
vtkm::cont::ArrayHandle<T> flag_Handle;
|
||||
if (level % 3 == 0)
|
||||
{
|
||||
flag_Handle = ComputeFlagProcedure(xrank_Handle, segId_Handle, device);
|
||||
flag_Handle = ComputeFlagProcedure(xrank_Handle, segId_Handle);
|
||||
}
|
||||
else if (level % 3 == 1)
|
||||
{
|
||||
flag_Handle = ComputeFlagProcedure(yrank_Handle, segId_Handle, device);
|
||||
flag_Handle = ComputeFlagProcedure(yrank_Handle, segId_Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
flag_Handle = ComputeFlagProcedure(zrank_Handle, segId_Handle, device);
|
||||
flag_Handle = ComputeFlagProcedure(zrank_Handle, segId_Handle);
|
||||
}
|
||||
|
||||
SegmentedSplitProcedure3D(
|
||||
pointId_Handle, flag_Handle, segId_Handle, xrank_Handle, yrank_Handle, zrank_Handle, device);
|
||||
pointId_Handle, flag_Handle, segId_Handle, xrank_Handle, yrank_Handle, zrank_Handle);
|
||||
|
||||
vtkm::cont::ArrayHandle<T> segIdOld_Handle;
|
||||
Algorithm::Copy(segId_Handle, segIdOld_Handle);
|
||||
segId_Handle = NewKeyWrapper(segIdOld_Handle, flag_Handle, device);
|
||||
segId_Handle = NewKeyWrapper(segIdOld_Handle, flag_Handle);
|
||||
|
||||
RenumberRanksProcedure(xrank_Handle, flag_Handle, segId_Handle, segIdOld_Handle, device);
|
||||
RenumberRanksProcedure(yrank_Handle, flag_Handle, segId_Handle, segIdOld_Handle, device);
|
||||
RenumberRanksProcedure(zrank_Handle, flag_Handle, segId_Handle, segIdOld_Handle, device);
|
||||
RenumberRanksProcedure(xrank_Handle, flag_Handle, segId_Handle, segIdOld_Handle);
|
||||
RenumberRanksProcedure(yrank_Handle, flag_Handle, segId_Handle, segIdOld_Handle);
|
||||
RenumberRanksProcedure(zrank_Handle, flag_Handle, segId_Handle, segIdOld_Handle);
|
||||
|
||||
if (level % 3 == 0)
|
||||
{
|
||||
splitId_Handle =
|
||||
SaveSplitPointIdWrapper(pointId_Handle, flag_Handle, xrank_Handle, splitId_Handle, device);
|
||||
SaveSplitPointIdWrapper(pointId_Handle, flag_Handle, xrank_Handle, splitId_Handle);
|
||||
}
|
||||
else if (level % 3 == 1)
|
||||
{
|
||||
splitId_Handle =
|
||||
SaveSplitPointIdWrapper(pointId_Handle, flag_Handle, yrank_Handle, splitId_Handle, device);
|
||||
SaveSplitPointIdWrapper(pointId_Handle, flag_Handle, yrank_Handle, splitId_Handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
splitId_Handle =
|
||||
SaveSplitPointIdWrapper(pointId_Handle, flag_Handle, zrank_Handle, splitId_Handle, device);
|
||||
SaveSplitPointIdWrapper(pointId_Handle, flag_Handle, zrank_Handle, splitId_Handle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,15 +552,13 @@ public:
|
||||
/// \param coordi_Handle (in) x, y, z coordinates of input points
|
||||
/// \param pointId_Handle (out) returns indices to leaf nodes of the KD-tree
|
||||
/// \param splitId_Handle (out) returns indices to internal nodes of the KD-tree
|
||||
/// \param device the device to run the construction on
|
||||
// Leaf Node vector and internal node (split) vectpr
|
||||
template <typename CoordType, typename CoordStorageTag, typename DeviceAdapter>
|
||||
template <typename CoordType, typename CoordStorageTag>
|
||||
void Run(const vtkm::cont::ArrayHandle<vtkm::Vec<CoordType, 3>, CoordStorageTag>& coordi_Handle,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& pointId_Handle,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& splitId_Handle,
|
||||
DeviceAdapter device)
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& splitId_Handle)
|
||||
{
|
||||
using Algorithm = typename vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
vtkm::Id nTrainingPoints = coordi_Handle.GetNumberOfValues();
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::Id> counting_Handle(0, 1, nTrainingPoints);
|
||||
@ -603,20 +578,19 @@ public:
|
||||
|
||||
SeprateVec3AryHandle sepVec3Worklet;
|
||||
vtkm::worklet::DispatcherMapField<SeprateVec3AryHandle> sepVec3Dispatcher(sepVec3Worklet);
|
||||
sepVec3Dispatcher.SetDevice(DeviceAdapter());
|
||||
sepVec3Dispatcher.Invoke(coordi_Handle, xcoordi_Handle, ycoordi_Handle, zcoordi_Handle);
|
||||
|
||||
Algorithm::SortByKey(xcoordi_Handle, xorder_Handle);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> xrank_Handle =
|
||||
ScatterArrayWrapper(pointId_Handle, xorder_Handle, device);
|
||||
ScatterArrayWrapper(pointId_Handle, xorder_Handle);
|
||||
|
||||
Algorithm::SortByKey(ycoordi_Handle, yorder_Handle);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> yrank_Handle =
|
||||
ScatterArrayWrapper(pointId_Handle, yorder_Handle, device);
|
||||
ScatterArrayWrapper(pointId_Handle, yorder_Handle);
|
||||
|
||||
Algorithm::SortByKey(zcoordi_Handle, zorder_Handle);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> zrank_Handle =
|
||||
ScatterArrayWrapper(pointId_Handle, zorder_Handle, device);
|
||||
ScatterArrayWrapper(pointId_Handle, zorder_Handle);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> segId_Handle;
|
||||
vtkm::cont::ArrayHandleConstant<vtkm::Id> constHandle(0, nTrainingPoints);
|
||||
@ -626,14 +600,8 @@ public:
|
||||
vtkm::Int32 maxLevel = static_cast<vtkm::Int32>(ceil(vtkm::Log2(nTrainingPoints) + 1));
|
||||
for (vtkm::Int32 i = 0; i < maxLevel - 1; i++)
|
||||
{
|
||||
OneLevelSplit3D(pointId_Handle,
|
||||
xrank_Handle,
|
||||
yrank_Handle,
|
||||
zrank_Handle,
|
||||
segId_Handle,
|
||||
splitId_Handle,
|
||||
i,
|
||||
device);
|
||||
OneLevelSplit3D(
|
||||
pointId_Handle, xrank_Handle, yrank_Handle, zrank_Handle, segId_Handle, splitId_Handle, i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCounting.h>
|
||||
#include <vtkm/cont/ArrayHandleReverse.h>
|
||||
@ -203,34 +204,34 @@ public:
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec<CoordType, 3>, CoordStorageTag2>& qc_Handle,
|
||||
vtkm::cont::ArrayHandle<vtkm::Id>& nnId_Handle,
|
||||
vtkm::cont::ArrayHandle<CoordType>& nnDis_Handle,
|
||||
DeviceAdapter)
|
||||
DeviceAdapter id)
|
||||
{
|
||||
//fill the nnDis_Handle handle array with max values before running
|
||||
auto intialValue = std::numeric_limits<CoordType>::max();
|
||||
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::Copy(
|
||||
vtkm::cont::Algorithm::Copy(
|
||||
vtkm::cont::make_ArrayHandleConstant(intialValue, qc_Handle.GetNumberOfValues()),
|
||||
nnDis_Handle);
|
||||
|
||||
//set up stack size for cuda environment
|
||||
#ifdef VTKM_CUDA
|
||||
constexpr DeviceAdapter deviceId;
|
||||
std::size_t stackSizeBackup;
|
||||
(void)stackSizeBackup;
|
||||
if (deviceId.GetValue() == VTKM_DEVICE_ADAPTER_CUDA)
|
||||
if (id.GetValue() == VTKM_DEVICE_ADAPTER_CUDA)
|
||||
{
|
||||
cudaDeviceGetLimit(&stackSizeBackup, cudaLimitStackSize);
|
||||
cudaDeviceSetLimit(cudaLimitStackSize, 1024 * 16);
|
||||
}
|
||||
#else
|
||||
(void)id;
|
||||
#endif
|
||||
|
||||
NearestNeighborSearch3DWorklet nns3dWorklet;
|
||||
vtkm::worklet::DispatcherMapField<NearestNeighborSearch3DWorklet> nns3DDispatcher(nns3dWorklet);
|
||||
nns3DDispatcher.SetDevice(DeviceAdapter());
|
||||
nns3DDispatcher.Invoke(
|
||||
qc_Handle, pointId_Handle, splitId_Handle, coordi_Handle, nnId_Handle, nnDis_Handle);
|
||||
|
||||
#ifdef VTKM_CUDA
|
||||
if (deviceId.GetValue() == VTKM_DEVICE_ADAPTER_CUDA)
|
||||
if (id.GetValue() == VTKM_DEVICE_ADAPTER_CUDA)
|
||||
{
|
||||
cudaDeviceSetLimit(cudaLimitStackSize, stackSizeBackup);
|
||||
}
|
||||
|
@ -86,16 +86,8 @@ set(unit_tests
|
||||
)
|
||||
|
||||
|
||||
vtkm_unit_tests(NAME Worklets BACKEND SERIAL SOURCES ${unit_tests})
|
||||
if (TARGET vtkm::tbb)
|
||||
vtkm_unit_tests(NAME Worklets BACKEND TBB SOURCES ${unit_tests})
|
||||
endif()
|
||||
if (TARGET vtkm::openmp)
|
||||
vtkm_unit_tests(NAME Worklets BACKEND OPENMP SOURCES ${unit_tests})
|
||||
endif()
|
||||
vtkm_unit_tests(NAME Worklets SOURCES ${unit_tests} ALL_BACKENDS)
|
||||
if (TARGET vtkm::cuda)
|
||||
vtkm_unit_tests(NAME Worklets BACKEND CUDA SOURCES ${unit_tests})
|
||||
|
||||
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.0.0)
|
||||
set(particle_cuda_src "${CMAKE_CURRENT_BINARY_DIR}/UnitTestParticleAdvection.cu")
|
||||
set_source_files_properties(${particle_cuda_src} PROPERTIES COMPILE_FLAGS "-Xptxas --opt-level=0")
|
||||
|
@ -76,13 +76,12 @@ void TryKeyType(KeyType)
|
||||
|
||||
// Create Keys object
|
||||
vtkm::cont::ArrayHandle<KeyType> sortedKeys;
|
||||
vtkm::cont::ArrayCopy(keysArray, sortedKeys, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::worklet::Keys<KeyType> keys(sortedKeys, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::cont::ArrayCopy(keysArray, sortedKeys);
|
||||
vtkm::worklet::Keys<KeyType> keys(sortedKeys);
|
||||
VTKM_TEST_ASSERT(keys.GetInputRange() == NUM_UNIQUE, "Keys has bad input range.");
|
||||
|
||||
// Create values array
|
||||
vtkm::cont::ArrayHandleCounting<vtkm::FloatDefault> valuesArray(0.0f, 1.0f, ARRAY_SIZE);
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
|
||||
std::cout << " Try average with Keys object" << std::endl;
|
||||
CheckAverageByKey(keys.GetUniqueKeys(), vtkm::worklet::AverageByKey::Run(keys, valuesArray));
|
||||
@ -105,7 +104,7 @@ void DoTest()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestAverageByKey(int, char* [])
|
||||
int UnitTestAverageByKey(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(DoTest);
|
||||
return vtkm::cont::testing::Testing::Run(DoTest, argc, argv);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayHandleConcatenate.h>
|
||||
#include <vtkm/cont/BoundingIntervalHierarchy.hxx>
|
||||
#include <vtkm/cont/DataSetBuilderUniform.h>
|
||||
@ -69,7 +70,6 @@ vtkm::cont::DataSet ConstructDataSet(vtkm::Id size)
|
||||
void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet, vtkm::IdComponent numPlanes)
|
||||
{
|
||||
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
|
||||
using Algorithms = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Timer = vtkm::cont::Timer<DeviceAdapter>;
|
||||
|
||||
vtkm::cont::DynamicCellSet cellSet = dataSet.GetCellSet();
|
||||
@ -109,7 +109,7 @@ void TestBoundingIntervalHierarchy(vtkm::cont::DataSet dataSet, vtkm::IdComponen
|
||||
#if VTKM_DEVICE_ADAPTER == VTKM_DEVICE_ADAPTER_CUDA
|
||||
cudaDeviceSetLimit(cudaLimitStackSize, stackSizeBackup);
|
||||
#endif
|
||||
vtkm::Id numDiffs = Algorithms::Reduce(results, 0, vtkm::Add());
|
||||
vtkm::Id numDiffs = vtkm::cont::Algorithm::Reduce(results, 0, vtkm::Add());
|
||||
vtkm::Float64 timeDiff = interpolationTimer.GetElapsedTime();
|
||||
std::cout << "No of interpolations: " << results.GetNumberOfValues() << "\n";
|
||||
std::cout << "Interpolation time: " << timeDiff << "\n";
|
||||
@ -129,7 +129,7 @@ void RunTest()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestBoundingIntervalHierarchy(int, char* [])
|
||||
int UnitTestBoundingIntervalHierarchy(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(RunTest);
|
||||
return vtkm::cont::testing::Testing::Run(RunTest, argc, argv);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ void TestCellAverage()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestCellAverage(int, char* [])
|
||||
int UnitTestCellAverage(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestCellAverage);
|
||||
return vtkm::cont::testing::Testing::Run(TestCellAverage, argc, argv);
|
||||
}
|
||||
|
@ -98,8 +98,7 @@ void RunTest()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestCellDeepCopy(int, char* [])
|
||||
int UnitTestCellDeepCopy(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(RunTest);
|
||||
return vtkm::cont::testing::Testing::Run(RunTest, argc, argv);
|
||||
}
|
||||
|
@ -247,8 +247,7 @@ void TestCellGradient()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestCellGradient(int, char* [])
|
||||
int UnitTestCellGradient(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestCellGradient);
|
||||
return vtkm::cont::testing::Testing::Run(TestCellGradient, argc, argv);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void TestCellMeasure()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestCellMeasure(int, char* [])
|
||||
int UnitTestCellMeasure(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestCellMeasure);
|
||||
return vtkm::cont::testing::Testing::Run(TestCellMeasure, argc, argv);
|
||||
}
|
||||
|
@ -123,7 +123,6 @@ static vtkm::cont::DataSet MakeIsosurfaceTestDataSet(vtkm::Id3 dims)
|
||||
}
|
||||
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
class TestCellSetConnectivity
|
||||
{
|
||||
public:
|
||||
@ -141,10 +140,9 @@ public:
|
||||
|
||||
auto cellSet = outputData.GetCellSet().Cast<vtkm::cont::CellSetSingleType<>>();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> componentArray;
|
||||
vtkm::worklet::connectivity::CellSetConnectivity().Run(
|
||||
cellSet, componentArray, DeviceAdapter());
|
||||
vtkm::worklet::connectivity::CellSetConnectivity().Run(cellSet, componentArray);
|
||||
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
Algorithm::Sort(componentArray);
|
||||
Algorithm::Unique(componentArray);
|
||||
VTKM_TEST_ASSERT(componentArray.GetNumberOfValues() == 8,
|
||||
@ -157,10 +155,9 @@ public:
|
||||
|
||||
auto cellSet = dataSet.GetCellSet().Cast<vtkm::cont::CellSetExplicit<>>();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> componentArray;
|
||||
vtkm::worklet::connectivity::CellSetConnectivity().Run(
|
||||
cellSet, componentArray, DeviceAdapter());
|
||||
vtkm::worklet::connectivity::CellSetConnectivity().Run(cellSet, componentArray);
|
||||
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
Algorithm::Sort(componentArray);
|
||||
Algorithm::Unique(componentArray);
|
||||
VTKM_TEST_ASSERT(componentArray.GetNumberOfValues() == 1,
|
||||
@ -173,10 +170,9 @@ public:
|
||||
|
||||
auto cellSet = dataSet.GetCellSet();
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> componentArray;
|
||||
vtkm::worklet::connectivity::CellSetConnectivity().Run(
|
||||
cellSet, componentArray, DeviceAdapter());
|
||||
vtkm::worklet::connectivity::CellSetConnectivity().Run(cellSet, componentArray);
|
||||
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
Algorithm::Sort(componentArray);
|
||||
Algorithm::Unique(componentArray);
|
||||
VTKM_TEST_ASSERT(componentArray.GetNumberOfValues() == 1,
|
||||
@ -191,8 +187,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int UnitTestCellSetConnectivity(int, char* [])
|
||||
int UnitTestCellSetConnectivity(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestCellSetConnectivity<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>());
|
||||
return vtkm::cont::testing::Testing::Run(TestCellSetConnectivity(), argc, argv);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
#include <vtkm/worklet/connectivities/CellSetDualGraph.h>
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
class TestCellSetDualGraph
|
||||
{
|
||||
private:
|
||||
@ -62,7 +61,7 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> indexOffsetArray;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> connectivityArray;
|
||||
|
||||
vtkm::worklet::connectivity::CellSetDualGraph<DeviceAdapter>().Run(
|
||||
vtkm::worklet::connectivity::CellSetDualGraph().Run(
|
||||
cellSet, numIndicesArray, indexOffsetArray, connectivityArray);
|
||||
|
||||
vtkm::Id expectedNumIndices[] = { 1, 1, 3, 1, 1, 1 };
|
||||
@ -83,7 +82,7 @@ public:
|
||||
void operator()() const { this->TestTriangleMesh(); }
|
||||
};
|
||||
|
||||
int UnitTestCellSetDualGraph(int, char* [])
|
||||
int UnitTestCellSetDualGraph(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestCellSetDualGraph<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>());
|
||||
return vtkm::cont::testing::Testing::Run(TestCellSetDualGraph(), argc, argv);
|
||||
}
|
||||
|
@ -354,8 +354,7 @@ void TestClipping()
|
||||
TestClippingWithImplicitFunctionInverted();
|
||||
}
|
||||
|
||||
int UnitTestClipping(int, char* [])
|
||||
int UnitTestClipping(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestClipping);
|
||||
return vtkm::cont::testing::Testing::Run(TestClipping, argc, argv);
|
||||
}
|
||||
|
@ -182,8 +182,7 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
int UnitTestContourTreeUniform(int, char* [])
|
||||
int UnitTestContourTreeUniform(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestContourTreeUniform());
|
||||
return vtkm::cont::testing::Testing::Run(TestContourTreeUniform(), argc, argv);
|
||||
}
|
||||
|
@ -332,8 +332,7 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
int UnitTestContourTreeUniformAugmented(int, char* [])
|
||||
int UnitTestContourTreeUniformAugmented(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestContourTreeUniform());
|
||||
return vtkm::cont::testing::Testing::Run(TestContourTreeUniform(), argc, argv);
|
||||
}
|
||||
|
@ -208,8 +208,7 @@ void TestCoordinateSystemTransform()
|
||||
dsSph.GetCoordinateSystem(), sphToCarPts, revResult, { false, true, true });
|
||||
}
|
||||
|
||||
int UnitTestCoordinateSystemTransform(int, char* [])
|
||||
int UnitTestCoordinateSystemTransform(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestCoordinateSystemTransform);
|
||||
return vtkm::cont::testing::Testing::Run(TestCoordinateSystemTransform, argc, argv);
|
||||
}
|
||||
|
@ -232,8 +232,7 @@ void TestCosmo_2DHaloFind()
|
||||
linkingLength,
|
||||
resultHaloId,
|
||||
resultMBP,
|
||||
resultPot,
|
||||
VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
resultPot);
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(haloIdArray, resultHaloId, nCells), "Incorrect Halo Ids");
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(mbpArray, resultMBP, nCells), "Incorrect MBP Ids");
|
||||
@ -285,8 +284,7 @@ void TestCosmo_3DHaloFind()
|
||||
linkingLength,
|
||||
resultHaloId,
|
||||
resultMBP,
|
||||
resultPot,
|
||||
VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
resultPot);
|
||||
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(haloIdArray, resultHaloId, nCells), "Incorrect Halo Ids");
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(mbpArray, resultMBP, nCells), "Incorrect MBP Ids");
|
||||
@ -322,21 +320,11 @@ void TestCosmo_3DCenterFind()
|
||||
vtkm::Float32 particleMass = 1.0f;
|
||||
|
||||
vtkm::worklet::CosmoTools cosmoTools;
|
||||
cosmoTools.RunMBPCenterFinderNxN(xLocArray,
|
||||
yLocArray,
|
||||
zLocArray,
|
||||
nCells,
|
||||
particleMass,
|
||||
nxnResult,
|
||||
VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
cosmoTools.RunMBPCenterFinderNxN(
|
||||
xLocArray, yLocArray, zLocArray, nCells, particleMass, nxnResult);
|
||||
|
||||
cosmoTools.RunMBPCenterFinderMxN(xLocArray,
|
||||
yLocArray,
|
||||
zLocArray,
|
||||
nCells,
|
||||
particleMass,
|
||||
mxnResult,
|
||||
VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
cosmoTools.RunMBPCenterFinderMxN(
|
||||
xLocArray, yLocArray, zLocArray, nCells, particleMass, mxnResult);
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(nxnResult.first, mxnResult.first),
|
||||
"NxN and MxN got different results");
|
||||
@ -350,7 +338,7 @@ void TestCosmoTools()
|
||||
TestCosmo_3DCenterFind();
|
||||
}
|
||||
|
||||
int UnitTestCosmoTools(int, char* [])
|
||||
int UnitTestCosmoTools(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestCosmoTools);
|
||||
return vtkm::cont::testing::Testing::Run(TestCosmoTools, argc, argv);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ void TestCrossProductWorklets()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestCrossProduct(int, char* [])
|
||||
int UnitTestCrossProduct(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestCrossProductWorklets);
|
||||
return vtkm::cont::testing::Testing::Run(TestCrossProductWorklets, argc, argv);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ void TestDotProductWorklets()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestDotProduct(int, char* [])
|
||||
int UnitTestDotProduct(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestDotProductWorklets);
|
||||
return vtkm::cont::testing::Testing::Run(TestDotProductWorklets, argc, argv);
|
||||
}
|
||||
|
@ -201,14 +201,15 @@ void TestExternalFaces3()
|
||||
|
||||
void TestExternalFaces()
|
||||
{
|
||||
// Ignore the device passed in.
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(MyDeviceAdapter());
|
||||
TestExternalFaces1();
|
||||
TestExternalFaces2();
|
||||
TestExternalFaces3();
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestExternalFaces(int, char* [])
|
||||
int UnitTestExternalFaces(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(MyDeviceAdapter());
|
||||
return vtkm::cont::testing::Testing::Run(TestExternalFaces);
|
||||
return vtkm::cont::testing::Testing::Run(TestExternalFaces, argc, argv);
|
||||
}
|
||||
|
@ -260,8 +260,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int UnitTestExtractGeometry(int, char* [])
|
||||
int UnitTestExtractGeometry(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestingExtractGeometry());
|
||||
return vtkm::cont::testing::Testing::Run(TestingExtractGeometry(), argc, argv);
|
||||
}
|
||||
|
@ -249,8 +249,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int UnitTestExtractPoints(int, char* [])
|
||||
int UnitTestExtractPoints(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestingExtractPoints());
|
||||
return vtkm::cont::testing::Testing::Run(TestingExtractPoints(), argc, argv);
|
||||
}
|
||||
|
@ -228,8 +228,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int UnitTestExtractStructured(int, char* [])
|
||||
int UnitTestExtractStructured(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestingExtractStructured());
|
||||
return vtkm::cont::testing::Testing::Run(TestingExtractStructured(), argc, argv);
|
||||
}
|
||||
|
@ -340,8 +340,7 @@ void TestFieldHistogram()
|
||||
PrintHistogram(bins, numberOfBins, range, delta);
|
||||
} // TestFieldHistogram
|
||||
|
||||
int UnitTestFieldHistogram(int, char* [])
|
||||
int UnitTestFieldHistogram(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestFieldHistogram);
|
||||
return vtkm::cont::testing::Testing::Run(TestFieldHistogram, argc, argv);
|
||||
}
|
||||
|
@ -309,8 +309,7 @@ vtkm::cont::DataSet Make2DUniformStatDataSet1()
|
||||
//
|
||||
// Create a dataset with known point data and cell data (statistical distributions)
|
||||
//
|
||||
void PrintStatInfo(
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32, VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::StatInfo statinfo)
|
||||
void PrintStatInfo(vtkm::worklet::FieldStatistics<vtkm::Float32>::StatInfo statinfo)
|
||||
{
|
||||
std::cout << " Median " << statinfo.median << std::endl;
|
||||
std::cout << " Minimum " << statinfo.minimum << std::endl;
|
||||
@ -336,7 +335,7 @@ void PrintStatInfo(
|
||||
void TestFieldSimple()
|
||||
{
|
||||
// Create the output structure
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32, VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::StatInfo statinfo;
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32>::StatInfo statinfo;
|
||||
|
||||
// Data attached is [1:10]
|
||||
vtkm::cont::DataSet ds = Make2DUniformStatDataSet0();
|
||||
@ -346,8 +345,7 @@ void TestFieldSimple()
|
||||
ds.GetField("data").GetData().CopyTo(data);
|
||||
|
||||
// Run
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32, VTKM_DEFAULT_DEVICE_ADAPTER_TAG>().Run(data,
|
||||
statinfo);
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32>().Run(data, statinfo);
|
||||
std::cout << "Statistics for CELL data:" << std::endl;
|
||||
PrintStatInfo(statinfo);
|
||||
|
||||
@ -368,7 +366,7 @@ void TestFieldSimple()
|
||||
void TestFieldStandardDistributions()
|
||||
{
|
||||
// Create the output structure
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32, VTKM_DEFAULT_DEVICE_ADAPTER_TAG>::StatInfo statinfo;
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32>::StatInfo statinfo;
|
||||
|
||||
// Data attached is the poisson distribution
|
||||
vtkm::cont::DataSet ds = Make2DUniformStatDataSet1();
|
||||
@ -384,26 +382,22 @@ void TestFieldStandardDistributions()
|
||||
ds.GetField("p_uniform").GetData().CopyTo(p_uniform);
|
||||
|
||||
// Run Poisson data
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32, VTKM_DEFAULT_DEVICE_ADAPTER_TAG>().Run(p_poisson,
|
||||
statinfo);
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32>().Run(p_poisson, statinfo);
|
||||
std::cout << "Poisson distributed POINT data:" << std::endl;
|
||||
PrintStatInfo(statinfo);
|
||||
|
||||
// Run Normal data
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32, VTKM_DEFAULT_DEVICE_ADAPTER_TAG>().Run(p_normal,
|
||||
statinfo);
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32>().Run(p_normal, statinfo);
|
||||
std::cout << "Normal distributed POINT data:" << std::endl;
|
||||
PrintStatInfo(statinfo);
|
||||
|
||||
// Run Chi Square data
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32, VTKM_DEFAULT_DEVICE_ADAPTER_TAG>().Run(p_chiSquare,
|
||||
statinfo);
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32>().Run(p_chiSquare, statinfo);
|
||||
std::cout << "Chi Square distributed POINT data:" << std::endl;
|
||||
PrintStatInfo(statinfo);
|
||||
|
||||
// Run Uniform data
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32, VTKM_DEFAULT_DEVICE_ADAPTER_TAG>().Run(p_uniform,
|
||||
statinfo);
|
||||
vtkm::worklet::FieldStatistics<vtkm::Float32>().Run(p_uniform, statinfo);
|
||||
std::cout << "Uniform distributed POINT data:" << std::endl;
|
||||
PrintStatInfo(statinfo);
|
||||
} // TestFieldStatistics
|
||||
@ -414,7 +408,7 @@ void TestFieldStatistics()
|
||||
TestFieldSimple();
|
||||
}
|
||||
|
||||
int UnitTestFieldStatistics(int, char* [])
|
||||
int UnitTestFieldStatistics(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestFieldStatistics);
|
||||
return vtkm::cont::testing::Testing::Run(TestFieldStatistics, argc, argv);
|
||||
}
|
||||
|
@ -26,11 +26,10 @@
|
||||
#include <vtkm/worklet/connectivities/ImageConnectivity.h>
|
||||
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
class TestImageConnectivity
|
||||
{
|
||||
public:
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
@ -51,10 +50,7 @@ public:
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> component;
|
||||
vtkm::worklet::connectivity::ImageConnectivity().Run(
|
||||
data.GetCellSet(0).Cast<vtkm::cont::CellSetStructured<2>>(),
|
||||
colorField.GetData(),
|
||||
component,
|
||||
DeviceAdapter());
|
||||
data.GetCellSet(0).Cast<vtkm::cont::CellSetStructured<2>>(), colorField.GetData(), component);
|
||||
|
||||
std::vector<vtkm::Id> componentExpected = { 0, 1, 2, 1, 1, 3, 3, 4, 0, 1, 1, 1, 3, 3, 3, 4,
|
||||
1, 1, 3, 3, 3, 4, 3, 4, 1, 1, 3, 3, 4, 4, 4, 4 };
|
||||
@ -68,8 +64,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int UnitTestImageConnectivity(int, char* [])
|
||||
int UnitTestImageConnectivity(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestImageConnectivity<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>());
|
||||
return vtkm::cont::testing::Testing::Run(TestImageConnectivity(), argc, argv);
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <vtkm/worklet/connectivities/InnerJoin.h>
|
||||
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
class TestInnerJoin
|
||||
{
|
||||
public:
|
||||
@ -51,7 +50,7 @@ public:
|
||||
|
||||
void TestTwoArrays() const
|
||||
{
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
std::vector<vtkm::Id> A = { 8, 3, 6, 8, 9, 5, 12, 10, 14 };
|
||||
std::vector<vtkm::Id> B = { 7, 11, 9, 8, 5, 1, 0, 5 };
|
||||
@ -68,8 +67,7 @@ public:
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> outA;
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> outB;
|
||||
|
||||
vtkm::worklet::connectivity::InnerJoin<DeviceAdapter>().Run(
|
||||
A_arr, idxA, B_arr, idxB, joinedIndex, outA, outB);
|
||||
vtkm::worklet::connectivity::InnerJoin().Run(A_arr, idxA, B_arr, idxB, joinedIndex, outA, outB);
|
||||
|
||||
vtkm::Id expectedIndex[] = { 5, 5, 8, 8, 9 };
|
||||
VTKM_TEST_ASSERT(TestArrayHandle(joinedIndex, expectedIndex, 5), "Wrong joined keys");
|
||||
@ -84,7 +82,7 @@ public:
|
||||
void operator()() const { this->TestTwoArrays(); }
|
||||
};
|
||||
|
||||
int UnitTestInnerJoin(int, char* [])
|
||||
int UnitTestInnerJoin(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestInnerJoin<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>());
|
||||
return vtkm::cont::testing::Testing::Run(TestInnerJoin(), argc, argv);
|
||||
}
|
||||
|
@ -19,12 +19,13 @@
|
||||
//============================================================================
|
||||
|
||||
#include <random>
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/worklet/KdTree3D.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
////brute force method /////
|
||||
template <typename CoordiVecT, typename CoordiPortalT, typename CoordiT>
|
||||
@ -74,7 +75,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void TestKdTreeBuildNNS()
|
||||
void TestKdTreeBuildNNS(vtkm::cont::DeviceAdapterId deviceId)
|
||||
{
|
||||
vtkm::Int32 nTrainingPoints = 1000;
|
||||
vtkm::Int32 nTestingPoint = 1000;
|
||||
@ -95,7 +96,7 @@ void TestKdTreeBuildNNS()
|
||||
|
||||
// Run data
|
||||
vtkm::worklet::KdTree3D kdtree3d;
|
||||
kdtree3d.Build(coordi_Handle, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
kdtree3d.Build(coordi_Handle);
|
||||
|
||||
//Nearest Neighbor worklet Testing
|
||||
/// randomly generate testing points /////
|
||||
@ -111,8 +112,7 @@ void TestKdTreeBuildNNS()
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> nnId_Handle;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> nnDis_Handle;
|
||||
|
||||
kdtree3d.Run(
|
||||
coordi_Handle, qc_Handle, nnId_Handle, nnDis_Handle, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
kdtree3d.Run(coordi_Handle, qc_Handle, nnId_Handle, nnDis_Handle, deviceId);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> bfnnId_Handle;
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> bfnnDis_Handle;
|
||||
@ -140,7 +140,7 @@ void TestKdTreeBuildNNS()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestKdTreeBuildNNS(int, char* [])
|
||||
int UnitTestKdTreeBuildNNS(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestKdTreeBuildNNS);
|
||||
return vtkm::cont::testing::Testing::RunOnDevice(TestKdTreeBuildNNS, argc, argv);
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ void TryKeyType(KeyType)
|
||||
vtkm::cont::ArrayHandle<KeyType> keyArray = vtkm::cont::make_ArrayHandle(keyBuffer, ARRAY_SIZE);
|
||||
|
||||
vtkm::cont::ArrayHandle<KeyType> sortedKeys;
|
||||
vtkm::cont::ArrayCopy(keyArray, sortedKeys, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::cont::ArrayCopy(keyArray, sortedKeys);
|
||||
|
||||
vtkm::worklet::Keys<KeyType> keys(sortedKeys, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::worklet::Keys<KeyType> keys(sortedKeys);
|
||||
VTKM_TEST_ASSERT(keys.GetInputRange() == NUM_UNIQUE, "Keys has bad input range.");
|
||||
|
||||
CheckKeyReduce(keyArray.GetPortalConstControl(),
|
||||
@ -101,7 +101,7 @@ void TestKeys()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestKeys(int, char* [])
|
||||
int UnitTestKeys(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestKeys);
|
||||
return vtkm::cont::testing::Testing::Run(TestKeys, argc, argv);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void TestMagnitude()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestMagnitude(int, char* [])
|
||||
int UnitTestMagnitude(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestMagnitude);
|
||||
return vtkm::cont::testing::Testing::Run(TestMagnitude, argc, argv);
|
||||
}
|
||||
|
@ -411,12 +411,11 @@ void TestMarchingCubesExplicit()
|
||||
|
||||
void TestMarchingCubes()
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
TestMarchingCubesUniformGrid();
|
||||
TestMarchingCubesExplicit();
|
||||
}
|
||||
|
||||
int UnitTestMarchingCubes(int, char* [])
|
||||
int UnitTestMarchingCubes(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestMarchingCubes);
|
||||
return vtkm::cont::testing::Testing::Run(TestMarchingCubes, argc, argv);
|
||||
}
|
||||
|
@ -123,8 +123,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int UnitTestMask(int, char* [])
|
||||
int UnitTestMask(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestingMask());
|
||||
return vtkm::cont::testing::Testing::Run(TestingMask(), argc, argv);
|
||||
}
|
||||
|
@ -110,8 +110,7 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
int UnitTestMaskPoints(int, char* [])
|
||||
int UnitTestMaskPoints(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestingMaskPoints());
|
||||
return vtkm::cont::testing::Testing::Run(TestingMaskPoints(), argc, argv);
|
||||
}
|
||||
|
@ -209,8 +209,7 @@ void TestNDimsEntropy()
|
||||
} // TestNDimsEntropy
|
||||
}
|
||||
|
||||
int UnitTestNDimsEntropy(int, char* [])
|
||||
int UnitTestNDimsEntropy(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestNDimsEntropy);
|
||||
return vtkm::cont::testing::Testing::Run(TestNDimsEntropy, argc, argv);
|
||||
}
|
||||
|
@ -299,8 +299,7 @@ void TestNDimsHistMarginalization()
|
||||
} // TestNDimsHistMarginalization
|
||||
}
|
||||
|
||||
int UnitTestNDimsHistMarginalization(int, char* [])
|
||||
int UnitTestNDimsHistMarginalization(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestNDimsHistMarginalization);
|
||||
return vtkm::cont::testing::Testing::Run(TestNDimsHistMarginalization, argc, argv);
|
||||
}
|
||||
|
@ -125,8 +125,7 @@ void TestNDimsHistogram()
|
||||
} // TestNDHistogram
|
||||
}
|
||||
|
||||
int UnitTestNDimsHistogram(int, char* [])
|
||||
int UnitTestNDimsHistogram(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestNDimsHistogram);
|
||||
return vtkm::cont::testing::Testing::Run(TestNDimsHistogram, argc, argv);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ void TestNormalWorklets()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestNormalize(int, char* [])
|
||||
int UnitTestNormalize(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestNormalWorklets);
|
||||
return vtkm::cont::testing::Testing::Run(TestNormalWorklets, argc, argv);
|
||||
}
|
||||
|
@ -509,8 +509,7 @@ void TestParticleAdvection()
|
||||
TestParticleWorklets();
|
||||
}
|
||||
|
||||
int UnitTestParticleAdvection(int, char* [])
|
||||
int UnitTestParticleAdvection(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestParticleAdvection);
|
||||
return vtkm::cont::testing::Testing::Run(TestParticleAdvection, argc, argv);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ void TestPointElevation()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestPointElevation(int, char* [])
|
||||
int UnitTestPointElevation(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestPointElevation);
|
||||
return vtkm::cont::testing::Testing::Run(TestPointElevation, argc, argv);
|
||||
}
|
||||
|
@ -224,8 +224,7 @@ void TestPointGradient()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestPointGradient(int, char* [])
|
||||
int UnitTestPointGradient(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestPointGradient);
|
||||
return vtkm::cont::testing::Testing::Run(TestPointGradient, argc, argv);
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ void TestPointTransform()
|
||||
TestPointTransformRotation(ds, angles[i], axes[j]);
|
||||
}
|
||||
|
||||
int UnitTestPointTransform(int, char* [])
|
||||
int UnitTestPointTransform(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestPointTransform);
|
||||
return vtkm::cont::testing::Testing::Run(TestPointTransform, argc, argv);
|
||||
}
|
||||
|
@ -211,8 +211,7 @@ public:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestProbe(int, char* [])
|
||||
int UnitTestProbe(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestProbe::Run);
|
||||
return vtkm::cont::testing::Testing::Run(TestProbe::Run, argc, argv);
|
||||
}
|
||||
|
@ -88,8 +88,7 @@ void RunTest()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestRemoveUnusedPoints(int, char* [])
|
||||
int UnitTestRemoveUnusedPoints(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(RunTest);
|
||||
return vtkm::cont::testing::Testing::Run(RunTest, argc, argv);
|
||||
}
|
||||
|
@ -192,13 +192,12 @@ struct TestToRGB
|
||||
{
|
||||
}
|
||||
|
||||
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
|
||||
template <typename T>
|
||||
VTKM_CONT void operator()(T) const
|
||||
{
|
||||
//use each component to generate the output
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>> output;
|
||||
this->Worklet.Run(make_data<T>(this->Worklet.GetRange()), output, DeviceAdapter());
|
||||
this->Worklet.Run(make_data<T>(this->Worklet.GetRange()), output);
|
||||
bool valid = verify(output);
|
||||
VTKM_TEST_ASSERT(valid, "scalar RGB failed");
|
||||
}
|
||||
@ -213,7 +212,7 @@ struct TestToRGB
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 3>> output;
|
||||
|
||||
//use all components to generate the output
|
||||
this->Worklet.Run(input, output, DeviceAdapter());
|
||||
this->Worklet.Run(input, output);
|
||||
valid = verify(output);
|
||||
VTKM_TEST_ASSERT(valid, "all components RGB failed");
|
||||
|
||||
@ -233,7 +232,7 @@ struct TestToRGB
|
||||
}
|
||||
|
||||
vtkm::worklet::ScalarsToColors magWorklet(magr);
|
||||
magWorklet.RunMagnitude(input, output, DeviceAdapter());
|
||||
magWorklet.RunMagnitude(input, output);
|
||||
// vtkm::cont::printSummary_ArrayHandle(output, std::cout, true);
|
||||
|
||||
auto portal2 = output.GetPortalControl();
|
||||
@ -256,7 +255,7 @@ struct TestToRGB
|
||||
int end = (N % 2 == 0) ? (N - 1) : N;
|
||||
for (int i = 0; i < end; ++i)
|
||||
{
|
||||
this->Worklet.RunComponent(input, i, output, DeviceAdapter());
|
||||
this->Worklet.RunComponent(input, i, output);
|
||||
valid = verify(output);
|
||||
VTKM_TEST_ASSERT(valid, "per component RGB failed");
|
||||
}
|
||||
@ -277,13 +276,12 @@ struct TestToRGBA
|
||||
{
|
||||
}
|
||||
|
||||
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
|
||||
template <typename T>
|
||||
VTKM_CONT void operator()(T) const
|
||||
{
|
||||
//use each component to generate the output
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>> output;
|
||||
this->Worklet.Run(make_data<T>(this->Worklet.GetRange()), output, DeviceAdapter());
|
||||
this->Worklet.Run(make_data<T>(this->Worklet.GetRange()), output);
|
||||
|
||||
bool valid = verify(this->Worklet.GetAlpha(), output);
|
||||
VTKM_TEST_ASSERT(valid, "scalar RGBA failed");
|
||||
@ -300,7 +298,7 @@ struct TestToRGBA
|
||||
// vtkm::cont::printSummary_ArrayHandle(input, std::cout, true);
|
||||
|
||||
//use all components to generate the output
|
||||
this->Worklet.Run(input, output, DeviceAdapter());
|
||||
this->Worklet.Run(input, output);
|
||||
valid = verify(this->Worklet.GetAlpha(), output);
|
||||
VTKM_TEST_ASSERT(valid, "all components RGBA failed");
|
||||
|
||||
@ -320,7 +318,7 @@ struct TestToRGBA
|
||||
}
|
||||
|
||||
vtkm::worklet::ScalarsToColors magWorklet(magr);
|
||||
magWorklet.RunMagnitude(input, output, DeviceAdapter());
|
||||
magWorklet.RunMagnitude(input, output);
|
||||
// vtkm::cont::printSummary_ArrayHandle(output, std::cout, true);
|
||||
|
||||
auto portal2 = output.GetPortalControl();
|
||||
@ -343,7 +341,7 @@ struct TestToRGBA
|
||||
int end = (N % 2 == 0) ? (N - 1) : N;
|
||||
for (int i = 0; i < end; ++i)
|
||||
{
|
||||
this->Worklet.RunComponent(input, i, output, DeviceAdapter());
|
||||
this->Worklet.RunComponent(input, i, output);
|
||||
valid = verify(this->Worklet.GetAlpha(), output);
|
||||
VTKM_TEST_ASSERT(valid, "per component RGB failed");
|
||||
}
|
||||
@ -405,7 +403,7 @@ void TestScalarsToColors()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestScalarsToColors(int, char* [])
|
||||
int UnitTestScalarsToColors(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestScalarsToColors);
|
||||
return vtkm::cont::testing::Testing::Run(TestScalarsToColors, argc, argv);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ TestScatterArrays MakeScatterArraysShort()
|
||||
const vtkm::IdComponent visitArray[outputSize] = { 0, 0, 1, 0, 0, 0 };
|
||||
|
||||
TestScatterArrays arrays;
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
// Need to copy arrays so that the data does not go out of scope.
|
||||
Algorithm::Copy(vtkm::cont::make_ArrayHandle(countArray, countArraySize), arrays.CountArray);
|
||||
@ -78,7 +78,7 @@ TestScatterArrays MakeScatterArraysLong()
|
||||
const vtkm::IdComponent visitArray[outputSize] = { 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4 };
|
||||
|
||||
TestScatterArrays arrays;
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
// Need to copy arrays so that the data does not go out of scope.
|
||||
Algorithm::Copy(vtkm::cont::make_ArrayHandle(countArray, countArraySize), arrays.CountArray);
|
||||
@ -98,7 +98,7 @@ TestScatterArrays MakeScatterArraysZero()
|
||||
const vtkm::Id inputToOutputMap[countArraySize] = { 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
TestScatterArrays arrays;
|
||||
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
using Algorithm = vtkm::cont::Algorithm;
|
||||
|
||||
// Need to copy arrays so that the data does not go out of scope.
|
||||
Algorithm::Copy(vtkm::cont::make_ArrayHandle(countArray, countArraySize), arrays.CountArray);
|
||||
@ -120,10 +120,10 @@ struct TestScatterCountingWorklet : public vtkm::worklet::WorkletMapField
|
||||
|
||||
using ScatterType = vtkm::worklet::ScatterCounting;
|
||||
|
||||
template <typename CountArrayType, typename Device>
|
||||
VTKM_CONT static ScatterType MakeScatter(const CountArrayType& countArray, Device)
|
||||
template <typename CountArrayType>
|
||||
VTKM_CONT static ScatterType MakeScatter(const CountArrayType& countArray)
|
||||
{
|
||||
return ScatterType(countArray, Device());
|
||||
return ScatterType(countArray);
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
@ -165,7 +165,7 @@ void TestScatterArrayGeneration(const TestScatterArrays& arrays)
|
||||
std::cout << " Testing array generation" << std::endl;
|
||||
|
||||
vtkm::worklet::ScatterCounting scatter(
|
||||
arrays.CountArray, VTKM_DEFAULT_DEVICE_ADAPTER_TAG(), true);
|
||||
arrays.CountArray, vtkm::cont::DeviceAdapterTagAny(), true);
|
||||
|
||||
vtkm::Id inputSize = arrays.CountArray.GetNumberOfValues();
|
||||
|
||||
@ -186,7 +186,7 @@ void TestScatterWorklet(const TestScatterArrays& arrays)
|
||||
std::cout << " Testing scatter counting in a worklet." << std::endl;
|
||||
|
||||
vtkm::worklet::DispatcherMapField<TestScatterCountingWorklet> dispatcher(
|
||||
TestScatterCountingWorklet::MakeScatter(arrays.CountArray, VTKM_DEFAULT_DEVICE_ADAPTER_TAG()));
|
||||
TestScatterCountingWorklet::MakeScatter(arrays.CountArray));
|
||||
|
||||
vtkm::Id inputSize = arrays.CountArray.GetNumberOfValues();
|
||||
vtkm::cont::ArrayHandleIndex inputIndices(inputSize);
|
||||
@ -225,7 +225,7 @@ void TestScatterCounting()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestScatterCounting(int, char* [])
|
||||
int UnitTestScatterCounting(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestScatterCounting);
|
||||
return vtkm::cont::testing::Testing::Run(TestScatterCounting, argc, argv);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void TestScatterPermutation()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestScatterPermutation(int, char* [])
|
||||
int UnitTestScatterPermutation(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestScatterPermutation);
|
||||
return vtkm::cont::testing::Testing::Run(TestScatterPermutation, argc, argv);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ int TestSplatKernels()
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int UnitTestSplatKernels(int, char* [])
|
||||
int UnitTestSplatKernels(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestSplatKernels);
|
||||
return vtkm::cont::testing::Testing::Run(TestSplatKernels, argc, argv);
|
||||
}
|
||||
|
@ -234,8 +234,7 @@ void TestSplitSharpEdges()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestSplitSharpEdges(int, char* [])
|
||||
int UnitTestSplitSharpEdges(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestSplitSharpEdges);
|
||||
return vtkm::cont::testing::Testing::Run(TestSplitSharpEdges, argc, argv);
|
||||
}
|
||||
|
@ -23,6 +23,12 @@
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
#include <vtkm/worklet/StreamLineUniformGrid.h>
|
||||
|
||||
#include <vtkm/cont/openmp/internal/ArrayManagerExecutionOpenMP.h>
|
||||
#include <vtkm/cont/tbb/internal/ArrayManagerExecutionTBB.h>
|
||||
#ifdef VTKM_ENABLE_CUDA
|
||||
#include <vtkm/cont/cuda/internal/ArrayManagerExecutionCuda.h>
|
||||
#endif
|
||||
|
||||
#include <fstream>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
@ -109,12 +115,31 @@ float data[125 * 3] = {
|
||||
};
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct StreamLineFilterUniformGridFunctor
|
||||
{
|
||||
vtkm::cont::DataSet OutDataSet;
|
||||
template <typename DeviceAdapter, typename FieldType>
|
||||
bool operator()(DeviceAdapter,
|
||||
const vtkm::cont::DataSet& inDataSet,
|
||||
vtkm::Id streamMode,
|
||||
vtkm::Id numSeeds,
|
||||
vtkm::Id maxSteps,
|
||||
FieldType timeStep)
|
||||
{
|
||||
vtkm::worklet::StreamLineFilterUniformGrid<FieldType, DeviceAdapter> streamLineFilter;
|
||||
OutDataSet = streamLineFilter.Run(inDataSet, streamMode, numSeeds, maxSteps, timeStep);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void TestStreamLineUniformGrid()
|
||||
{
|
||||
std::cout << "Testing StreamLineUniformGrid Filter" << std::endl;
|
||||
|
||||
using DeviceAdapter = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
|
||||
|
||||
// Parameters for streamlines
|
||||
vtkm::Id numSeeds = 5;
|
||||
vtkm::Id maxSteps = 50;
|
||||
@ -150,14 +175,14 @@ void TestStreamLineUniformGrid()
|
||||
inDataSet.AddCellSet(inCellSet);
|
||||
|
||||
// Create and run the filter
|
||||
vtkm::worklet::StreamLineFilterUniformGrid<vtkm::Float32, DeviceAdapter> streamLineFilter;
|
||||
vtkm::cont::DataSet outDataSet =
|
||||
streamLineFilter.Run(inDataSet, vtkm::worklet::internal::BOTH, numSeeds, maxSteps, timeStep);
|
||||
detail::StreamLineFilterUniformGridFunctor smfuFunctor;
|
||||
vtkm::cont::TryExecute(
|
||||
smfuFunctor, inDataSet, vtkm::worklet::internal::BOTH, numSeeds, maxSteps, timeStep);
|
||||
|
||||
// Check output
|
||||
vtkm::cont::CellSetExplicit<> outCellSet;
|
||||
outDataSet.GetCellSet(0).CopyTo(outCellSet);
|
||||
auto coordArray = outDataSet.GetCoordinateSystem(0).GetData();
|
||||
smfuFunctor.OutDataSet.GetCellSet(0).CopyTo(outCellSet);
|
||||
auto coordArray = smfuFunctor.OutDataSet.GetCoordinateSystem(0).GetData();
|
||||
|
||||
vtkm::Id numberOfCells = outCellSet.GetNumberOfCells();
|
||||
vtkm::Id numberOfPoints = coordArray.GetNumberOfValues();
|
||||
@ -168,7 +193,7 @@ void TestStreamLineUniformGrid()
|
||||
"Wrong number of cells for stream lines");
|
||||
}
|
||||
|
||||
int UnitTestStreamLineUniformGrid(int, char* [])
|
||||
int UnitTestStreamLineUniformGrid(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestStreamLineUniformGrid);
|
||||
return vtkm::cont::testing::Testing::Run(TestStreamLineUniformGrid, argc, argv);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/ArrayHandleStreaming.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -77,7 +78,7 @@ void TestStreamingSine()
|
||||
}
|
||||
input = vtkm::cont::make_ArrayHandle(data);
|
||||
|
||||
using DeviceAlgorithms = vtkm::cont::DeviceAdapterAlgorithm<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
using DeviceAlgorithms = vtkm::cont::Algorithm;
|
||||
vtkm::worklet::SineWorklet sineWorklet;
|
||||
vtkm::worklet::DispatcherStreamingMapField<vtkm::worklet::SineWorklet> dispatcher(sineWorklet);
|
||||
dispatcher.SetNumberOfBlocks(NBlocks);
|
||||
@ -123,7 +124,7 @@ void TestStreamingSine()
|
||||
"Wrong sum for streaming reduce with binary operator");
|
||||
}
|
||||
|
||||
int UnitTestStreamingSine(int, char* [])
|
||||
int UnitTestStreamingSine(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestStreamingSine);
|
||||
return vtkm::cont::testing::Testing::Run(TestStreamingSine, argc, argv);
|
||||
}
|
||||
|
@ -75,7 +75,6 @@ void TestSmoothSurfaceNormals(const vtkm::cont::DataSet& dataset,
|
||||
|
||||
void TestSurfaceNormals()
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
|
||||
vtkm::cont::DataSet dataset =
|
||||
vtkm::cont::testing::MakeTestDataSet().Make3DExplicitDataSetPolygonal();
|
||||
@ -87,7 +86,7 @@ void TestSurfaceNormals()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestSurfaceNormals(int, char* [])
|
||||
int UnitTestSurfaceNormals(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestSurfaceNormals);
|
||||
return vtkm::cont::testing::Testing::Run(TestSurfaceNormals, argc, argv);
|
||||
}
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
using vtkm::cont::testing::MakeTestDataSet;
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
class TestingTetrahedralize
|
||||
{
|
||||
public:
|
||||
@ -97,8 +96,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int UnitTestTetrahedralize(int, char* [])
|
||||
int UnitTestTetrahedralize(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(
|
||||
TestingTetrahedralize<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>());
|
||||
return vtkm::cont::testing::Testing::Run(TestingTetrahedralize(), argc, argv);
|
||||
}
|
||||
|
@ -154,8 +154,7 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
int UnitTestThreshold(int, char* [])
|
||||
int UnitTestThreshold(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestingThreshold());
|
||||
return vtkm::cont::testing::Testing::Run(TestingThreshold(), argc, argv);
|
||||
}
|
||||
|
@ -187,8 +187,7 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
int UnitTestThresholdPoints(int, char* [])
|
||||
int UnitTestThresholdPoints(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestingThresholdPoints());
|
||||
return vtkm::cont::testing::Testing::Run(TestingThresholdPoints(), argc, argv);
|
||||
}
|
||||
|
@ -88,8 +88,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
int UnitTestTriangulate(int, char* [])
|
||||
int UnitTestTriangulate(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestingTriangulate());
|
||||
return vtkm::cont::testing::Testing::Run(TestingTriangulate(), argc, argv);
|
||||
}
|
||||
|
@ -30,8 +30,6 @@
|
||||
|
||||
void TestVertexClustering()
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
|
||||
const vtkm::Id3 divisions(3, 3, 3);
|
||||
vtkm::cont::testing::MakeTestDataSet maker;
|
||||
vtkm::cont::DataSet dataSet = maker.Make3DExplicitDataSetCowNose();
|
||||
@ -142,7 +140,7 @@ void TestVertexClustering()
|
||||
|
||||
} // TestVertexClustering
|
||||
|
||||
int UnitTestVertexClustering(int, char* [])
|
||||
int UnitTestVertexClustering(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestVertexClustering);
|
||||
return vtkm::cont::testing::Testing::Run(TestVertexClustering, argc, argv);
|
||||
}
|
||||
|
@ -99,8 +99,7 @@ void TestWarpScalar()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestWarpScalar(int, char* [])
|
||||
int UnitTestWarpScalar(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestWarpScalar);
|
||||
return vtkm::cont::testing::Testing::Run(TestWarpScalar, argc, argv);
|
||||
}
|
||||
|
@ -104,8 +104,7 @@ void TestWarpVector()
|
||||
}
|
||||
}
|
||||
|
||||
int UnitTestWarpVector(int, char* [])
|
||||
int UnitTestWarpVector(int argc, char* argv[])
|
||||
{
|
||||
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
return vtkm::cont::testing::Testing::Run(TestWarpVector);
|
||||
return vtkm::cont::testing::Testing::Run(TestWarpVector, argc, argv);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ void TestDecomposeReconstruct3D(vtkm::Float64 cratio)
|
||||
|
||||
// make input data array handle
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> inputArray;
|
||||
inputArray.PrepareForOutput(sigLen, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
inputArray.Allocate(sigLen);
|
||||
FillArray3D(inputArray, sigX, sigY, sigZ);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> outputArray;
|
||||
@ -208,30 +208,25 @@ void TestDecomposeReconstruct3D(vtkm::Float64 cratio)
|
||||
vtkm::Float64 elapsedTime1, elapsedTime2, elapsedTime3;
|
||||
|
||||
// Decompose
|
||||
|
||||
vtkm::cont::Timer<> timer;
|
||||
computationTime = compressor.WaveDecompose3D(
|
||||
inputArray, nLevels, sigX, sigY, sigZ, outputArray, false, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
computationTime =
|
||||
compressor.WaveDecompose3D(inputArray, nLevels, sigX, sigY, sigZ, outputArray, false);
|
||||
elapsedTime1 = timer.GetElapsedTime();
|
||||
std::cout << "Decompose time = " << elapsedTime1 << std::endl;
|
||||
std::cout << " ->computation time = " << computationTime << std::endl;
|
||||
|
||||
// Squash small coefficients
|
||||
timer.Reset();
|
||||
compressor.SquashCoefficients(outputArray, cratio, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
compressor.SquashCoefficients(outputArray, cratio);
|
||||
elapsedTime2 = timer.GetElapsedTime();
|
||||
std::cout << "Squash time = " << elapsedTime2 << std::endl;
|
||||
|
||||
// Reconstruct
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> reconstructArray;
|
||||
timer.Reset();
|
||||
computationTime = compressor.WaveReconstruct3D(outputArray,
|
||||
nLevels,
|
||||
sigX,
|
||||
sigY,
|
||||
sigZ,
|
||||
reconstructArray,
|
||||
false,
|
||||
VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
computationTime =
|
||||
compressor.WaveReconstruct3D(outputArray, nLevels, sigX, sigY, sigZ, reconstructArray, false);
|
||||
elapsedTime3 = timer.GetElapsedTime();
|
||||
std::cout << "Reconstruction time = " << elapsedTime3 << std::endl;
|
||||
std::cout << " ->computation time = " << computationTime << std::endl;
|
||||
@ -240,8 +235,7 @@ void TestDecomposeReconstruct3D(vtkm::Float64 cratio)
|
||||
|
||||
outputArray.ReleaseResources();
|
||||
|
||||
compressor.EvaluateReconstruction(
|
||||
inputArray, reconstructArray, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
compressor.EvaluateReconstruction(inputArray, reconstructArray);
|
||||
|
||||
timer.Reset();
|
||||
for (vtkm::Id i = 0; i < reconstructArray.GetNumberOfValues(); i++)
|
||||
@ -263,7 +257,7 @@ void TestDecomposeReconstruct2D(vtkm::Float64 cratio)
|
||||
|
||||
// make input data array handle
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> inputArray;
|
||||
inputArray.PrepareForOutput(sigLen, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
inputArray.Allocate(sigLen);
|
||||
FillArray2D(inputArray, sigX, sigY);
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> outputArray;
|
||||
@ -283,23 +277,22 @@ void TestDecomposeReconstruct2D(vtkm::Float64 cratio)
|
||||
|
||||
// Decompose
|
||||
vtkm::cont::Timer<> timer;
|
||||
computationTime = compressor.WaveDecompose2D(
|
||||
inputArray, nLevels, sigX, sigY, outputArray, L, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
computationTime = compressor.WaveDecompose2D(inputArray, nLevels, sigX, sigY, outputArray, L);
|
||||
elapsedTime1 = timer.GetElapsedTime();
|
||||
std::cout << "Decompose time = " << elapsedTime1 << std::endl;
|
||||
std::cout << " ->computation time = " << computationTime << std::endl;
|
||||
|
||||
// Squash small coefficients
|
||||
timer.Reset();
|
||||
compressor.SquashCoefficients(outputArray, cratio, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
compressor.SquashCoefficients(outputArray, cratio);
|
||||
elapsedTime2 = timer.GetElapsedTime();
|
||||
std::cout << "Squash time = " << elapsedTime2 << std::endl;
|
||||
|
||||
// Reconstruct
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> reconstructArray;
|
||||
timer.Reset();
|
||||
computationTime = compressor.WaveReconstruct2D(
|
||||
outputArray, nLevels, sigX, sigY, reconstructArray, L, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
computationTime =
|
||||
compressor.WaveReconstruct2D(outputArray, nLevels, sigX, sigY, reconstructArray, L);
|
||||
elapsedTime3 = timer.GetElapsedTime();
|
||||
std::cout << "Reconstruction time = " << elapsedTime3 << std::endl;
|
||||
std::cout << " ->computation time = " << computationTime << std::endl;
|
||||
@ -308,8 +301,7 @@ void TestDecomposeReconstruct2D(vtkm::Float64 cratio)
|
||||
|
||||
outputArray.ReleaseResources();
|
||||
|
||||
compressor.EvaluateReconstruction(
|
||||
inputArray, reconstructArray, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
compressor.EvaluateReconstruction(inputArray, reconstructArray);
|
||||
|
||||
timer.Reset();
|
||||
for (vtkm::Id i = 0; i < reconstructArray.GetNumberOfValues(); i++)
|
||||
@ -351,27 +343,25 @@ void TestDecomposeReconstruct1D(vtkm::Float64 cratio)
|
||||
|
||||
// Decompose
|
||||
vtkm::cont::Timer<> timer;
|
||||
compressor.WaveDecompose(inputArray, nLevels, outputArray, L, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
compressor.WaveDecompose(inputArray, nLevels, outputArray, L);
|
||||
|
||||
vtkm::Float64 elapsedTime = timer.GetElapsedTime();
|
||||
std::cout << "Decompose time = " << elapsedTime << std::endl;
|
||||
|
||||
// Squash small coefficients
|
||||
timer.Reset();
|
||||
compressor.SquashCoefficients(outputArray, cratio, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
compressor.SquashCoefficients(outputArray, cratio);
|
||||
elapsedTime = timer.GetElapsedTime();
|
||||
std::cout << "Squash time = " << elapsedTime << std::endl;
|
||||
|
||||
// Reconstruct
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> reconstructArray;
|
||||
timer.Reset();
|
||||
compressor.WaveReconstruct(
|
||||
outputArray, nLevels, L, reconstructArray, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
compressor.WaveReconstruct(outputArray, nLevels, L, reconstructArray);
|
||||
elapsedTime = timer.GetElapsedTime();
|
||||
std::cout << "Reconstruction time = " << elapsedTime << std::endl;
|
||||
|
||||
compressor.EvaluateReconstruction(
|
||||
inputArray, reconstructArray, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
compressor.EvaluateReconstruction(inputArray, reconstructArray);
|
||||
|
||||
timer.Reset();
|
||||
for (vtkm::Id i = 0; i < reconstructArray.GetNumberOfValues(); i++)
|
||||
@ -399,7 +389,7 @@ void TestWaveletCompressor()
|
||||
TestDecomposeReconstruct3D(cratio);
|
||||
}
|
||||
|
||||
int UnitTestWaveletCompressor(int, char* [])
|
||||
int UnitTestWaveletCompressor(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestWaveletCompressor);
|
||||
return vtkm::cont::testing::Testing::Run(TestWaveletCompressor, argc, argv);
|
||||
}
|
||||
|
@ -21,31 +21,44 @@
|
||||
#include <vtkm/worklet/WaveletGenerator.h>
|
||||
|
||||
#include <vtkm/cont/Timer.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
namespace
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct WaveletGeneratorFunctor
|
||||
{
|
||||
vtkm::cont::DataSet Ds;
|
||||
template <typename DeviceAdapter>
|
||||
bool operator()(DeviceAdapter)
|
||||
{
|
||||
vtkm::worklet::WaveletGenerator gen;
|
||||
Ds = gen.GenerateDataSet<DeviceAdapter>();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void WaveletGeneratorTest()
|
||||
{
|
||||
using Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG;
|
||||
vtkm::cont::Timer<> timer;
|
||||
detail::WaveletGeneratorFunctor wgFunctor;
|
||||
vtkm::cont::TryExecute(wgFunctor);
|
||||
|
||||
vtkm::worklet::WaveletGenerator gen;
|
||||
|
||||
vtkm::cont::Timer<Device> timer;
|
||||
auto ds = gen.GenerateDataSet<Device>();
|
||||
double time = timer.GetElapsedTime();
|
||||
|
||||
std::cout << "Default wavelet took " << time << "s.\n";
|
||||
|
||||
{
|
||||
auto coords = ds.GetCoordinateSystem("coords");
|
||||
auto coords = wgFunctor.Ds.GetCoordinateSystem("coords");
|
||||
auto data = coords.GetData();
|
||||
VTKM_TEST_ASSERT(test_equal(data.GetNumberOfValues(), 9261), "Incorrect number of points.");
|
||||
}
|
||||
|
||||
{
|
||||
auto cells = ds.GetCellSet(ds.GetCellSetIndex("cells"));
|
||||
auto cells = wgFunctor.Ds.GetCellSet(wgFunctor.Ds.GetCellSetIndex("cells"));
|
||||
VTKM_TEST_ASSERT(test_equal(cells.GetNumberOfCells(), 8000), "Incorrect number of cells.");
|
||||
}
|
||||
|
||||
@ -53,7 +66,7 @@ void WaveletGeneratorTest()
|
||||
{
|
||||
using ScalarHandleType = vtkm::cont::ArrayHandle<vtkm::FloatDefault>;
|
||||
|
||||
auto field = ds.GetField("scalars", vtkm::cont::Field::Association::POINTS);
|
||||
auto field = wgFunctor.Ds.GetField("scalars", vtkm::cont::Field::Association::POINTS);
|
||||
auto dynData = field.GetData();
|
||||
VTKM_TEST_ASSERT(dynData.IsType<ScalarHandleType>(), "Invalid scalar handle type.");
|
||||
ScalarHandleType handle = dynData.Cast<ScalarHandleType>();
|
||||
@ -75,9 +88,7 @@ void WaveletGeneratorTest()
|
||||
}
|
||||
}
|
||||
|
||||
} // end anon namespace
|
||||
|
||||
int UnitTestWaveletGenerator(int, char* [])
|
||||
int UnitTestWaveletGenerator(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(WaveletGeneratorTest);
|
||||
return vtkm::cont::testing::Testing::Run(WaveletGeneratorTest, argc, argv);
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ void RunWholeCellSetInTests()
|
||||
TryStructuredGrid1D();
|
||||
}
|
||||
|
||||
int UnitTestWholeCellSetIn(int, char* [])
|
||||
int UnitTestWholeCellSetIn(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(RunWholeCellSetInTests);
|
||||
return vtkm::cont::testing::Testing::Run(RunWholeCellSetInTests, argc, argv);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
@ -100,8 +101,8 @@ struct DoStaticTestWorklet
|
||||
vtkm::cont::ArrayHandle<T> outputHandle, outputHandleAsPtr;
|
||||
vtkm::cont::ArrayHandle<T> inoutHandle, inoutHandleAsPtr;
|
||||
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandleAsPtr, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandleAsPtr);
|
||||
|
||||
std::cout << "Create and run dispatchers." << std::endl;
|
||||
vtkm::worklet::DispatcherMapField<WorkletType> dispatcher;
|
||||
@ -155,7 +156,7 @@ struct DoDynamicTestWorklet
|
||||
vtkm::cont::DynamicArrayHandle inputDynamic(inputHandle);
|
||||
|
||||
{ //Verify we can pass by value
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
|
||||
vtkm::cont::DynamicArrayHandle outputDynamic(outputHandle);
|
||||
vtkm::cont::DynamicArrayHandle inoutDynamic(inoutHandle);
|
||||
dispatcher.Invoke(inputDynamic, outputDynamic, inoutDynamic);
|
||||
@ -164,7 +165,7 @@ struct DoDynamicTestWorklet
|
||||
}
|
||||
|
||||
{ //Verify we can pass by pointer
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
|
||||
vtkm::cont::DynamicArrayHandle outputDynamic(outputHandle);
|
||||
vtkm::cont::DynamicArrayHandle inoutDynamic(inoutHandle);
|
||||
dispatcher.Invoke(&inputDynamic, &outputDynamic, &inoutDynamic);
|
||||
@ -187,11 +188,9 @@ struct DoTestWorklet
|
||||
}
|
||||
};
|
||||
|
||||
void TestWorkletMapField()
|
||||
void TestWorkletMapField(vtkm::cont::DeviceAdapterId id)
|
||||
{
|
||||
using DeviceAdapterTraits = vtkm::cont::DeviceAdapterTraits<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
std::cout << "Testing Map Field on device adapter: " << DeviceAdapterTraits::GetName()
|
||||
<< std::endl;
|
||||
std::cout << "Testing Map Field on device adapter: " << id.GetName() << std::endl;
|
||||
|
||||
std::cout << "--- Worklet accepting all types." << std::endl;
|
||||
vtkm::testing::Testing::TryTypes(mapfield::DoTestWorklet<TestMapFieldWorklet>(),
|
||||
@ -217,7 +216,7 @@ void TestWorkletMapField()
|
||||
|
||||
} // mapfield namespace
|
||||
|
||||
int UnitTestWorkletMapField(int, char* [])
|
||||
int UnitTestWorkletMapField(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(mapfield::TestWorkletMapField);
|
||||
return vtkm::cont::testing::Testing::RunOnDevice(mapfield::TestWorkletMapField, argc, argv);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
@ -102,11 +103,9 @@ struct DoTestWorklet
|
||||
}
|
||||
};
|
||||
|
||||
void TestWorkletMapFieldExecArg()
|
||||
void TestWorkletMapFieldExecArg(vtkm::cont::DeviceAdapterId id)
|
||||
{
|
||||
using DeviceAdapterTraits = vtkm::cont::DeviceAdapterTraits<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
std::cout << "Testing Worklet with WholeArray on device adapter: "
|
||||
<< DeviceAdapterTraits::GetName() << std::endl;
|
||||
std::cout << "Testing Worklet with WholeArray on device adapter: " << id.GetName() << std::endl;
|
||||
|
||||
std::cout << "--- Worklet accepting all types." << std::endl;
|
||||
vtkm::testing::Testing::TryTypes(map_exec_field::DoTestWorklet<TestExecObjectWorklet>(),
|
||||
@ -115,7 +114,8 @@ void TestWorkletMapFieldExecArg()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestWorkletMapFieldExecArg(int, char* [])
|
||||
int UnitTestWorkletMapFieldExecArg(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(map_exec_field::TestWorkletMapFieldExecArg);
|
||||
return vtkm::cont::testing::Testing::RunOnDevice(
|
||||
map_exec_field::TestWorkletMapFieldExecArg, argc, argv);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleIndex.h>
|
||||
#include <vtkm/cont/DynamicArrayHandle.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
|
||||
#include <vtkm/worklet/DispatcherMapField.h>
|
||||
#include <vtkm/worklet/WorkletMapField.h>
|
||||
@ -151,11 +152,9 @@ struct DoTestAtomicArrayWorklet
|
||||
}
|
||||
};
|
||||
|
||||
void TestWorkletMapFieldExecArg()
|
||||
void TestWorkletMapFieldExecArg(vtkm::cont::DeviceAdapterId id)
|
||||
{
|
||||
using DeviceAdapterTraits = vtkm::cont::DeviceAdapterTraits<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
std::cout << "Testing Worklet with WholeArray on device adapter: "
|
||||
<< DeviceAdapterTraits::GetName() << std::endl;
|
||||
std::cout << "Testing Worklet with WholeArray on device adapter: " << id.GetName() << std::endl;
|
||||
|
||||
std::cout << "--- Worklet accepting all types." << std::endl;
|
||||
vtkm::testing::Testing::TryTypes(map_whole_array::DoTestWholeArrayWorklet(),
|
||||
@ -168,7 +167,8 @@ void TestWorkletMapFieldExecArg()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestWorkletMapFieldWholeArray(int, char* [])
|
||||
int UnitTestWorkletMapFieldWholeArray(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(map_whole_array::TestWorkletMapFieldExecArg);
|
||||
return vtkm::cont::testing::Testing::RunOnDevice(
|
||||
map_whole_array::TestWorkletMapFieldExecArg, argc, argv);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <vtkm/VecAxisAlignedPointCoordinates.h>
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -194,11 +195,10 @@ static void TestMaxNeighborValue();
|
||||
static void TestScatterIdentityNeighbor();
|
||||
static void TestScatterUnfiormNeighbor();
|
||||
|
||||
void TestWorkletPointNeighborhood()
|
||||
void TestWorkletPointNeighborhood(vtkm::cont::DeviceAdapterId id)
|
||||
{
|
||||
using DeviceAdapterTraits = vtkm::cont::DeviceAdapterTraits<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
std::cout << "Testing Point Neighborhood Worklet on device adapter: "
|
||||
<< DeviceAdapterTraits::GetName() << std::endl;
|
||||
std::cout << "Testing Point Neighborhood Worklet on device adapter: " << id.GetName()
|
||||
<< std::endl;
|
||||
|
||||
TestMaxNeighborValue();
|
||||
TestScatterIdentityNeighbor();
|
||||
@ -278,7 +278,7 @@ static void TestScatterUnfiormNeighbor()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestWorkletMapPointNeighborhood(int, char* [])
|
||||
int UnitTestWorkletMapPointNeighborhood(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestWorkletPointNeighborhood);
|
||||
return vtkm::cont::testing::Testing::RunOnDevice(TestWorkletPointNeighborhood, argc, argv);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <vtkm/Math.h>
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -76,11 +77,10 @@ static void TestMaxPointOrCell();
|
||||
static void TestAvgPointToCell();
|
||||
static void TestAvgCellToPoint();
|
||||
|
||||
void TestWorkletMapTopologyExplicit()
|
||||
void TestWorkletMapTopologyExplicit(vtkm::cont::DeviceAdapterId id)
|
||||
{
|
||||
using DeviceAdapterTraits = vtkm::cont::DeviceAdapterTraits<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
std::cout << "Testing Topology Worklet ( Explicit ) on device adapter: "
|
||||
<< DeviceAdapterTraits::GetName() << std::endl;
|
||||
std::cout << "Testing Topology Worklet ( Explicit ) on device adapter: " << id.GetName()
|
||||
<< std::endl;
|
||||
|
||||
TestMaxPointOrCell();
|
||||
TestAvgPointToCell();
|
||||
@ -178,7 +178,7 @@ static void TestAvgCellToPoint()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestWorkletMapTopologyExplicit(int, char* [])
|
||||
int UnitTestWorkletMapTopologyExplicit(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestWorkletMapTopologyExplicit);
|
||||
return vtkm::cont::testing::Testing::RunOnDevice(TestWorkletMapTopologyExplicit, argc, argv);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <vtkm/Math.h>
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
|
||||
#include <vtkm/cont/testing/MakeTestDataSet.h>
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
@ -99,11 +100,10 @@ static void TestAvgPointToCell();
|
||||
static void TestAvgCellToPoint();
|
||||
static void TestStructuredUniformPointCoords();
|
||||
|
||||
void TestWorkletMapTopologyUniform()
|
||||
void TestWorkletMapTopologyUniform(vtkm::cont::DeviceAdapterId id)
|
||||
{
|
||||
using DeviceAdapterTraits = vtkm::cont::DeviceAdapterTraits<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
std::cout << "Testing Topology Worklet ( Uniform ) on device adapter: "
|
||||
<< DeviceAdapterTraits::GetName() << std::endl;
|
||||
std::cout << "Testing Topology Worklet ( Uniform ) on device adapter: " << id.GetName()
|
||||
<< std::endl;
|
||||
|
||||
TestMaxPointOrCell();
|
||||
TestAvgPointToCell();
|
||||
@ -246,7 +246,7 @@ static void TestStructuredUniformPointCoords()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestWorkletMapTopologyUniform(int, char* [])
|
||||
int UnitTestWorkletMapTopologyUniform(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestWorkletMapTopologyUniform);
|
||||
return vtkm::cont::testing::Testing::RunOnDevice(TestWorkletMapTopologyUniform, argc, argv);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <vtkm/worklet/Keys.h>
|
||||
|
||||
#include <vtkm/cont/ArrayCopy.h>
|
||||
#include <vtkm/cont/internal/DeviceAdapterTag.h>
|
||||
|
||||
#include <vtkm/cont/testing/Testing.h>
|
||||
|
||||
@ -136,9 +137,9 @@ void TryKeyType(KeyType)
|
||||
vtkm::cont::ArrayHandle<KeyType> keyArray = vtkm::cont::make_ArrayHandle(keyBuffer, ARRAY_SIZE);
|
||||
|
||||
vtkm::cont::ArrayHandle<KeyType> sortedKeys;
|
||||
vtkm::cont::ArrayCopy(keyArray, sortedKeys, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::cont::ArrayCopy(keyArray, sortedKeys);
|
||||
|
||||
vtkm::worklet::Keys<KeyType> keys(sortedKeys, VTKM_DEFAULT_DEVICE_ADAPTER_TAG());
|
||||
vtkm::worklet::Keys<KeyType> keys(sortedKeys);
|
||||
|
||||
vtkm::cont::ArrayHandle<KeyType> valuesToModify;
|
||||
valuesToModify.Allocate(ARRAY_SIZE);
|
||||
@ -185,11 +186,9 @@ void TryKeyType(KeyType)
|
||||
CheckPortal(keyPairOut.GetPortalConstControl());
|
||||
}
|
||||
|
||||
void TestReduceByKey()
|
||||
void TestReduceByKey(vtkm::cont::DeviceAdapterId id)
|
||||
{
|
||||
using DeviceAdapterTraits = vtkm::cont::DeviceAdapterTraits<VTKM_DEFAULT_DEVICE_ADAPTER_TAG>;
|
||||
std::cout << "Testing Map Field on device adapter: " << DeviceAdapterTraits::GetName()
|
||||
<< std::endl;
|
||||
std::cout << "Testing Map Field on device adapter: " << id.GetName() << std::endl;
|
||||
|
||||
std::cout << "Testing vtkm::Id keys." << std::endl;
|
||||
TryKeyType(vtkm::Id());
|
||||
@ -206,7 +205,7 @@ void TestReduceByKey()
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestWorkletReduceByKey(int, char* [])
|
||||
int UnitTestWorkletReduceByKey(int argc, char* argv[])
|
||||
{
|
||||
return vtkm::cont::testing::Testing::Run(TestReduceByKey);
|
||||
return vtkm::cont::testing::Testing::RunOnDevice(TestReduceByKey, argc, argv);
|
||||
}
|
||||
|
@ -105,26 +105,21 @@ public:
|
||||
|
||||
// perform a device copy. The whole 1st array to a certain start location of the 2nd array
|
||||
template <typename ArrayType1, typename ArrayType2>
|
||||
void DeviceCopyStartX(const ArrayType1& srcArray,
|
||||
ArrayType2& dstArray,
|
||||
vtkm::Id startIdx,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
void DeviceCopyStartX(const ArrayType1& srcArray, ArrayType2& dstArray, vtkm::Id startIdx)
|
||||
{
|
||||
using CopyType = vtkm::worklet::wavelets::CopyWorklet;
|
||||
CopyType cp(startIdx);
|
||||
vtkm::worklet::DispatcherMapField<CopyType> dispatcher(cp);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(srcArray, dstArray);
|
||||
}
|
||||
|
||||
// Assign zero value to a certain location of an array
|
||||
template <typename ArrayType>
|
||||
void DeviceAssignZero(ArrayType& array, vtkm::Id index, vtkm::cont::DeviceAdapterId device)
|
||||
void DeviceAssignZero(ArrayType& array, vtkm::Id index)
|
||||
{
|
||||
using ZeroWorklet = vtkm::worklet::wavelets::AssignZeroWorklet;
|
||||
ZeroWorklet worklet(index);
|
||||
vtkm::worklet::DispatcherMapField<ZeroWorklet> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(array);
|
||||
}
|
||||
|
||||
@ -133,13 +128,11 @@ public:
|
||||
void DeviceAssignZero2DRow(ArrayType& array,
|
||||
vtkm::Id dimX,
|
||||
vtkm::Id dimY, // input
|
||||
vtkm::Id rowIdx,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
vtkm::Id rowIdx)
|
||||
{
|
||||
using AssignZero2DType = vtkm::worklet::wavelets::AssignZero2DWorklet;
|
||||
AssignZero2DType zeroWorklet(dimX, dimY, -1, rowIdx);
|
||||
vtkm::worklet::DispatcherMapField<AssignZero2DType> dispatcher(zeroWorklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(array);
|
||||
}
|
||||
|
||||
@ -148,13 +141,11 @@ public:
|
||||
void DeviceAssignZero2DColumn(ArrayType& array,
|
||||
vtkm::Id dimX,
|
||||
vtkm::Id dimY, // input
|
||||
vtkm::Id colIdx,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
vtkm::Id colIdx)
|
||||
{
|
||||
using AssignZero2DType = vtkm::worklet::wavelets::AssignZero2DWorklet;
|
||||
AssignZero2DType zeroWorklet(dimX, dimY, colIdx, -1);
|
||||
vtkm::worklet::DispatcherMapField<AssignZero2DType> dispatcher(zeroWorklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(array);
|
||||
}
|
||||
|
||||
@ -164,13 +155,11 @@ public:
|
||||
vtkm::Id dimX,
|
||||
vtkm::Id dimY,
|
||||
vtkm::Id dimZ, // dims of input
|
||||
vtkm::Id zeroX, // X idx to set zero
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
vtkm::Id zeroX) // X idx to set zero
|
||||
{
|
||||
using AssignZero3DType = vtkm::worklet::wavelets::AssignZero3DWorklet;
|
||||
AssignZero3DType zeroWorklet(dimX, dimY, dimZ, zeroX, -1, -1);
|
||||
vtkm::worklet::DispatcherMapField<AssignZero3DType> dispatcher(zeroWorklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(array);
|
||||
}
|
||||
|
||||
@ -180,13 +169,11 @@ public:
|
||||
vtkm::Id dimX,
|
||||
vtkm::Id dimY,
|
||||
vtkm::Id dimZ, // dims of input
|
||||
vtkm::Id zeroY, // Y idx to set zero
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
vtkm::Id zeroY) // Y idx to set zero
|
||||
{
|
||||
using AssignZero3DType = vtkm::worklet::wavelets::AssignZero3DWorklet;
|
||||
AssignZero3DType zeroWorklet(dimX, dimY, dimZ, -1, zeroY, -1);
|
||||
vtkm::worklet::DispatcherMapField<AssignZero3DType> dispatcher(zeroWorklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(array);
|
||||
}
|
||||
|
||||
@ -196,13 +183,11 @@ public:
|
||||
vtkm::Id dimX,
|
||||
vtkm::Id dimY,
|
||||
vtkm::Id dimZ, // dims of input
|
||||
vtkm::Id zeroZ, // Y idx to set zero
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
vtkm::Id zeroZ) // Y idx to set zero
|
||||
{
|
||||
using AssignZero3DType = vtkm::worklet::wavelets::AssignZero3DWorklet;
|
||||
AssignZero3DType zeroWorklet(dimX, dimY, dimZ, -1, -1, zeroZ);
|
||||
vtkm::worklet::DispatcherMapField<AssignZero3DType> dispatcher(zeroWorklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(array);
|
||||
}
|
||||
|
||||
@ -216,18 +201,16 @@ public:
|
||||
}
|
||||
};
|
||||
template <typename ArrayType>
|
||||
void DeviceSort(ArrayType& array, vtkm::cont::DeviceAdapterId device)
|
||||
void DeviceSort(ArrayType& array)
|
||||
{
|
||||
vtkm::cont::Algorithm::Sort(device, array, SortLessAbsFunctor());
|
||||
vtkm::cont::Algorithm::Sort(array, SortLessAbsFunctor());
|
||||
}
|
||||
|
||||
// Reduce to the sum of all values on device
|
||||
template <typename ArrayType>
|
||||
typename ArrayType::ValueType DeviceSum(const ArrayType& array,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
typename ArrayType::ValueType DeviceSum(const ArrayType& array)
|
||||
{
|
||||
return vtkm::cont::Algorithm::Reduce(
|
||||
device, array, static_cast<typename ArrayType::ValueType>(0.0));
|
||||
return vtkm::cont::Algorithm::Reduce(array, static_cast<typename ArrayType::ValueType>(0.0));
|
||||
}
|
||||
|
||||
// Helper functors for finding the max and min of an array
|
||||
@ -250,18 +233,16 @@ public:
|
||||
|
||||
// Device Min and Max functions
|
||||
template <typename ArrayType>
|
||||
typename ArrayType::ValueType DeviceMax(const ArrayType& array,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
typename ArrayType::ValueType DeviceMax(const ArrayType& array)
|
||||
{
|
||||
typename ArrayType::ValueType initVal = array.GetPortalConstControl().Get(0);
|
||||
return vtkm::cont::Algorithm::Reduce(device, array, initVal, maxFunctor());
|
||||
return vtkm::cont::Algorithm::Reduce(array, initVal, maxFunctor());
|
||||
}
|
||||
template <typename ArrayType>
|
||||
typename ArrayType::ValueType DeviceMin(const ArrayType& array,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
typename ArrayType::ValueType DeviceMin(const ArrayType& array)
|
||||
{
|
||||
typename ArrayType::ValueType initVal = array.GetPortalConstControl().Get(0);
|
||||
return vtkm::cont::Algorithm::Reduce(device, array, initVal, minFunctor());
|
||||
return vtkm::cont::Algorithm::Reduce(array, initVal, minFunctor());
|
||||
}
|
||||
|
||||
// Max absolute value of an array
|
||||
@ -274,18 +255,17 @@ public:
|
||||
}
|
||||
};
|
||||
template <typename ArrayType>
|
||||
typename ArrayType::ValueType DeviceMaxAbs(const ArrayType& array,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
typename ArrayType::ValueType DeviceMaxAbs(const ArrayType& array)
|
||||
{
|
||||
typename ArrayType::ValueType initVal = array.GetPortalConstControl().Get(0);
|
||||
return vtkm::cont::Algorithm::Reduce(device, array, initVal, maxAbsFunctor());
|
||||
return vtkm::cont::Algorithm::Reduce(array, initVal, maxAbsFunctor());
|
||||
}
|
||||
|
||||
// Calculate variance of an array
|
||||
template <typename ArrayType>
|
||||
vtkm::Float64 DeviceCalculateVariance(ArrayType& array, vtkm::cont::DeviceAdapterId device)
|
||||
vtkm::Float64 DeviceCalculateVariance(ArrayType& array)
|
||||
{
|
||||
vtkm::Float64 mean = static_cast<vtkm::Float64>(this->DeviceSum(array, device)) /
|
||||
vtkm::Float64 mean = static_cast<vtkm::Float64>(this->DeviceSum(array)) /
|
||||
static_cast<vtkm::Float64>(array.GetNumberOfValues());
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64> squaredDeviation;
|
||||
@ -294,10 +274,9 @@ public:
|
||||
using SDWorklet = vtkm::worklet::wavelets::SquaredDeviation;
|
||||
SDWorklet sdw(mean);
|
||||
vtkm::worklet::DispatcherMapField<SDWorklet> dispatcher(sdw);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(array, squaredDeviation);
|
||||
|
||||
vtkm::Float64 sdMean = this->DeviceSum(squaredDeviation, device) /
|
||||
vtkm::Float64 sdMean = this->DeviceSum(squaredDeviation) /
|
||||
static_cast<vtkm::Float64>(squaredDeviation.GetNumberOfValues());
|
||||
|
||||
return sdMean;
|
||||
@ -312,13 +291,11 @@ public:
|
||||
vtkm::Id bigX,
|
||||
vtkm::Id bigY,
|
||||
vtkm::Id startX,
|
||||
vtkm::Id startY,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
vtkm::Id startY)
|
||||
{
|
||||
using CopyToWorklet = vtkm::worklet::wavelets::RectangleCopyTo;
|
||||
CopyToWorklet cp(smallX, smallY, bigX, bigY, startX, startY);
|
||||
vtkm::worklet::DispatcherMapField<CopyToWorklet> dispatcher(cp);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(smallRect, bigRect);
|
||||
}
|
||||
|
||||
@ -334,13 +311,11 @@ public:
|
||||
vtkm::Id bigZ,
|
||||
vtkm::Id startX,
|
||||
vtkm::Id startY,
|
||||
vtkm::Id startZ,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
vtkm::Id startZ)
|
||||
{
|
||||
using CopyToWorklet = vtkm::worklet::wavelets::CubeCopyTo;
|
||||
CopyToWorklet cp(smallX, smallY, smallZ, bigX, bigY, bigZ, startX, startY, startZ);
|
||||
vtkm::worklet::DispatcherMapField<CopyToWorklet> dispatcher(cp);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(smallCube, bigCube);
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,7 @@ public:
|
||||
vtkm::worklet::wavelets::DWTMode ext1Method,
|
||||
vtkm::worklet::wavelets::DWTMode ext2Method,
|
||||
bool pretendSigPaddedZero,
|
||||
bool padZeroAtExt2,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
bool padZeroAtExt2)
|
||||
{
|
||||
// pretendSigPaddedZero and padZeroAtExt2 cannot happen at the same time
|
||||
VTKM_ASSERT(!pretendSigPaddedZero || !padZeroAtExt2);
|
||||
@ -78,7 +77,7 @@ public:
|
||||
if (pretendSigPaddedZero || padZeroAtExt2) // plane of size 1*dimY*dimZ
|
||||
{
|
||||
ext2.Allocate(sigPretendDimY * sigPretendDimZ);
|
||||
WaveletBase::DeviceAssignZero3DPlaneX(ext2, 1, sigPretendDimY, sigPretendDimZ, 0, device);
|
||||
WaveletBase::DeviceAssignZero3DPlaneX(ext2, 1, sigPretendDimY, sigPretendDimZ, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -117,7 +116,6 @@ public:
|
||||
dir,
|
||||
false); // not treating input signal as having zeros
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext1, sigIn);
|
||||
}
|
||||
|
||||
@ -145,7 +143,6 @@ public:
|
||||
dir,
|
||||
false);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2, sigIn);
|
||||
}
|
||||
else if (!pretendSigPaddedZero && padZeroAtExt2)
|
||||
@ -170,7 +167,6 @@ public:
|
||||
dir,
|
||||
false);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2, sigIn);
|
||||
}
|
||||
else // pretendSigPaddedZero
|
||||
@ -194,14 +190,13 @@ public:
|
||||
dir,
|
||||
true); // pretend sig is padded a zero
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2Temp, sigIn);
|
||||
|
||||
// Give ext2 one layer thicker to hold the pretend zeros from signal.
|
||||
ext2.Allocate((extDimX + 1) * extDimY * extDimZ);
|
||||
WaveletBase::DeviceCubeCopyTo(
|
||||
ext2Temp, extDimX, extDimY, extDimZ, ext2, extDimX + 1, extDimY, extDimZ, 1, 0, 0, device);
|
||||
WaveletBase::DeviceAssignZero3DPlaneX(ext2, extDimX + 1, extDimY, extDimZ, 0, device);
|
||||
ext2Temp, extDimX, extDimY, extDimZ, ext2, extDimX + 1, extDimY, extDimZ, 1, 0, 0);
|
||||
WaveletBase::DeviceAssignZero3DPlaneX(ext2, extDimX + 1, extDimY, extDimZ, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -224,8 +219,7 @@ public:
|
||||
vtkm::worklet::wavelets::DWTMode ext1Method,
|
||||
vtkm::worklet::wavelets::DWTMode ext2Method,
|
||||
bool pretendSigPaddedZero,
|
||||
bool padZeroAtExt2,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
bool padZeroAtExt2)
|
||||
{
|
||||
// pretendSigPaddedZero and padZeroAtExt2 cannot happen at the same time
|
||||
VTKM_ASSERT(!pretendSigPaddedZero || !padZeroAtExt2);
|
||||
@ -236,7 +230,7 @@ public:
|
||||
if (pretendSigPaddedZero || padZeroAtExt2) // plane of size dimX*dimZ
|
||||
{
|
||||
ext2.Allocate(sigPretendDimX * 1 * sigPretendDimZ);
|
||||
WaveletBase::DeviceAssignZero3DPlaneY(ext2, sigPretendDimX, 1, sigPretendDimZ, 0, device);
|
||||
WaveletBase::DeviceAssignZero3DPlaneY(ext2, sigPretendDimX, 1, sigPretendDimZ, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -275,7 +269,6 @@ public:
|
||||
dir,
|
||||
false); // not treating input signal as having zeros
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext1, sigIn);
|
||||
}
|
||||
|
||||
@ -303,7 +296,6 @@ public:
|
||||
dir,
|
||||
false);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2, sigIn);
|
||||
}
|
||||
else if (!pretendSigPaddedZero && padZeroAtExt2)
|
||||
@ -328,7 +320,6 @@ public:
|
||||
dir,
|
||||
false);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2, sigIn);
|
||||
}
|
||||
else // pretendSigPaddedZero
|
||||
@ -352,14 +343,13 @@ public:
|
||||
dir,
|
||||
true); // pretend sig is padded a zero
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2Temp, sigIn);
|
||||
|
||||
// Give ext2 one layer thicker to hold the pretend zeros from signal.
|
||||
ext2.Allocate(extDimX * (extDimY + 1) * extDimZ);
|
||||
WaveletBase::DeviceCubeCopyTo(
|
||||
ext2Temp, extDimX, extDimY, extDimZ, ext2, extDimX, extDimY + 1, extDimZ, 0, 1, 0, device);
|
||||
WaveletBase::DeviceAssignZero3DPlaneY(ext2, extDimX, extDimY + 1, extDimZ, 0, device);
|
||||
ext2Temp, extDimX, extDimY, extDimZ, ext2, extDimX, extDimY + 1, extDimZ, 0, 1, 0);
|
||||
WaveletBase::DeviceAssignZero3DPlaneY(ext2, extDimX, extDimY + 1, extDimZ, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -382,8 +372,7 @@ public:
|
||||
vtkm::worklet::wavelets::DWTMode ext1Method,
|
||||
vtkm::worklet::wavelets::DWTMode ext2Method,
|
||||
bool pretendSigPaddedZero,
|
||||
bool padZeroAtExt2,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
bool padZeroAtExt2)
|
||||
{
|
||||
// pretendSigPaddedZero and padZeroAtExt2 cannot happen at the same time
|
||||
VTKM_ASSERT(!pretendSigPaddedZero || !padZeroAtExt2);
|
||||
@ -394,7 +383,7 @@ public:
|
||||
if (pretendSigPaddedZero || padZeroAtExt2) // plane of size dimX * dimY
|
||||
{
|
||||
ext2.Allocate(sigPretendDimX * sigPretendDimY * 1);
|
||||
WaveletBase::DeviceAssignZero3DPlaneZ(ext2, sigPretendDimX, sigPretendDimY, 1, 0, device);
|
||||
WaveletBase::DeviceAssignZero3DPlaneZ(ext2, sigPretendDimX, sigPretendDimY, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -433,7 +422,6 @@ public:
|
||||
dir,
|
||||
false); // not treating input signal as having zeros
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext1, sigIn);
|
||||
}
|
||||
|
||||
@ -461,7 +449,6 @@ public:
|
||||
dir,
|
||||
false);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2, sigIn);
|
||||
}
|
||||
else if (!pretendSigPaddedZero && padZeroAtExt2)
|
||||
@ -486,7 +473,6 @@ public:
|
||||
dir,
|
||||
false);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2, sigIn);
|
||||
}
|
||||
else // pretendSigPaddedZero
|
||||
@ -510,14 +496,13 @@ public:
|
||||
dir,
|
||||
true); // pretend sig is padded a zero
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2Temp, sigIn);
|
||||
|
||||
// Give ext2 one layer thicker to hold the pretend zeros from signal.
|
||||
ext2.Allocate(extDimX * extDimY * (extDimZ + 1));
|
||||
WaveletBase::DeviceCubeCopyTo(
|
||||
ext2Temp, extDimX, extDimY, extDimZ, ext2, extDimX, extDimY, extDimZ + 1, 0, 0, 1, device);
|
||||
WaveletBase::DeviceAssignZero3DPlaneZ(ext2, extDimX, extDimY, extDimZ + 1, 0, device);
|
||||
ext2Temp, extDimX, extDimY, extDimZ, ext2, extDimX, extDimY, extDimZ + 1, 0, 0, 1);
|
||||
WaveletBase::DeviceAssignZero3DPlaneZ(ext2, extDimX, extDimY, extDimZ + 1, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -559,8 +544,7 @@ public:
|
||||
vtkm::Id sigPretendDimY,
|
||||
vtkm::Id sigPretendDimZ,
|
||||
ArrayOutType& coeffOut,
|
||||
bool discardSigIn, // discard sigIn on devices
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
bool discardSigIn) // discard sigIn on devices
|
||||
{
|
||||
std::vector<vtkm::Id> L(27, 0);
|
||||
|
||||
@ -642,8 +626,7 @@ public:
|
||||
WaveletBase::wmode,
|
||||
WaveletBase::wmode,
|
||||
false,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
LeftRightXFormType worklet(filterLen,
|
||||
L[0],
|
||||
oddLow,
|
||||
@ -663,7 +646,6 @@ public:
|
||||
sigPretendDimY,
|
||||
sigPretendDimZ);
|
||||
LeftRightDispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(leftExt,
|
||||
sigIn,
|
||||
@ -700,8 +682,7 @@ public:
|
||||
WaveletBase::wmode,
|
||||
WaveletBase::wmode,
|
||||
false,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
TopDownXFormType worklet(filterLen,
|
||||
L[1],
|
||||
oddLow,
|
||||
@ -721,7 +702,6 @@ public:
|
||||
addLen,
|
||||
sigPretendDimZ);
|
||||
TopDownDispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(topExt,
|
||||
afterX,
|
||||
@ -753,8 +733,7 @@ public:
|
||||
WaveletBase::wmode,
|
||||
WaveletBase::wmode,
|
||||
false,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
FrontBackXFormType worklet(filterLen,
|
||||
L[1],
|
||||
oddLow,
|
||||
@ -774,7 +753,6 @@ public:
|
||||
sigPretendDimY,
|
||||
addLen);
|
||||
FrontBackDispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(frontExt,
|
||||
afterY,
|
||||
@ -800,8 +778,7 @@ public:
|
||||
vtkm::Id inStartZ,
|
||||
const std::vector<vtkm::Id>& L,
|
||||
ArrayOutType& sigOut,
|
||||
bool discardCoeffIn, // can we discard coeffIn?
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
bool discardCoeffIn) // can we discard coeffIn?
|
||||
{
|
||||
//VTKM_ASSERT( L.size() == 27 );
|
||||
//VTKM_ASSERT( inDimX * inDimY * inDimZ == coeffIn.GetNumberOfValues() );
|
||||
@ -850,8 +827,7 @@ public:
|
||||
ext3DimZ,
|
||||
ext4DimZ,
|
||||
filterLen,
|
||||
wmode,
|
||||
device);
|
||||
wmode);
|
||||
FrontBackXFormType worklet(filterLen,
|
||||
extDimX,
|
||||
extDimY,
|
||||
@ -878,7 +854,6 @@ public:
|
||||
inStartY,
|
||||
inStartZ); // coeffIn
|
||||
FrontBackDispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
@ -925,8 +900,7 @@ public:
|
||||
ext3DimY,
|
||||
ext4DimY,
|
||||
filterLen,
|
||||
wmode,
|
||||
device);
|
||||
wmode);
|
||||
TopDownXFormType worklet(filterLen,
|
||||
extDimX,
|
||||
ext1DimY,
|
||||
@ -953,7 +927,6 @@ public:
|
||||
0,
|
||||
0);
|
||||
TopDownDispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
@ -994,8 +967,7 @@ public:
|
||||
ext3DimX,
|
||||
ext4DimX,
|
||||
filterLen,
|
||||
wmode,
|
||||
device);
|
||||
wmode);
|
||||
sigOut.Allocate(inPretendDimX * inPretendDimY * inPretendDimZ);
|
||||
LeftRightXFormType worklet(filterLen,
|
||||
ext1DimX,
|
||||
@ -1023,7 +995,6 @@ public:
|
||||
0,
|
||||
0);
|
||||
LeftRightDispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
@ -1056,8 +1027,7 @@ public:
|
||||
vtkm::worklet::wavelets::DWTMode ext2Method,
|
||||
bool pretendSigPaddedZero,
|
||||
bool padZeroAtExt2,
|
||||
bool modeLR, // true = left-right, false = top-down
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
bool modeLR) // true = left-right, false = top-down
|
||||
{
|
||||
// pretendSigPaddedZero and padZeroAtExt2 cannot happen at the same time
|
||||
VTKM_ASSERT(!pretendSigPaddedZero || !padZeroAtExt2);
|
||||
@ -1070,12 +1040,12 @@ public:
|
||||
if (modeLR) // right extension
|
||||
{
|
||||
ext2.Allocate(sigPretendDimY);
|
||||
WaveletBase::DeviceAssignZero2DColumn(ext2, 1, sigPretendDimY, 0, device);
|
||||
WaveletBase::DeviceAssignZero2DColumn(ext2, 1, sigPretendDimY, 0);
|
||||
}
|
||||
else // bottom extension
|
||||
{
|
||||
ext2.Allocate(sigPretendDimX);
|
||||
WaveletBase::DeviceAssignZero2DRow(ext2, sigPretendDimX, 1, 0, device);
|
||||
WaveletBase::DeviceAssignZero2DRow(ext2, sigPretendDimX, 1, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1118,7 +1088,6 @@ public:
|
||||
dir,
|
||||
false); // not treating sigIn as having zeros
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext1, sigIn);
|
||||
}
|
||||
|
||||
@ -1150,7 +1119,6 @@ public:
|
||||
dir,
|
||||
false);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2, sigIn);
|
||||
}
|
||||
else if (!pretendSigPaddedZero && padZeroAtExt2)
|
||||
@ -1180,7 +1148,6 @@ public:
|
||||
dir,
|
||||
false);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2, sigIn);
|
||||
/* Pad a zero at the end of cDTemp, when cDTemp is forced to have the same
|
||||
length as cATemp. For example, with odd length signal, cA is 1 element
|
||||
@ -1224,22 +1191,21 @@ public:
|
||||
dir,
|
||||
true); // pretend sig is padded a zero
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(ext2Temp, sigIn);
|
||||
|
||||
if (modeLR)
|
||||
{
|
||||
ext2.Allocate((extDimX + 1) * extDimY);
|
||||
WaveletBase::DeviceRectangleCopyTo(
|
||||
ext2Temp, extDimX, extDimY, ext2, extDimX + 1, extDimY, 1, 0, device);
|
||||
WaveletBase::DeviceAssignZero2DColumn(ext2, extDimX + 1, extDimY, 0, device);
|
||||
ext2Temp, extDimX, extDimY, ext2, extDimX + 1, extDimY, 1, 0);
|
||||
WaveletBase::DeviceAssignZero2DColumn(ext2, extDimX + 1, extDimY, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ext2.Allocate(extDimX * (extDimY + 1));
|
||||
WaveletBase::DeviceRectangleCopyTo(
|
||||
ext2Temp, extDimX, extDimY, ext2, extDimX, extDimY + 1, 0, 1, device);
|
||||
WaveletBase::DeviceAssignZero2DRow(ext2, extDimX, extDimY + 1, 0, device);
|
||||
ext2Temp, extDimX, extDimY, ext2, extDimX, extDimY + 1, 0, 1);
|
||||
WaveletBase::DeviceAssignZero2DRow(ext2, extDimX, extDimY + 1, 0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -1253,8 +1219,7 @@ public:
|
||||
vtkm::worklet::wavelets::DWTMode leftExtMethod,
|
||||
vtkm::worklet::wavelets::DWTMode rightExtMethod,
|
||||
bool attachZeroRightLeft,
|
||||
bool attachZeroRightRight,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
bool attachZeroRightRight)
|
||||
{
|
||||
// "right extension" can be attached a zero on either end, but not both ends.
|
||||
VTKM_ASSERT(!attachZeroRightRight || !attachZeroRightLeft);
|
||||
@ -1271,7 +1236,7 @@ public:
|
||||
{
|
||||
leftExtend.Allocate(0);
|
||||
rightExtend.Allocate(1);
|
||||
WaveletBase::DeviceAssignZero(rightExtend, 0, device);
|
||||
WaveletBase::DeviceAssignZero(rightExtend, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1301,7 +1266,6 @@ public:
|
||||
{
|
||||
LeftSYMH worklet(addLen);
|
||||
vtkm::worklet::DispatcherMapField<LeftSYMH> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(leftExtend, sigIn);
|
||||
break;
|
||||
}
|
||||
@ -1309,7 +1273,6 @@ public:
|
||||
{
|
||||
LeftSYMW worklet(addLen);
|
||||
vtkm::worklet::DispatcherMapField<LeftSYMW> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(leftExtend, sigIn);
|
||||
break;
|
||||
}
|
||||
@ -1317,7 +1280,6 @@ public:
|
||||
{
|
||||
LeftASYMH worklet(addLen);
|
||||
vtkm::worklet::DispatcherMapField<LeftASYMH> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(leftExtend, sigIn);
|
||||
break;
|
||||
}
|
||||
@ -1325,7 +1287,6 @@ public:
|
||||
{
|
||||
LeftASYMW worklet(addLen);
|
||||
vtkm::worklet::DispatcherMapField<LeftASYMW> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(leftExtend, sigIn);
|
||||
break;
|
||||
}
|
||||
@ -1354,7 +1315,6 @@ public:
|
||||
{
|
||||
RightSYMH worklet(sigInLen);
|
||||
vtkm::worklet::DispatcherMapField<RightSYMH> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(rightExtend, sigIn);
|
||||
break;
|
||||
}
|
||||
@ -1362,7 +1322,6 @@ public:
|
||||
{
|
||||
RightSYMW worklet(sigInLen);
|
||||
vtkm::worklet::DispatcherMapField<RightSYMW> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(rightExtend, sigIn);
|
||||
break;
|
||||
}
|
||||
@ -1370,7 +1329,6 @@ public:
|
||||
{
|
||||
RightASYMH worklet(sigInLen);
|
||||
vtkm::worklet::DispatcherMapField<RightASYMH> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(rightExtend, sigIn);
|
||||
break;
|
||||
}
|
||||
@ -1378,7 +1336,6 @@ public:
|
||||
{
|
||||
RightASYMW worklet(sigInLen);
|
||||
vtkm::worklet::DispatcherMapField<RightASYMW> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(rightExtend, sigIn);
|
||||
break;
|
||||
}
|
||||
@ -1390,7 +1347,7 @@ public:
|
||||
}
|
||||
if (attachZeroRightRight)
|
||||
{
|
||||
WaveletBase::DeviceAssignZero(rightExtend, addLen, device);
|
||||
WaveletBase::DeviceAssignZero(rightExtend, addLen);
|
||||
}
|
||||
}
|
||||
else // attachZeroRightLeft mode
|
||||
@ -1399,7 +1356,7 @@ public:
|
||||
// attach a zero at the end of sigIn
|
||||
ExtensionArrayType singleValArray;
|
||||
singleValArray.Allocate(1);
|
||||
WaveletBase::DeviceAssignZero(singleValArray, 0, device);
|
||||
WaveletBase::DeviceAssignZero(singleValArray, 0);
|
||||
ConcatArray sigInPlusOne(sigIn, singleValArray);
|
||||
|
||||
// allocate memory for extension
|
||||
@ -1411,7 +1368,6 @@ public:
|
||||
{
|
||||
RightSYMH worklet(sigInLen + 1);
|
||||
vtkm::worklet::DispatcherMapField<RightSYMH> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(rightExtend, sigInPlusOne);
|
||||
break;
|
||||
}
|
||||
@ -1419,7 +1375,6 @@ public:
|
||||
{
|
||||
RightSYMW worklet(sigInLen + 1);
|
||||
vtkm::worklet::DispatcherMapField<RightSYMW> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(rightExtend, sigInPlusOne);
|
||||
break;
|
||||
}
|
||||
@ -1427,7 +1382,6 @@ public:
|
||||
{
|
||||
RightASYMH worklet(sigInLen + 1);
|
||||
vtkm::worklet::DispatcherMapField<RightASYMH> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(rightExtend, sigInPlusOne);
|
||||
break;
|
||||
}
|
||||
@ -1435,7 +1389,6 @@ public:
|
||||
{
|
||||
RightASYMW worklet(sigInLen + 1);
|
||||
vtkm::worklet::DispatcherMapField<RightASYMW> dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
dispatcher.Invoke(rightExtend, sigInPlusOne);
|
||||
break;
|
||||
}
|
||||
@ -1449,8 +1402,8 @@ public:
|
||||
// make a copy of rightExtend with a zero attached to the left
|
||||
ExtensionArrayType rightExtendPlusOne;
|
||||
rightExtendPlusOne.Allocate(addLen + 1);
|
||||
WaveletBase::DeviceCopyStartX(rightExtend, rightExtendPlusOne, 1, device);
|
||||
WaveletBase::DeviceAssignZero(rightExtendPlusOne, 0, device);
|
||||
WaveletBase::DeviceCopyStartX(rightExtend, rightExtendPlusOne, 1);
|
||||
WaveletBase::DeviceAssignZero(rightExtendPlusOne, 0);
|
||||
rightExtend = rightExtendPlusOne;
|
||||
}
|
||||
|
||||
@ -1465,8 +1418,7 @@ public:
|
||||
template <typename SignalArrayType, typename CoeffArrayType>
|
||||
vtkm::Float64 DWT1D(const SignalArrayType& sigIn, // Input
|
||||
CoeffArrayType& coeffOut, // Output: cA followed by cD
|
||||
std::vector<vtkm::Id>& L, // Output: how many cA and cD.
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
std::vector<vtkm::Id>& L) // Output: how many cA and cD.
|
||||
{
|
||||
vtkm::Id sigInLen = sigIn.GetNumberOfValues();
|
||||
if (GetWaveletMaxLevel(sigInLen) < 1)
|
||||
@ -1526,7 +1478,7 @@ public:
|
||||
ConcatType2 sigInExtended;
|
||||
|
||||
this->Extend1D(
|
||||
sigIn, sigInExtended, addLen, WaveletBase::wmode, WaveletBase::wmode, false, false, device);
|
||||
sigIn, sigInExtended, addLen, WaveletBase::wmode, WaveletBase::wmode, false, false);
|
||||
//VTKM_ASSERT( sigInExtended.GetNumberOfValues() == sigExtendedLen );
|
||||
|
||||
// initialize a worklet for forward transform
|
||||
@ -1536,7 +1488,6 @@ public:
|
||||
coeffOut.Allocate(sigExtendedLen);
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::wavelets::ForwardTransform> dispatcher(
|
||||
forwardTransform);
|
||||
dispatcher.SetDevice(device);
|
||||
// put a timer
|
||||
vtkm::cont::Timer<> timer;
|
||||
dispatcher.Invoke(sigInExtended,
|
||||
@ -1556,8 +1507,7 @@ public:
|
||||
template <typename CoeffArrayType, typename SignalArrayType>
|
||||
vtkm::Float64 IDWT1D(const CoeffArrayType& coeffIn, // Input, cA followed by cD
|
||||
std::vector<vtkm::Id>& L, // Input, how many cA and cD
|
||||
SignalArrayType& sigOut, // Output
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
SignalArrayType& sigOut) // Output
|
||||
{
|
||||
vtkm::Id filterLen = WaveletBase::filter.GetFilterLength();
|
||||
bool doSymConv = false;
|
||||
@ -1640,24 +1590,24 @@ public:
|
||||
if (doSymConv) // Actually extend cA and cD
|
||||
{
|
||||
// first extend cA to be cATemp
|
||||
this->Extend1D(cA, cATemp, addLen, cALeftMode, cARightMode, false, false, device);
|
||||
this->Extend1D(cA, cATemp, addLen, cALeftMode, cARightMode, false, false);
|
||||
|
||||
// Then extend cD based on extension needs
|
||||
if (cDPadLen > 0)
|
||||
{
|
||||
// Add back the missing final cD, 0.0, before doing extension
|
||||
this->Extend1D(cD, cDTemp, addLen, cDLeftMode, cDRightMode, true, false, device);
|
||||
this->Extend1D(cD, cDTemp, addLen, cDLeftMode, cDRightMode, true, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::Id cDTempLenWouldBe = L[1] + 2 * addLen;
|
||||
if (cDTempLenWouldBe == cDTempLen)
|
||||
{
|
||||
this->Extend1D(cD, cDTemp, addLen, cDLeftMode, cDRightMode, false, false, device);
|
||||
this->Extend1D(cD, cDTemp, addLen, cDLeftMode, cDRightMode, false, false);
|
||||
}
|
||||
else if (cDTempLenWouldBe == cDTempLen - 1)
|
||||
{
|
||||
this->Extend1D(cD, cDTemp, addLen, cDLeftMode, cDRightMode, false, true, device);
|
||||
this->Extend1D(cD, cDTemp, addLen, cDLeftMode, cDRightMode, false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1692,7 +1642,6 @@ public:
|
||||
vtkm::worklet::wavelets::InverseTransformOdd inverseXformOdd(filterLen, L[0], cATempLen);
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::wavelets::InverseTransformOdd> dispatcher(
|
||||
inverseXformOdd);
|
||||
dispatcher.SetDevice(device);
|
||||
// use a timer
|
||||
vtkm::cont::Timer<> timer;
|
||||
dispatcher.Invoke(coeffInExtended,
|
||||
@ -1707,7 +1656,6 @@ public:
|
||||
filterLen, L[0], cATempLen, !doSymConv);
|
||||
vtkm::worklet::DispatcherMapField<vtkm::worklet::wavelets::InverseTransformEven> dispatcher(
|
||||
inverseXformEven);
|
||||
dispatcher.SetDevice(device);
|
||||
// use a timer
|
||||
vtkm::cont::Timer<> timer;
|
||||
dispatcher.Invoke(coeffInExtended,
|
||||
@ -1754,8 +1702,7 @@ public:
|
||||
vtkm::Id sigPretendDimX,
|
||||
vtkm::Id sigPretendDimY,
|
||||
ArrayOutType& coeffOut,
|
||||
std::vector<vtkm::Id>& L,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
std::vector<vtkm::Id>& L)
|
||||
{
|
||||
L[0] = WaveletBase::GetApproxLength(sigPretendDimX);
|
||||
L[2] = L[0];
|
||||
@ -1804,8 +1751,7 @@ public:
|
||||
WaveletBase::wmode,
|
||||
false,
|
||||
false,
|
||||
true, // Extend in left-right direction
|
||||
device);
|
||||
true); // Extend in left-right direction
|
||||
ForwardXForm worklet(filterLen,
|
||||
L[0],
|
||||
oddLow,
|
||||
@ -1821,7 +1767,6 @@ public:
|
||||
addLen,
|
||||
sigPretendDimY);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(leftExt,
|
||||
sigIn,
|
||||
@ -1850,8 +1795,7 @@ public:
|
||||
WaveletBase::wmode,
|
||||
false,
|
||||
false,
|
||||
false, // Extend in top-down direction
|
||||
device);
|
||||
false); // Extend in top-down direction
|
||||
ForwardXForm worklet(filterLen,
|
||||
L[1],
|
||||
oddLow,
|
||||
@ -1867,7 +1811,6 @@ public:
|
||||
sigPretendDimX,
|
||||
addLen);
|
||||
DispatcherType dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(topExt,
|
||||
afterX,
|
||||
@ -1890,8 +1833,7 @@ public:
|
||||
vtkm::Id inStartX,
|
||||
vtkm::Id inStartY,
|
||||
const std::vector<vtkm::Id>& L,
|
||||
ArrayOutType& sigOut,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
ArrayOutType& sigOut)
|
||||
{
|
||||
vtkm::Id inPretendDimX = L[0] + L[4];
|
||||
vtkm::Id inPretendDimY = L[1] + L[3];
|
||||
@ -1927,8 +1869,7 @@ public:
|
||||
ext3DimY,
|
||||
ext4DimY,
|
||||
filterLen,
|
||||
wmode,
|
||||
device);
|
||||
wmode);
|
||||
|
||||
afterY.Allocate(inPretendDimX * inPretendDimY);
|
||||
IDWT2DWorklet worklet(filterLen,
|
||||
@ -1950,7 +1891,6 @@ public:
|
||||
inStartY, // coeffIn
|
||||
false); // top-down
|
||||
Dispatcher dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
@ -1986,8 +1926,7 @@ public:
|
||||
ext3DimX,
|
||||
ext4DimX,
|
||||
filterLen,
|
||||
wmode,
|
||||
device);
|
||||
wmode);
|
||||
sigOut.Allocate(inPretendDimX * inPretendDimY);
|
||||
IDWT2DWorklet worklet(filterLen,
|
||||
ext1DimX,
|
||||
@ -2008,7 +1947,6 @@ public:
|
||||
0,
|
||||
true); // left-right
|
||||
Dispatcher dispatcher(worklet);
|
||||
dispatcher.SetDevice(device);
|
||||
timer.Reset();
|
||||
dispatcher.Invoke(ext1,
|
||||
ext2,
|
||||
@ -2045,8 +1983,7 @@ public:
|
||||
vtkm::Id& ext3DimX,
|
||||
vtkm::Id& ext4DimX, // output
|
||||
vtkm::Id filterLen,
|
||||
DWTMode mode,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
DWTMode mode)
|
||||
{
|
||||
VTKM_ASSERT(inPretendDimX == (cADimX + cDDimX));
|
||||
|
||||
@ -2106,8 +2043,7 @@ public:
|
||||
cARight,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
device);
|
||||
true);
|
||||
|
||||
ext1DimX = ext2DimX = addLen;
|
||||
|
||||
@ -2129,8 +2065,7 @@ public:
|
||||
cDRight,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
device);
|
||||
true);
|
||||
ext3DimX = addLen;
|
||||
ext4DimX = addLen + 1;
|
||||
}
|
||||
@ -2153,8 +2088,7 @@ public:
|
||||
cDRight,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
device);
|
||||
true);
|
||||
ext3DimX = ext4DimX = addLen;
|
||||
}
|
||||
else if (cDExtendedWouldBe == cDExtendedDimX - 1)
|
||||
@ -2173,8 +2107,7 @@ public:
|
||||
cDRight,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
device);
|
||||
true);
|
||||
ext3DimX = addLen;
|
||||
ext4DimX = addLen + 1;
|
||||
}
|
||||
@ -2206,8 +2139,7 @@ public:
|
||||
vtkm::Id& ext3DimY,
|
||||
vtkm::Id& ext4DimY, // output
|
||||
vtkm::Id filterLen,
|
||||
DWTMode mode,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
DWTMode mode)
|
||||
{
|
||||
VTKM_ASSERT(inPretendDimY == (cADimY + cDDimY));
|
||||
|
||||
@ -2265,8 +2197,7 @@ public:
|
||||
cADownMode,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
ext1DimY = ext2DimY = addLen;
|
||||
|
||||
// extend cD
|
||||
@ -2287,8 +2218,7 @@ public:
|
||||
cDDownMode,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
ext3DimY = addLen;
|
||||
ext4DimY = addLen + 1;
|
||||
}
|
||||
@ -2311,8 +2241,7 @@ public:
|
||||
cDDownMode,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
ext3DimY = ext4DimY = addLen;
|
||||
}
|
||||
else if (cDExtendedWouldBe == cDExtendedDimY - 1)
|
||||
@ -2331,8 +2260,7 @@ public:
|
||||
cDDownMode,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
ext3DimY = addLen;
|
||||
ext4DimY = addLen + 1;
|
||||
}
|
||||
@ -2367,8 +2295,7 @@ public:
|
||||
vtkm::Id& ext3DimX,
|
||||
vtkm::Id& ext4DimX, // output
|
||||
vtkm::Id filterLen,
|
||||
DWTMode mode,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
DWTMode mode)
|
||||
{
|
||||
VTKM_ASSERT(inPretendDimX == (cADimX + cDDimX));
|
||||
|
||||
@ -2432,8 +2359,7 @@ public:
|
||||
cALeftMode,
|
||||
cARightMode,
|
||||
false,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
ext1DimX = ext2DimX = addLen;
|
||||
|
||||
// extend cD
|
||||
@ -2485,8 +2411,7 @@ public:
|
||||
cDLeftMode,
|
||||
cDRightMode,
|
||||
pretendSigPaddedZero,
|
||||
padZeroAtExt2,
|
||||
device);
|
||||
padZeroAtExt2);
|
||||
}
|
||||
|
||||
template <typename ArrayInType, typename ArrayOutType>
|
||||
@ -2511,8 +2436,7 @@ public:
|
||||
vtkm::Id& ext3DimY,
|
||||
vtkm::Id& ext4DimY, // output
|
||||
vtkm::Id filterLen,
|
||||
DWTMode mode,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
DWTMode mode)
|
||||
{
|
||||
VTKM_ASSERT(inPretendDimY == (cADimY + cDDimY));
|
||||
|
||||
@ -2576,8 +2500,7 @@ public:
|
||||
cATopMode,
|
||||
cADownMode,
|
||||
false,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
ext1DimY = ext2DimY = addLen;
|
||||
|
||||
// extend cD
|
||||
@ -2629,8 +2552,7 @@ public:
|
||||
cDTopMode,
|
||||
cDDownMode,
|
||||
pretendSigPaddedZero,
|
||||
padZeroAtExt2,
|
||||
device);
|
||||
padZeroAtExt2);
|
||||
}
|
||||
|
||||
template <typename ArrayInType, typename ArrayOutType>
|
||||
@ -2655,8 +2577,7 @@ public:
|
||||
vtkm::Id& ext3DimZ,
|
||||
vtkm::Id& ext4DimZ, // output
|
||||
vtkm::Id filterLen,
|
||||
DWTMode mode,
|
||||
vtkm::cont::DeviceAdapterId device)
|
||||
DWTMode mode)
|
||||
{
|
||||
VTKM_ASSERT(inPretendDimZ == (cADimZ + cDDimZ));
|
||||
|
||||
@ -2720,8 +2641,7 @@ public:
|
||||
cAFrontMode,
|
||||
cABackMode,
|
||||
false,
|
||||
false,
|
||||
device);
|
||||
false);
|
||||
ext1DimZ = ext2DimZ = addLen;
|
||||
|
||||
// extend cD
|
||||
@ -2773,8 +2693,7 @@ public:
|
||||
cDFrontMode,
|
||||
cDBackMode,
|
||||
pretendSigPaddedZero,
|
||||
padZeroAtExt2,
|
||||
device);
|
||||
padZeroAtExt2);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user