Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into task/2023_08_siram…
Browse files Browse the repository at this point in the history
…ok_command_integration
  • Loading branch information
siramok committed Oct 25, 2023
2 parents 1c72284 + dfd6a2e commit 242c627
Show file tree
Hide file tree
Showing 10 changed files with 355 additions and 40 deletions.
6 changes: 6 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ build:
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: src/docs/sphinx/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
# formats:
# - pdf

# Set requirements required to build your docs
python:
install:
- requirements: src/docs/sphinx/requirements.txt
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s

### Added
- Added parameters to control HDF5 compression options to the Relay Extract.
- Added check to make sure all domain IDs are unique

### Changed
- Changed the Data Binning filter to accept a `reduction_field` parameter (instead of `var`), and similarly the axis parameters to take `field` (instead of `var`). The `var` style parameters are still accepted, but deprecated and will be removed in a future release.
Expand Down
2 changes: 1 addition & 1 deletion src/docs/sphinx/Actions/Scenes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ The code below creates a pipeline that first applies a contour filter and then a
:align: center

The camera placement chosen by the VQ metric DDS Entropy for this example.
This example and implementation of the other VQ metrics can be found in `auto_camera test <https://github.com/Alpine-DAV/ascent/blob/develop/src/tests/vtkh/t_vtk-h_auto_camera.cpp>`_.
This example and implementation of the other VQ metrics can be found in `auto_camera test <https://github.com/Alpine-DAV/ascent/blob/develop/src/tests/ascent/t_ascent_render_auto_camera.cpp>`_.

.. _actions_cinema:

Expand Down
4 changes: 3 additions & 1 deletion src/docs/sphinx/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
docutils<0.18
docutils
sphinx==6.2.1
sphinx-rtd-theme==1.2.2
208 changes: 173 additions & 35 deletions src/libs/ascent/runtimes/ascent_main_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
using namespace conduit;
using namespace std;


//-----------------------------------------------------------------------------
// -- begin ascent:: --
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -326,7 +325,7 @@ AscentRuntime::Initialize(const conduit::Node &options)
}

if(options.has_path("ghost_field_names"))
{
{
if(!options["ghost_field_names"].dtype().is_list())
{
ASCENT_ERROR("ghost_field_names is not a list");
Expand Down Expand Up @@ -433,7 +432,7 @@ AscentRuntime::AddPublishedMeshInfo()
#ifdef ASCENT_MPI_ENABLED
int comm_id = flow::Workspace::default_mpi_comm();
MPI_Comm mpi_comm = MPI_Comm_f2c(comm_id);

Node n_src, n_reduce;
n_src = src_tbytes;
// all reduce to get total number of bytes across mpi tasks
Expand Down Expand Up @@ -510,33 +509,6 @@ AscentRuntime::Cleanup()
void
AscentRuntime::Publish(const conduit::Node &data)
{
// Process the comments.
m_comments.reset();
if(data.has_path("state/software"))
{
m_comments.append() = "Software";
m_comments.append() = data["state/software"].as_string();
}
if(data.has_path("state/source"))
{
m_comments.append() = "Source";
m_comments.append() = data["state/source"].as_string();
}
if(data.has_path("state/title"))
{
m_comments.append() = "Title";
m_comments.append() = data["state/title"].as_string();
}
if(data.has_path("state/info"))
{
m_comments.append() = "Description";
m_comments.append() = data["state/info"].as_string();
}
if(data.has_path("state/comment"))
{
m_comments.append() = "Comment";
m_comments.append() = data["state/comment"].as_string();
}

blueprint::mesh::to_multi_domain(data, m_source);
EnsureDomainIds();
Expand All @@ -553,6 +525,22 @@ AscentRuntime::Publish(const conduit::Node &data)
void
AscentRuntime::EnsureDomainIds()
{
//add debug timing file in case these checks
//add a lot of overhead
#define _DEBUG 0

#if _DEBUG
std::stringstream log_name;
std::string log_prefix = "EnsureDomainIDs_times_";
#ifdef ASCENT_MPI_ENABLED
log_name << log_prefix << m_rank<<".csv";
#else
log_name << log_prefix << "0.csv";
#endif
std::ofstream stream;
stream.open(log_name.str().c_str(),std::ofstream::app);
conduit::utils::Timer ensureDomainIDsTimer;
#endif
// if no domain ids were provided add them now
int num_domains = 0;
bool has_ids = true;
Expand All @@ -573,7 +561,6 @@ AscentRuntime::EnsureDomainIds()
}
}


#ifdef ASCENT_MPI_ENABLED
int comm_id = flow::Workspace::default_mpi_comm();

Expand Down Expand Up @@ -616,24 +603,151 @@ AscentRuntime::EnsureDomainIds()
}

int domain_offset = 0;

#if _DEBUG
conduit::utils::Timer local_check_timer;
#endif

#ifdef ASCENT_MPI_ENABLED
int *domains_per_rank = new int[comm_size];
MPI_Allgather(&num_domains, 1, MPI_INT, domains_per_rank, 1, MPI_INT, mpi_comm);
for(int i = 0; i < m_rank; ++i)
{
domain_offset += domains_per_rank[i];
}
int total_domains = 0;
for(int i = 0; i < comm_size; i++)
{
total_domains += domains_per_rank[i];
}
delete[] domains_per_rank;
#endif

std::unordered_set<int> local_unique_ids;
for(int i = 0; i < num_domains; ++i)
{
conduit::Node &dom = m_source.child(i);

if(!dom.has_path("state/domain_id"))
{
dom["state/domain_id"] = domain_offset + i;
dom["state/domain_id"] = domain_offset + i;
local_unique_ids.insert(domain_offset + i);
}
else
{
local_unique_ids.insert(dom["state/domain_id"].to_int32());
}
}

int unique_ids = 1;
if(local_unique_ids.size() != num_domains)
{
unique_ids = 0;
}
#ifdef ASCENT_MPI_ENABLED
conduit::Node n_ids;
n_ids.set(DataType::c_int(comm_size));
int *unique_ids_array = n_ids.value();//new int[comm_size];
MPI_Allgather(&unique_ids, 1, MPI_INT, unique_ids_array, 1, MPI_INT, mpi_comm);
std::stringstream ss;
for(int i = 0; i < comm_size; i++)
{
if(unique_ids_array[i] == 0)
{
unique_ids = 0;
ss << i << " ";
}
}

if(!unique_ids)
ASCENT_ERROR("Local Domain IDs are not unique on ranks: " << ss.str());
#else
if(!unique_ids)
ASCENT_ERROR("Local Domain IDs are not unique ");
#endif
#if _DEBUG
float local_check_timer_time = local_check_timer.elapsed();
std::stringstream local_check_timer_log;
local_check_timer_log << "Local Uniqueness Check: " << local_check_timer_time << "\n";
stream << local_check_timer_log.str();
#endif


#ifdef ASCENT_MPI_ENABLED

#if _DEBUG
conduit::utils::Timer global_check_timer;
#endif
conduit::Node n_dom_ids;
conduit::Node n_global_dom_ids;
conduit::Node n_dom_rank;
conduit::Node n_global_dom_rank;
n_dom_ids.set(DataType::c_int(total_domains));
n_global_dom_ids.set(DataType::c_int(total_domains));
n_dom_rank.set(DataType::c_int(total_domains));
n_global_dom_rank.set(DataType::c_int(total_domains));
int *domain_ids_per_rank = n_dom_ids.value();
int *global_domain_ids = n_global_dom_ids.value();
int *domain_rank = n_dom_rank.value();
int *global_domain_rank = n_global_dom_rank.value();

for(int i = 0; i < total_domains; i++)
{
domain_ids_per_rank[i] = -1;
domain_rank[i] = -1;
}
for(int i = 0; i < num_domains; ++i)
{
conduit::Node &dom = m_source.child(i);
domain_ids_per_rank[domain_offset + i] = dom["state/domain_id"].to_int32();
domain_rank[domain_offset + i] = m_rank;
}

MPI_Allreduce(domain_ids_per_rank, global_domain_ids, total_domains, MPI_INT, MPI_MAX, mpi_comm);
MPI_Allreduce(domain_rank, global_domain_rank, total_domains, MPI_INT, MPI_MAX, mpi_comm);

std::unordered_set<int> global_ids;
for(int i = 0; i < total_domains; i++)
{
global_ids.insert(global_domain_ids[i]);
}

if(global_ids.size() != total_domains)
{
std::map<int,std::vector<int>> map_global_ids;
for(int i = 0; i < total_domains; i++)
{
map_global_ids[global_domain_ids[i]].push_back(global_domain_rank[i]);
}
for(auto itr = map_global_ids.begin(); itr != map_global_ids.end(); ++itr)
{
if(itr->second.size() > 1)
{
ss << "domain: " << itr->first << " on ranks: ";
for(auto iitr = itr->second.begin(); iitr != itr->second.end(); ++iitr)
{
ss << *iitr << " ";
}
ss << "\n";
}
}
ASCENT_ERROR("Global Domain IDs are not unique for " << ss.str());
}
#if _DEBUG
float global_check_timer_time = global_check_timer.elapsed();
std::stringstream global_check_timer_log;
global_check_timer_log << "Global Uniqueness Check: " << global_check_timer_time << "\n";
stream << global_check_timer_log.str();
#endif
#endif

#if _DEBUG
float ensureDomainIDs_time = ensureDomainIDsTimer.elapsed();
std::stringstream ensureDomainIDs_log;
ensureDomainIDs_log << "AscentRuntime::EnsureDomainIDs [TOTAL]: " << ensureDomainIDs_time << "\n";
stream << ensureDomainIDs_log.str();
stream.close();
#endif
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1285,10 +1399,35 @@ AscentRuntime::PopulateMetadata()
const int num_domains = m_source.number_of_children();
int cycle = -1;
float time = -1.f;
bool metadata_set = false;

for(int i = 0; i < num_domains; ++i)
{
const conduit::Node &dom = m_source.child(i);
if (!metadata_set && dom.has_path("state"))
{
m_comments.reset();
conduit::NodeConstIterator itr = dom["state"].children();

while(itr.has_next())
{
const conduit::Node &cld = itr.next();
if(cld.has_path("keyword") && cld.has_path("data"))
{
metadata_set = true;
m_comments.append() = cld["keyword"].as_string();
try
{
m_comments.append() = cld["data"].as_string();
}
catch(const conduit::Error)
{
m_comments.append() = cld["data"].to_string();
}
}
}
}

if(dom.has_path("state/cycle"))
{
cycle = dom["state/cycle"].to_int32();
Expand All @@ -1299,7 +1438,6 @@ AscentRuntime::PopulateMetadata()
}
}


if(cycle != -1)
{
Metadata::n_metadata["cycle"] = cycle;
Expand Down Expand Up @@ -1976,7 +2114,7 @@ AscentRuntime::Execute(const conduit::Node &actions)
{
SaveInfo();
}

}
// --- close try --- //

Expand Down Expand Up @@ -2094,7 +2232,7 @@ void AscentRuntime::SourceFieldFilter()

// if all fields were removed - also remove the fields node
// or else blueprint verify will fail
//
//
// (this can happen when some domains do not have selected fields)
//
if(dom["fields"].number_of_children() == 0)
Expand Down
3 changes: 3 additions & 0 deletions src/libs/rover/ray_generators/camera_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
#include <ray_generators/camera_generator.hpp>

#include <vtkm/rendering/CanvasRayTracer.h>

namespace rover {

CameraGenerator::CameraGenerator()
Expand Down
12 changes: 11 additions & 1 deletion src/libs/rover/ray_generators/visit_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include <ray_generators/visit_generator.hpp>
#include <utils/rover_logging.hpp>
#include <vtkm/VectorAnalysis.h>
#include <vtkm/Version.h>
#include <vtkm/rendering/raytracing/RayOperations.h>
#include <assert.h>
#include <limits>
namespace rover {
Expand Down Expand Up @@ -75,7 +77,15 @@ VisitGenerator::gen_rays(vtkmRayTracing::Ray<T> &rays)

const int size = m_width * m_height;

rays.Resize(size, vtkm::cont::DeviceAdapterTagSerial());
#if (VTKM_VERSION_MAJOR >= 2) && (VTKM_VERSION_MINOR >= 1)
vtkm::rendering::raytracing::RayOperations::Resize(rays,
size);
#else
vtkm::rendering::raytracing::RayOperations::Resize(rays,
size,
vtkm::cont::DeviceAdapterTagSerial());
#endif


vtkm::Vec<T,3> view_side;

Expand Down
7 changes: 6 additions & 1 deletion src/libs/vtkh/rendering/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,12 @@ Render::Print() const
void
Render::RenderBackground()
{
if(m_render_background) m_canvas.BlendBackground();
if(m_render_background)
{
m_canvas.SetBackgroundColor(m_bg_color);
m_canvas.SetForegroundColor(m_fg_color);
m_canvas.BlendBackground();
}
}

Render::vtkmCanvas
Expand Down
Loading

0 comments on commit 242c627

Please sign in to comment.