Skip to content

Commit

Permalink
raja binning fixes (#1238)
Browse files Browse the repository at this point in the history
* fix bugs and move to raja based data binning

* remove unused code

* remove unused code

* typo

* big test refactor to cover 2d and 3d across more mesh types

* enhance html diff report

* fix typo

* wip progress

* fixes

* make dray isosurface test cheaper

* interium state for mpi binning test

* stray 2
  • Loading branch information
cyrush authored May 11, 2024
1 parent 8f4d893 commit 0aef6cf
Show file tree
Hide file tree
Showing 57 changed files with 2,704 additions and 589 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -529,23 +529,22 @@ struct VertexFunctor
struct CentroidFunctor
{
Array<double> m_centroids;
int m_dims;

template<typename MeshType, typename Exec>
void operator()(MeshType &mesh, const Exec &)
{

const int size = mesh.m_num_cells;
const int dims = mesh.m_dims;

// std::cout << " centroid mesh dims " << dims << std::endl;

// one component for each dim
m_centroids.resize(size * mesh.m_dims);
double *centroids_ptr = m_centroids.get_ptr(Exec::memory_space);
//std::cout<<"Mem space "<<Exec::memory_space<<"\n";
using for_policy = typename Exec::for_policy;
ascent::forall<for_policy>(0, size, [=] ASCENT_LAMBDA(index_t cell_idx)
{
centroids_ptr[cell_idx] = cell_idx;
int indices[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
mesh.cell_indices(cell_idx, indices);

Expand Down Expand Up @@ -1381,7 +1380,7 @@ int find_bin(const T* bins, const int size, const T val, bool clamp)

return first;
}

//
// returns -1 if value lies outside the range
conduit::index_t
get_bin_index(const conduit::float64 value, const conduit::Node &axis)
Expand Down Expand Up @@ -1419,7 +1418,7 @@ get_bin_index(const conduit::float64 value, const conduit::Node &axis)
}
return bin_index;
}

//
void
populate_homes(const conduit::Node &dom,
const conduit::Node &bin_axes,
Expand Down Expand Up @@ -1556,6 +1555,7 @@ populate_homes(const conduit::Node &dom,
}
}


void
update_bin(double *bins,
const int i,
Expand Down Expand Up @@ -2018,6 +2018,8 @@ binning(const conduit::Node &dataset,
return res;
}


/// TODO MOVE TO ascent_data_binning.cpp
void
paint_binning(const conduit::Node &binning,
conduit::Node &dataset,
Expand Down Expand Up @@ -2108,13 +2110,17 @@ paint_binning(const conduit::Node &binning,
}


/// TODO MOVE TO ascent_data_binning.cpp
void
binning_mesh(const conduit::Node &binning,
conduit::Node &mesh,
const std::string field_name)
{
int num_axes = binning["attrs/bin_axes/value"].number_of_children();


// std::cout << "Creating binning mesh from " << binning.to_yaml();

if(num_axes > 3)
{
ASCENT_ERROR(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ ASCENT_API
void derived_field_add_fields(conduit::Node &dataset,
const std::vector<std::string> &field_names,
const std::string &output_field_name);

ASCENT_API
void derived_field_power_of_field(conduit::Node &dataset,
const std::string &field_name,
const double &exponent,
const std::string &output_field_name);

//
// NOTE: ascent_data_binning contains a RAJA version
// of binning that needs more work, but should eventually
Expand All @@ -114,6 +116,7 @@ conduit::Node binning(const conduit::Node &dataset,
const double empty_bin_val,
const std::string &component);

// TODO: Create RAJA version of paint_binning + binning_mesh
ASCENT_API
void ASCENT_API paint_binning(const conduit::Node &binning,
conduit::Node &dataset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ exec_dispatch_mesh(const conduit::Node &n_coords,

if(is_conduit_type<conduit::int32>(n_topo[conn_path]))
{
MCArray<conduit::int32> conn(n_topo["conn_path"]);
MCArray<conduit::int32> conn(n_topo[conn_path]);
UnstructuredMesh<conduit::float64,conduit::int32> mesh(mem_space,
coords,
conn,
Expand Down Expand Up @@ -370,17 +370,39 @@ exec_dispatch_mesh(const conduit::Node &n_coords,
// figure out the types of coords
if(is_conduit_type<conduit::float32>(n_coords["values/x"]))
{
MCArray<conduit::float32> coords(n_coords["values"]);
MCArray<conduit::float32> x_coords(n_coords["values/x"]);
MCArray<conduit::float32> y_coords(n_coords["values/y"]);
std::string zvalue_path = "values/z";

if(!n_coords.has_path("values/z"))
{
zvalue_path = "values/x";
}
MCArray<conduit::float32> z_coords(n_coords[zvalue_path]);

RectilinearMesh<conduit::float32> mesh(mem_space,
coords,
x_coords,
y_coords,
z_coords,
dims);
func(mesh,exec);
}
else if(is_conduit_type<conduit::float64>(n_coords["values/x"]))
{
MCArray<conduit::float32> coords(n_coords["values"]);
RectilinearMesh<conduit::float32> mesh(mem_space,
coords,
MCArray<conduit::float64> x_coords(n_coords["values/x"]);
MCArray<conduit::float64> y_coords(n_coords["values/y"]);
std::string zvalue_path = "values/z";

if(!n_coords.has_path("values/z"))
{
zvalue_path = "values/x";
}
MCArray<conduit::float64> z_coords(n_coords[zvalue_path]);

RectilinearMesh<conduit::float64> mesh(mem_space,
x_coords,
y_coords,
z_coords,
dims);
func(mesh,exec);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,13 +840,16 @@ struct RectilinearMesh

//==---------------------------------------------------------------------==//
RectilinearMesh(const std::string mem_space,
MCArray<CoordsType> &coords,
MCArray<CoordsType> &x_coords,
MCArray<CoordsType> &y_coords,
MCArray<CoordsType> &z_coords,
const int dims)
: m_coords_x(coords.accessor(mem_space, "x")),
m_coords_y(coords.accessor(mem_space, "y")),
m_coords_z(dims == 3 ? coords.accessor(mem_space, "z") :
// just use a dummy in this case
coords.accessor(mem_space, "x")),
: m_coords_x(x_coords.accessor(mem_space)),
m_coords_y(x_coords.accessor(mem_space)),
m_coords_z(z_coords.accessor(mem_space)),
// m_coords_z(dims == 3 ? z_coords.accessor(mem_space) :
// // just use a dummy in this case
// coords.accessor(mem_space)),
m_dims(dims),
m_point_dims({{(int)m_coords_x.m_size,
(int)m_coords_y.m_size,
Expand Down
Loading

0 comments on commit 0aef6cf

Please sign in to comment.