Skip to content

Commit

Permalink
things build with doubs, now unsigned long long.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolemarsaglia committed Sep 9, 2024
1 parent 46290b9 commit d5a2c52
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
26 changes: 13 additions & 13 deletions src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleExtractComponent.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/cont/Invoker.h>
#include <vtkh/DataSet.hpp>

// other ascent includes
Expand Down Expand Up @@ -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::Float64> 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<unsigned long long> input_arr = vtkm::cont::make_ArrayHandle(vtkm_arr,input_arr);
std::cerr<< " before calling cast" <<std::endl;
vtkm::worklet::DispatcherMapField<vtkh::VTKMTypeCast>().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<double> input_arr = vtkm::cont::make_ArrayHandle(input, num_vals, vtkm::CopyFlag::On);
//const unsigned long long *input = n_vals.value();
//vtkm::cont::ArrayHandle<unsigned long long> input_arr = vtkm::cont::make_ArrayHandle(input, num_vals);
vtkm::cont::Invoker invoker;
//vtkm::worklet::DispatcherMapField<vtkh::VTKmTypeCast>().Invoke(input_arr,vtkm_arr);
//vtkh::VTKmTypeCast<double,vtkm::Float64> worklet;
vtkh::VTKmTypeCast worklet;
invoker(worklet,input_arr,vtkm_arr);
// VTKHDeviceAdapter::castUint64ToFloat64(input, output2, num_vals);
std::cerr<< " after calling cast" <<std::endl;

Expand Down
19 changes: 13 additions & 6 deletions src/libs/vtkh/utils/vtkm_array_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define VTKH_VTKM_ARRAY_UTILS_HPP

#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/worklet/WorkletMapField.h>

namespace vtkh {

Expand All @@ -12,16 +13,22 @@ GetVTKMPointer(vtkm::cont::ArrayHandle<T> &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<InType> &input, vtkm::cont::ArrayHandle<OutType> &output) const
template<typename InType, typename OutType>
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<OutType>(input[idx]));
output = static_cast<OutType>(input);
}
};
Expand Down

0 comments on commit d5a2c52

Please sign in to comment.