From d5a2c52c5772661e1e78e47ed6179e74b08b1258 Mon Sep 17 00:00:00 2001 From: Nicole Marsaglia Date: Mon, 9 Sep 2024 16:30:23 -0700 Subject: [PATCH] things build with doubs, now unsigned long long. --- .../runtimes/ascent_vtkh_data_adapter.cpp | 26 +++++++++---------- src/libs/vtkh/utils/vtkm_array_utils.hpp | 19 +++++++++----- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp b/src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp index f7fde18f7..19f4bf8b5 100644 --- a/src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp +++ b/src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include // other ascent includes @@ -1664,21 +1664,21 @@ std::cerr << "NOT SUPPORTED" << std::endl; // convert to float64, we use this as a comprise to cover the widest range std::cerr << "AF 7" << std::endl; vtkm::cont::ArrayHandle vtkm_arr; -std::cerr << "AF 8" << std::endl; vtkm_arr.Allocate(num_vals); -std::cerr << "AF 9" << std::endl; // TODO -- FUTURE: Do this conversion w/ device if on device -std::cerr << "AF 10" << std::endl; - void *ptr = (void*) vtkh::GetVTKMPointer(vtkm_arr); -std::cerr << "AF 11" << std::endl; - Node n_tmp; -std::cerr << "AF 12" << std::endl; - n_tmp.set_external(DataType::float64(num_vals),ptr); - const unsigned long long *input = n_vals.value(); - vtkm::cont::ArrayHandle input_arr = vtkm::cont::make_ArrayHandle(vtkm_arr,input_arr); -std::cerr<< " before calling cast" <().Invoke(input_arr,vtkm_arr); + //void *ptr = (void*) vtkh::GetVTKMPointer(vtkm_arr); + //Node n_tmp; + //n_tmp.set_external(DataType::float64(num_vals),ptr); + const double *input = n_vals.value(); + vtkm::cont::ArrayHandle input_arr = vtkm::cont::make_ArrayHandle(input, num_vals, vtkm::CopyFlag::On); + //const unsigned long long *input = n_vals.value(); + //vtkm::cont::ArrayHandle input_arr = vtkm::cont::make_ArrayHandle(input, num_vals); + vtkm::cont::Invoker invoker; + //vtkm::worklet::DispatcherMapField().Invoke(input_arr,vtkm_arr); + //vtkh::VTKmTypeCast worklet; + vtkh::VTKmTypeCast worklet; + invoker(worklet,input_arr,vtkm_arr); // VTKHDeviceAdapter::castUint64ToFloat64(input, output2, num_vals); std::cerr<< " after calling cast" < +#include namespace vtkh { @@ -12,16 +13,22 @@ GetVTKMPointer(vtkm::cont::ArrayHandle &handle) return handle.WritePortal().GetArray(); } -struct VTKmTypeCast : public vtkm::worklet::WorkletMapField +class VTKmTypeCast : public vtkm::worklet::WorkletMapField { - using ControlSignature = void(FieldIn input, FieldOut output); - using ExecutionSignature = void(_1, _2); +public: + VTKM_CONT + VTKmTypeCast() = default; - // Use VTKM_EXEC for the operator() function to make it run on both host and device + using ControlSignature = void(FieldIn, FieldOut); + using ExecutionSignature = void( _1, _2); + //using ExecutionSignature = void(InputIndex, _1, _2); + + //void operator()(const vtkm::Id idx, const vtkm::cont::ArrayHandle &input, vtkm::cont::ArrayHandle &output) const template - VTKM_EXEC void operator()(const InType& input, OutType& output) const + VTKM_EXEC + void operator()(const InType &input, OutType &output) const { - // Cast input to the output type and assign it + //output.Set(idx, static_cast(input[idx])); output = static_cast(input); } };