Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.8.4 warnings pass (part 2) #1008

Merged
merged 7 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/libs/blueprint/conduit_blueprint_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2435,10 +2435,10 @@ generate_decomposed_entities(conduit::Node &mesh,
std::map<index_t, std::set<index_t>> entity_neighbor_map;
// NOTE(JRC): Diff, entirely different iteration strategy for finding entities
// to consider on individual adjset interfaces.
for(const index_t &di : decomposed_centroid_dims)
for(const index_t &dentry : decomposed_centroid_dims)
{
const Node &dim_topo = src_topo_data.dim_topos[di];
for(index_t ei = 0; ei < src_topo_data.get_length(di); ei++)
const Node &dim_topo = src_topo_data.dim_topos[dentry];
for(index_t ei = 0; ei < src_topo_data.get_length(dentry); ei++)
{
std::vector<index_t> entity_pidxs = bputils::topology::unstructured::points(dim_topo, ei);
for(const auto &neighbor_pair : neighbor_pidxs_map)
Expand All @@ -2454,7 +2454,7 @@ generate_decomposed_entities(conduit::Node &mesh,

if(entity_in_neighbor)
{
const index_t entity_cidx = identify_decomposed(src_topo_data, ei, di);
const index_t entity_cidx = identify_decomposed(src_topo_data, ei, dentry);
entity_neighbor_map[entity_cidx].insert(ni);
}
}
Expand Down Expand Up @@ -4386,19 +4386,19 @@ namespace detail
original_vertices["topology"] = topo_name;
original_vertices["association"] = "vertex";
original_vertices["volume_dependent"] = "false";
int orig_num_points = coordset_src["values/x"].dtype().number_of_elements();
int new_num_points = coordset_dest["values/x"].dtype().number_of_elements();
index_t orig_num_points = coordset_src["values/x"].dtype().number_of_elements();
index_t new_num_points = coordset_dest["values/x"].dtype().number_of_elements();
original_vertices["values"].set(conduit::DataType::int32(new_num_points));
int32 *orig_vert_ids = original_vertices["values"].value();
for (int i = 0; i < new_num_points; i ++)
for (index_t i = 0; i < new_num_points; i ++)
{
if (i < orig_num_points)
{
orig_vert_ids[i] = i;
orig_vert_ids[i] = static_cast<int32>(i);
}
else
{
orig_vert_ids[i] = -1;
orig_vert_ids[i] = static_cast<int32>(-1);
}
}

Expand All @@ -4416,7 +4416,7 @@ namespace detail
}
else
{
for (uint64 i = 0; i < field_names.size(); i ++)
for (size_t i = 0; i < field_names.size(); i ++)
{
if (field_names[i] == field_name)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ void related_boundary(index_t base_grid_ele_i,

for(index_t i = 0; i < num_eles; i++)
{
ele_local_vals[i] = i;
ele_global_vals[i] = main_id_global;
ele_local_vals[i] = static_cast<float64>(i);
ele_global_vals[i] = static_cast<float64>(main_id_global);
dom_id_vals[i] = 0.0;
main_id_global+=1;
}
Expand Down Expand Up @@ -353,8 +353,8 @@ void related_boundary(index_t base_grid_ele_i,

for(index_t i = 0; i < num_eles; i++)
{
ele_local_vals[i] = i;
ele_global_vals[i] = main_id_global;
ele_local_vals[i] = static_cast<float64>(i);
ele_global_vals[i] = static_cast<float64>(main_id_global);
dom_id_vals[i] = 1.0;
main_id_global++;
}
Expand Down Expand Up @@ -559,8 +559,8 @@ void related_boundary(index_t base_grid_ele_i,

for(index_t i = 0; i < num_eles; i++)
{
ele_local_vals[i] = i;
ele_global_vals[i] = main_id_global;
ele_local_vals[i] = static_cast<float64>(i);
ele_global_vals[i] = static_cast<float64>(main_id_global);
dom_id_vals[i] = 2.0;
main_id_global+=1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void venn_sparse_by_element_matset(Node &res)
vf[vfidx + size] = frac;
matset_area[vfidx + size] = element_area;
matset_impt[vfidx + size] = imp;
matset_check_vals[vfidx + size] = mcheck;
matset_check_vals[vfidx + size] = static_cast<float64>(mcheck);
id[vfidx + size] = mat_id;

field_area[idx] += matset_area[vfidx + size] * vf[vfidx + size];
Expand Down
24 changes: 12 additions & 12 deletions src/libs/blueprint/conduit_blueprint_mesh_partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9117,7 +9117,7 @@ handle_multi_buffer(const Node &n_matset,
}
const DataAccessor<double> volume_fractions = vfract_data.value();

if(!is_elem_based && element_ids
if(!is_elem_based && (element_ids.get() != nullptr)
&& volume_fractions.number_of_elements() != element_ids->number_of_elements())
{
CONDUIT_ERROR("element_ids and volume_fractions to not contain the same "
Expand All @@ -9135,7 +9135,7 @@ handle_multi_buffer(const Node &n_matset,
const index_t idx = itr.index();
out_pair.first.push_back(volume_fractions[idx]);
// Material based will use element_ids array
if(!is_elem_based && element_ids)
if(!is_elem_based && (element_ids.get() != nullptr))
{
out_pair.second.push_back(elem_map[element_ids->element(i)]);
}
Expand Down Expand Up @@ -9735,10 +9735,10 @@ Partitioner::combine(int domain,
out_field["association"].set("element");
Schema s;
const DataType &dt = n_elem_map.dtype();
const index_t sz = dt.number_of_elements() / 2;
s["domains"].set(DataType(dt.id(), sz, 0,
const index_t half_sz = dt.number_of_elements() / 2;
s["domains"].set(DataType(dt.id(), half_sz, 0,
2*dt.element_bytes(), dt.element_bytes(), dt.endianness()));
s["ids"].set(DataType(dt.id(), sz, 1*dt.element_bytes(),
s["ids"].set(DataType(dt.id(), half_sz, 1*dt.element_bytes(),
2*dt.element_bytes(), dt.element_bytes(), dt.endianness()));
out_field["values"].set(s);

Expand Down Expand Up @@ -9803,8 +9803,8 @@ Partitioner::combine(int domain,

if(!n_pointmaps.dtype().is_object())
{
const index_t sz = mesh::coordset::length(output_coordsets[coordset_name]);
const DataType dt(pointmaps[0].dtype().id(), sz);
const index_t coordset_sz = mesh::coordset::length(output_coordsets[coordset_name]);
const DataType dt(pointmaps[0].dtype().id(), coordset_sz);
out_field["values"]["domains"].set(dt);
out_field["values"]["ids"].set(dt);
DataArray<index_t> out_domains = out_field["values/domains"].value();
Expand Down Expand Up @@ -9907,12 +9907,12 @@ Partitioner::map_back_fields(const conduit::Node& repart_mesh,
if (dom["fields"].has_child("original_element_ids"))
{
const Node& orig_v_node = dom["fields/original_element_ids/values"];
const index_t_accessor orig_elems = orig_v_node["ids"].value();
const index_t_accessor orig_doms = orig_v_node["domains"].value();
for (index_t ielem = 0; ielem < orig_elems.number_of_elements(); ielem++)
const index_t_accessor orig_elems_vals = orig_v_node["ids"].value();
const index_t_accessor orig_doms_vals = orig_v_node["domains"].value();
for (index_t ielem = 0; ielem < orig_elems_vals.number_of_elements(); ielem++)
{
map_tgt_elems[idom][orig_doms[ielem]].push_back(orig_elems[ielem]);
map_sel_elems[idom][orig_doms[ielem]].push_back(ielem);
map_tgt_elems[idom][orig_doms_vals[ielem]].push_back(orig_elems_vals[ielem]);
map_sel_elems[idom][orig_doms_vals[ielem]].push_back(ielem);
}
for (const auto& slice_map : map_tgt_elems[idom])
{
Expand Down
9 changes: 7 additions & 2 deletions src/libs/conduit/c/conduit_datatype_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
#include <stdlib.h>
#include <string.h>

#ifdef CONDUIT_PLATFORM_WINDOWS
#define _conduit_strdup _strdup
#else
#define _conduit_strdup strdup
#endif

//-----------------------------------------------------------------------------
// -- begin extern C
//-----------------------------------------------------------------------------
Expand All @@ -30,8 +36,7 @@ conduit_index_t conduit_datatype_id(const conduit_datatype *cdatatype)

char* conduit_datatype_name(const conduit_datatype *cdatatype)
{
auto name = cpp_datatype_ref(cdatatype).name();
return strdup(name.c_str());
return _conduit_strdup(cpp_datatype_ref(cdatatype).name().c_str());
}

void conduit_datatype_name_destroy(char *name)
Expand Down
64 changes: 8 additions & 56 deletions src/libs/conduit/c/conduit_node_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,27 +431,15 @@ conduit_node_load(conduit_node *cnode,
char*
conduit_node_to_json(const conduit_node *cnode)
{
std::string str = cpp_node(cnode)->to_json();
std::size_t len = str.length() + 1;

char* output = (char*)malloc(len);
strcpy(output, str.c_str());

return output;
return _conduit_strdup(cpp_node(cnode)->to_json().c_str());
}

//-----------------------------------------------------------------------------
char*
conduit_node_to_json_with_options(const conduit_node *cnode,
const conduit_node *copts)
{
std::string str = cpp_node(cnode)->to_json(cpp_node_ref(copts));
std::size_t len = str.length() + 1;

char* output = (char*)malloc(len);
strcpy(output, str.c_str());

return output;
return _conduit_strdup(cpp_node(cnode)->to_json(cpp_node_ref(copts)).c_str());
}

//-----------------------------------------------------------------------------
Expand All @@ -462,27 +450,15 @@ conduit_node_to_json_with_options(const conduit_node *cnode,
char*
conduit_node_to_yaml(const conduit_node *cnode)
{
std::string str = cpp_node(cnode)->to_yaml();
std::size_t len = str.length() + 1;

char* output = (char*)malloc(len);
strcpy(output, str.c_str());

return output;
return _conduit_strdup(cpp_node(cnode)->to_yaml().c_str());
}

//-----------------------------------------------------------------------------
char*
conduit_node_to_yaml_with_options(const conduit_node *cnode,
const conduit_node *copts)
{
std::string str = cpp_node(cnode)->to_yaml(cpp_node_ref(copts));
std::size_t len = str.length() + 1;

char* output = (char*)malloc(len);
strcpy(output, str.c_str());

return output;
return _conduit_strdup(cpp_node(cnode)->to_yaml(cpp_node_ref(copts)).c_str());
}

//-----------------------------------------------------------------------------
Expand All @@ -493,27 +469,15 @@ conduit_node_to_yaml_with_options(const conduit_node *cnode,
char*
conduit_node_to_string(const conduit_node *cnode)
{
std::string str = cpp_node(cnode)->to_string();
std::size_t len = str.length() + 1;

char* output = (char*)malloc(len);
strcpy(output, str.c_str());

return output;
return _conduit_strdup(cpp_node(cnode)->to_string().c_str());
}

//-----------------------------------------------------------------------------
char*
conduit_node_to_string_with_options(const conduit_node *cnode,
const conduit_node *copts)
{
std::string str = cpp_node(cnode)->to_string(cpp_node_ref(copts));
std::size_t len = str.length() + 1;

char* output = (char*)malloc(len);
strcpy(output, str.c_str());

return output;
return _conduit_strdup(cpp_node(cnode)->to_string(cpp_node_ref(copts)).c_str());
}

//-----------------------------------------------------------------------------
Expand All @@ -523,26 +487,14 @@ conduit_node_to_string_with_options(const conduit_node *cnode,
//-----------------------------------------------------------------------------
char* conduit_node_to_summary_string(const conduit_node *cnode)
{
std::string str = cpp_node(cnode)->to_summary_string();
std::size_t len = str.length() + 1;

char* output = (char*)malloc(len);
strcpy(output, str.c_str());

return output;
return _conduit_strdup(cpp_node(cnode)->to_summary_string().c_str());
}

//-----------------------------------------------------------------------------
char* conduit_node_to_summary_string_with_options(const conduit_node *cnode,
const conduit_node *copts)
{
std::string str = cpp_node(cnode)->to_summary_string(cpp_node_ref(copts));
std::size_t len = str.length() + 1;

char* output = (char*)malloc(len);
strcpy(output, str.c_str());

return output;
return _conduit_strdup(cpp_node(cnode)->to_summary_string(cpp_node_ref(copts)).c_str());
}

//-----------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions src/libs/relay/conduit_relay_io_blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class BlueprintTreePathGenerator

//-------------------------------------------------------------------//
std::string Expand(const std::string pattern,
int idx) const
index_t idx) const
{
//
// This currently handles format strings:
Expand Down Expand Up @@ -202,9 +202,9 @@ class BlueprintTreePathGenerator
}

//-------------------------------------------------------------------//
std::string GenerateFilePath(int tree_id) const
std::string GenerateFilePath(index_t tree_id) const
{
int file_id = -1;
index_t file_id = -1;

if(m_num_trees == m_num_files)
{
Expand All @@ -224,7 +224,7 @@ class BlueprintTreePathGenerator
}

//-------------------------------------------------------------------//
std::string GenerateTreePath(int tree_id) const
std::string GenerateTreePath(index_t tree_id) const
{
// the tree path should always end in a /
std::string res = Expand(m_tree_pattern,tree_id);
Expand Down
4 changes: 2 additions & 2 deletions src/tests/blueprint/t_blueprint_mesh_partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ TEST(conduit_blueprint_mesh_combine, to_poly)
conduit::float32_array vals = n_dim.value();
for(conduit::index_t vi = 0; vi < 8; vi++)
{
vals[vi] = new_coords[d][vi];
vals[vi] = static_cast<conduit::float32>(new_coords[d][vi]);
}
}
else if(n_dim.dtype().is_float64())
Expand Down Expand Up @@ -1196,7 +1196,7 @@ TEST(conduit_blueprint_mesh_combine, to_poly)
conduit::float32_array vals = n_dim.value();
for(conduit::index_t vi = 0; vi < 4; vi++)
{
vals[vi] = new_coords[d][vi];
vals[vi] = static_cast<conduit::float32 > (new_coords[d][vi]);
}
}
else if(n_dim.dtype().is_float64())
Expand Down