Skip to content

Commit

Permalink
fix with one of the zstride coords calcs, simplify ascent render poly…
Browse files Browse the repository at this point in the history
… test cases
  • Loading branch information
cyrush committed Dec 6, 2023
1 parent 6cd6d7a commit 728a977
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 91 deletions.
53 changes: 30 additions & 23 deletions src/libs/ascent/runtimes/ascent_vtkh_data_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ GetExplicitCoordinateSystem(const conduit::Node &n_coords,
int x_verts_expanded = nverts * x_element_stride;
const T *x_verts_ptr = n_coords["values/x"].value();
vtkm::cont::ArrayHandle<T> x_source_array = vtkm::cont::make_ArrayHandle<T>(x_verts_ptr,
x_verts_expanded,
copy);
x_verts_expanded,
copy);
vtkm::cont::ArrayHandleStride<T> x_stride_handle(x_source_array,
nverts,
x_element_stride,
0);
nverts,
x_element_stride,
0); // offset

vtkm::cont::Algorithm::Copy(x_stride_handle, x_coords_handle);
}
Expand All @@ -186,22 +186,23 @@ GetExplicitCoordinateSystem(const conduit::Node &n_coords,
int y_verts_expanded = nverts * y_element_stride;
const T *y_verts_ptr = n_coords["values/y"].value();
vtkm::cont::ArrayHandle<T> y_source_array = vtkm::cont::make_ArrayHandle<T>(y_verts_ptr,
y_verts_expanded,
copy);
y_verts_expanded,
copy);
vtkm::cont::ArrayHandleStride<T> y_stride_handle(y_source_array,
nverts,
y_element_stride,
0);
nverts,
y_element_stride,
0); // offset

vtkm::cont::Algorithm::Copy(y_stride_handle, y_coords_handle);
}

if(z_element_stride == 0)
{
z_coords_handle.Allocate(nverts);
// TODO: Set on device?
// This does not get initialized to zero
T *z = vtkh::GetVTKMPointer(z_coords_handle);
memset(z, 0.0, nverts * sizeof(T));
memset(z, 0, nverts * sizeof(T));
}
else if(z_element_stride == 1)
{
Expand All @@ -215,12 +216,12 @@ GetExplicitCoordinateSystem(const conduit::Node &n_coords,
int z_verts_expanded = nverts * z_element_stride;
const T *z_verts_ptr = n_coords["values/z"].value();
vtkm::cont::ArrayHandle<T> z_source_array = vtkm::cont::make_ArrayHandle<T>(z_verts_ptr,
z_verts_expanded,
copy);
z_verts_expanded,
copy);
vtkm::cont::ArrayHandleStride<T> z_stride_handle(z_source_array,
nverts,
z_element_stride,
0);
nverts,
z_element_stride,
0); // offset

vtkm::cont::Algorithm::Copy(z_stride_handle, z_coords_handle);
}
Expand Down Expand Up @@ -1144,12 +1145,13 @@ VTKHDataAdapter::StructuredBlueprintToVTKmDataSet
index_t x_element_stride = x_stride / sizeof(float64);
index_t y_stride = n_coords["values/y"].dtype().stride();
index_t y_element_stride = y_stride / sizeof(float64);
index_t z_element_stride = 0.0;
index_t z_element_stride = 0;
if(n_coords.has_path("values/z"))
{
index_t z_stride = n_coords["values/z"].dtype().stride();
z_element_stride = z_stride / sizeof(float64);
}

coords = detail::GetExplicitCoordinateSystem<float64>(n_coords,
coords_name,
ndims,
Expand All @@ -1164,12 +1166,13 @@ VTKHDataAdapter::StructuredBlueprintToVTKmDataSet
index_t x_element_stride = x_stride / sizeof(float32);
index_t y_stride = n_coords["values/y"].dtype().stride();
index_t y_element_stride = y_stride / sizeof(float32);
index_t z_element_stride = 0.0;
index_t z_element_stride = 0;
if(n_coords.has_path("values/z"))
{
index_t z_stride = n_coords["values/z"].dtype().stride();
z_element_stride = z_stride / sizeof(float32);
}

coords = detail::GetExplicitCoordinateSystem<float32>(n_coords,
coords_name,
ndims,
Expand Down Expand Up @@ -1239,12 +1242,13 @@ VTKHDataAdapter::PointsImplicitBlueprintToVTKmDataSet
index_t x_element_stride = x_stride / sizeof(float64);
index_t y_stride = n_coords["values/y"].dtype().stride();
index_t y_element_stride = y_stride / sizeof(float64);
index_t z_element_stride = 0.0;
index_t z_element_stride = 0;
if(n_coords.has_path("values/z"))
{
index_t z_stride = n_coords["values/z"].dtype().stride();
z_element_stride = z_stride / sizeof(float64);
}

coords = detail::GetExplicitCoordinateSystem<float64>(n_coords,
coords_name,
ndims,
Expand All @@ -1259,12 +1263,13 @@ VTKHDataAdapter::PointsImplicitBlueprintToVTKmDataSet
index_t x_element_stride = x_stride / sizeof(float32);
index_t y_stride = n_coords["values/y"].dtype().stride();
index_t y_element_stride = y_stride / sizeof(float32);
index_t z_element_stride = 0.0;
index_t z_element_stride = 0;
if(n_coords.has_path("values/z"))
{
index_t z_stride = n_coords["values/z"].dtype().stride();
z_element_stride = z_stride / sizeof(float32);
}

coords = detail::GetExplicitCoordinateSystem<float32>(n_coords,
coords_name,
ndims,
Expand Down Expand Up @@ -1324,12 +1329,13 @@ VTKHDataAdapter::UnstructuredBlueprintToVTKmDataSet
index_t x_element_stride = x_stride / sizeof(float64);
index_t y_stride = n_coords["values/y"].dtype().stride();
index_t y_element_stride = y_stride / sizeof(float64);
index_t z_element_stride = 0.0;
index_t z_element_stride = 0;
if(n_coords.has_path("values/z"))
{
index_t z_stride = n_coords["values/z"].dtype().stride();
z_element_stride = z_stride / sizeof(float64);
}

//TODO:
//can we assume all by checking one?
//or check ystride & zstride % float64 == 0?
Expand All @@ -1350,12 +1356,13 @@ VTKHDataAdapter::UnstructuredBlueprintToVTKmDataSet
index_t x_element_stride = x_stride / sizeof(float32);
index_t y_stride = n_coords["values/y"].dtype().stride();
index_t y_element_stride = y_stride / sizeof(float32);
index_t z_element_stride = 0.0;
index_t z_element_stride = 0;
if(n_coords.has_path("values/z"))
{
index_t z_stride = n_coords["values/z"].dtype().stride();
index_t z_element_stride = z_stride / sizeof(float32);
z_element_stride = z_stride / sizeof(float32);
}

//TODO:
//can we assume all by checking one?
//or check ystride & zstride % float64 == 0?
Expand Down
58 changes: 17 additions & 41 deletions src/tests/ascent/t_ascent_render_2d_poly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,24 @@ TEST(ascent_pipeline, test_render_2d_poly)
//
// Create the actions.
//
conduit::Node scenes;
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "level";
scenes["s1/image_prefix"] = output_file;

conduit::Node actions;
conduit::Node &add_plots = actions.append();
add_plots["action"] = "add_scenes";
add_plots["scenes"] = scenes;
conduit::Node &scenes = add_plots["scenes"];
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "level";
scenes["s1/image_prefix"] = output_file;
actions.print();

//
// Run Ascent
//

Ascent ascent;

Node ascent_opts;
Node ascent_info;
ascent_opts["runtime/type"] = "ascent";
ascent.open(ascent_opts);
ascent.open();
ascent.publish(data);
ascent.execute(actions);
ascent.info(ascent_info);
EXPECT_EQ(ascent_info["runtime/type"].as_string(), "ascent");
ascent_info.print();
ascent.close();

//
Expand Down Expand Up @@ -134,32 +126,23 @@ TEST(ascent_pipeline, test_render_2d_poly_multi)
//
// Create the actions.
//
conduit::Node scenes;
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "level";
scenes["s1/image_prefix"] = output_file;

conduit::Node actions;
conduit::Node &add_plots = actions.append();
add_plots["action"] = "add_scenes";
add_plots["scenes"] = scenes;
conduit::Node &scenes = add_plots["scenes"];
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "level";
scenes["s1/image_prefix"] = output_file;
actions.print();

//
// Run Ascent
//

Ascent ascent;

Node ascent_opts;
Node ascent_info;
ascent_opts["runtime/type"] = "ascent";
ascent.open(ascent_opts);
ascent.open();
ascent.publish(root);
ascent.execute(actions);
ascent.info(ascent_info);
EXPECT_EQ(ascent_info["runtime/type"].as_string(), "ascent");
ascent_info.print();
ascent.close();

//
Expand Down Expand Up @@ -209,35 +192,28 @@ TEST(ascent_pipeline, test_render_2d_poly_and_nonpoly)
//
// Create the actions.
//
conduit::Node scenes;


conduit::Node actions;
conduit::Node &add_plots = actions.append();
add_plots["action"] = "add_scenes";
conduit::Node &scenes = add_plots["scenes"];
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "level";
scenes["s1/image_prefix"] = output_file + "polytess";
scenes["s2/plots/p1/type"] = "pseudocolor";
scenes["s2/plots/p1/field"] = "braid";
scenes["s2/image_prefix"] = output_file + "braid";

conduit::Node actions;
conduit::Node &add_plots = actions.append();
add_plots["action"] = "add_scenes";
add_plots["scenes"] = scenes;
actions.print();

//
// Run Ascent
//

Ascent ascent;

Node ascent_opts;
Node ascent_info;
ascent_opts["runtime/type"] = "ascent";
ascent.open(ascent_opts);
ascent.open();
ascent.publish(data);
ascent.execute(actions);
ascent.info(ascent_info);
EXPECT_EQ(ascent_info["runtime/type"].as_string(), "ascent");
ascent_info.print();
ascent.close();

//
Expand Down
37 changes: 10 additions & 27 deletions src/tests/ascent/t_ascent_render_3d_poly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ TEST(ascent_pipeline, test_render_3d_poly)
index_t length = 10;

conduit::blueprint::mesh::examples::polychain(length, data);

EXPECT_TRUE(conduit::blueprint::mesh::verify(data, verify_info));

string output_path = prepare_output_dir();
Expand All @@ -52,34 +51,25 @@ TEST(ascent_pipeline, test_render_3d_poly)
//
// Create the actions.
//
conduit::Node scenes;
conduit::Node actions;
conduit::Node &add_plots = actions.append();
add_plots["action"] = "add_scenes";
conduit::Node &scenes = add_plots["scenes"];
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "chain";
scenes["s1/image_prefix"] = output_file;

conduit::Node actions;
conduit::Node &add_plots = actions.append();
add_plots["action"] = "add_scenes";
add_plots["scenes"] = scenes;
actions.print();

//
// Run Ascent
//

Ascent ascent;

Node ascent_opts;
Node ascent_info;
ascent_opts["runtime/type"] = "ascent";
ascent.open(ascent_opts);
ascent.open();
ascent.publish(data);
ascent.execute(actions);
ascent.info(ascent_info);
EXPECT_EQ(ascent_info["runtime/type"].as_string(), "ascent");
ascent_info.print();
ascent.close();

//
// // check that we created an image
EXPECT_TRUE(check_test_image(output_file, 0.001f, "0"));
Expand Down Expand Up @@ -134,15 +124,13 @@ TEST(ascent_pipeline, test_render_3d_poly_multi)
//
// Create the actions.
//
conduit::Node scenes;
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "level";
scenes["s1/image_prefix"] = output_file;

conduit::Node actions;
conduit::Node &add_plots = actions.append();
add_plots["action"] = "add_scenes";
add_plots["scenes"] = scenes;
conduit::Node &scenes = add_plots["scenes"];
scenes["s1/plots/p1/type"] = "pseudocolor";
scenes["s1/plots/p1/field"] = "level";
scenes["s1/image_prefix"] = output_file;
actions.print();

//
Expand All @@ -152,14 +140,9 @@ TEST(ascent_pipeline, test_render_3d_poly_multi)
Ascent ascent;

Node ascent_opts;
Node ascent_info;
ascent_opts["runtime/type"] = "ascent";
ascent.open(ascent_opts);
ascent.open();
ascent.publish(root);
ascent.execute(actions);
ascent.info(ascent_info);
EXPECT_EQ(ascent_info["runtime/type"].as_string(), "ascent");
ascent_info.print();
ascent.close();

//
Expand Down

0 comments on commit 728a977

Please sign in to comment.