From 690304821fc9a07da9d76aa44e31f98875e25a5b Mon Sep 17 00:00:00 2001 From: Nicole Marsaglia Date: Tue, 10 Sep 2024 15:28:57 -0700 Subject: [PATCH] things work, gonna try out the one line reinterpret_cast --- .../runtimes/ascent_vtkh_data_adapter.cpp | 179 +++++++++++------- 1 file changed, 108 insertions(+), 71 deletions(-) diff --git a/src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp b/src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp index a933c0855..234fef860 100644 --- a/src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp +++ b/src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp @@ -1535,7 +1535,7 @@ std::cerr << "AF 6" << std::endl; try { -std::cerr << "SUPPORTED" << std::endl; +std::cerr << "TRY SUPPORTED" << std::endl; bool supported_type = false; // vtk-m can stride as long as the strides are a multiple of the native stride @@ -1598,6 +1598,7 @@ std::cerr << "stride \% sizeof(float64) = " << stride % sizeof(float64) << std:: zero_copy)); supported_type = true; } +std::cerr << "HJERE ini end float64" << std::endl; } // *********************************************************************** // NOTE: TODO OUR VTK-M is not compiled with int32 and int64 support ... @@ -1607,93 +1608,99 @@ std::cerr << "stride \% sizeof(float64) = " << stride % sizeof(float64) << std:: // Array: valueType=x storageType=N4vtkm4cont15StorageTagBasicE 27 values occupying 216 bytes [0 1 2 ... 24 25 26] // TypeList: N4vtkm4ListIJfdEEE // *********************************************************************** + // *********************************************************************** + // NOTE: int32 should work as of sept 10 2024 + // *********************************************************************** // - // else if(n_vals.dtype().is_int32()) - // { - // // check that the byte stride is a multiple of native stride - // index_t stride = n_vals.dtype().stride(); - // index_t element_stride = stride / sizeof(int32); - // //std::cout << "field name: " << field_name << " " - // // << " byte stride: " << stride - // // << " element_stride: " << element_stride << std::endl; - // // if element_stride is evenly divided by native, we are good to - // // use vtk m array handles - // if( stride % sizeof(int32) == 0 ) - // { - // // in this case we can use a strided array handle - // dset->AddField(detail::GetField(n_vals, - // field_name, - // assoc_str, - // topo_name, - // element_stride, - // zero_copy)); - // supported_type = true; - // } - // } - // else if(n_vals.dtype().is_int64()) - // { - // // check that the byte stride is a multiple of native stride - // index_t stride = n_vals.dtype().stride(); - // index_t element_stride = stride / sizeof(int64); - // //std::cout << "field name: " << field_name << " " - // // << " byte stride: " << stride - // // << " element_stride: " << element_stride << std::endl; - // // if element_stride is evenly divided by native, we are good to - // // use vtk m array handles - // if( stride % sizeof(int64) == 0 ) - // { - // // in this case we can use a strided array handle - // dset->AddField(detail::GetField(n_vals, - // field_name, - // assoc_str, - // topo_name, - // element_stride, - // zero_copy)); - // supported_type = true; - // } - // } + //else if(n_vals.dtype().is_int32()) + //{ + // // check that the byte stride is a multiple of native stride + // index_t stride = n_vals.dtype().stride(); + // index_t element_stride = stride / sizeof(int32); + // //std::cout << "field name: " << field_name << " " + // // << " byte stride: " << stride + // // << " element_stride: " << element_stride << std::endl; + // // if element_stride is evenly divided by native, we are good to + // // use vtk m array handles + // if( stride % sizeof(int32) == 0 ) + // { + // // in this case we can use a strided array handle + // dset->AddField(detail::GetField(n_vals, + // field_name, + // assoc_str, + // topo_name, + // element_stride, + // zero_copy)); + // supported_type = true; + // } + //} + //else if(n_vals.dtype().is_int64()) + //{ + // // check that the byte stride is a multiple of native stride + // index_t stride = n_vals.dtype().stride(); + // index_t element_stride = stride / sizeof(int64); + // //std::cout << "field name: " << field_name << " " + // // << " byte stride: " << stride + // // << " element_stride: " << element_stride << std::endl; + // // if element_stride is evenly divided by native, we are good to + // // use vtk m array handles + // if( stride % sizeof(int64) == 0 ) + // { + // // in this case we can use a strided array handle + // dset->AddField(detail::GetField(n_vals, + // field_name, + // assoc_str, + // topo_name, + // element_stride, + // zero_copy)); + // supported_type = true; + // } + //} + //else if(n_vals.dtype().is_uint64()) + //{ + // // check that the byte stride is a multiple of native stride + // index_t stride = n_vals.dtype().stride(); + // index_t element_stride = stride / sizeof(uint64); + // //std::cout << "field name: " << field_name << " " + // // << " byte stride: " << stride + // // << " element_stride: " << element_stride << std::endl; + // // if element_stride is evenly divided by native, we are good to + // // use vtk m array handles + // if( stride % sizeof(uint64) == 0 ) + // { + // // in this case we can use a strided array handle + // dset->AddField(detail::GetField(n_vals, + // field_name, + // assoc_str, + // topo_name, + // element_stride, + // zero_copy)); + // supported_type = true; + // } + //} // vtk-m cant support zero copy for this layout or was not compiled to expose this datatype // use float64 by default if(!supported_type) { -std::cerr << "NOT SUPPORTED" << std::endl; + + // std::cout << "WE ARE IN UNSUPPORTED DATA TYPE: " + // << n_vals.dtype().name() << std::endl; if(n_vals.dtype().is_uint64()) { - // std::cout << "WE ARE IN UNSUPPORTED DATA TYPE: " - // << n_vals.dtype().name() << std::endl; +std::cerr << "HERE IN UNSUPPORTED uint75" << 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 - //void *ptr = (void*) vtkh::GetVTKMPointer(vtkm_arr); - //Node n_tmp; - //n_tmp.set_external(DataType::float64(num_vals),ptr); const unsigned long long *input = n_vals.value(); -std::cerr << "AF 10" << std::endl; vtkm::cont::ArrayHandle input_arr = vtkm::cont::make_ArrayHandle(input, num_vals, vtkm::CopyFlag::Off); -std::cerr << "AF 11" << std::endl; - //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; -std::cerr << "AF 7" << std::endl; -std::cerr<< " before calling cast" < vtkm_arr; + vtkm_arr.Allocate(num_vals); + + // TODO -- FUTURE: Do this conversion w/ device if on device + void *ptr = (void*) vtkh::GetVTKMPointer(vtkm_arr); + Node n_tmp; + n_tmp.set_external(DataType::float64(num_vals),ptr); + n_vals.to_float64_array(n_tmp); + + // add field to dataset + if(assoc_str == "vertex") + { + dset->AddField(vtkm::cont::Field(field_name.c_str(), + vtkm::cont::Field::Association::Points, + vtkm_arr)); + } + else if( assoc_str == "element") + { + dset->AddField(vtkm::cont::Field(field_name.c_str(), + vtkm::cont::Field::Association::Cells, + vtkm_arr)); + } + } // else // { // std::cout << "SUPPORTED DATA TYPE: " // << n_vals.dtype().name() << std::endl; // } + } } catch (vtkm::cont::Error error) {