diff --git a/CMakeLists.txt b/CMakeLists.txt index b3b8bb5df9..e4257c5a6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,44 +61,26 @@ nanobind_build_library(nanobind SHARED) # Compile an extension library add_library(my_ext MODULE ${CMAKE_CURRENT_SOURCE_DIR}/circle.cc) -add_library(visualizer MODULE ${CMAKE_CURRENT_SOURCE_DIR}/visualizer.cc) -add_library(block MODULE ${CMAKE_CURRENT_SOURCE_DIR}/block.cc) # .. and link it against the nanobind parts message(STATUS "vtk libraries: ${VTK_LIBRARIES}") target_link_libraries(my_ext PUBLIC ${VTK_LIBRARIES}) target_link_libraries(my_ext PRIVATE nanobind) -target_link_libraries(visualizer PUBLIC ${VTK_LIBRARIES}) -target_link_libraries(visualizer PRIVATE nanobind) -target_link_libraries(block PUBLIC ${VTK_LIBRARIES}) -target_link_libraries(block PRIVATE nanobind) # .. enable size optimizations nanobind_opt_size(my_ext) -nanobind_opt_size(visualizer) -nanobind_opt_size(block) # .. enable link time optimization nanobind_lto(my_ext) -nanobind_lto(visualizer) -nanobind_lto(block) # .. disable the stack protector nanobind_disable_stack_protector(my_ext) -nanobind_disable_stack_protector(visualizer) -nanobind_disable_stack_protector(block) # .. set the Python extension suffix nanobind_extension(my_ext) -nanobind_extension(visualizer) -nanobind_extension(block) # .. set important compilation flags nanobind_compile_options(my_ext) -nanobind_compile_options(visualizer) -nanobind_compile_options(block) # .. set important linker flags nanobind_link_options(my_ext) -nanobind_link_options(visualizer) -nanobind_link_options(block) diff --git a/block.cc b/block.cc deleted file mode 100644 index 7871c92abd..0000000000 --- a/block.cc +++ /dev/null @@ -1,53 +0,0 @@ -#include "block.h" - -namespace vt { namespace tv { - -Block::Block(uint64_t b_id, - uint64_t h_id, - double size, - std::unordered_set o_ids) -: index(b_id) -, home_id(h_id) -, size(size) -, attached_object_ids(o_ids) -{} - -uint64_t Block::detach_object_id(uint64_t o_id) { - if(auto search = this->attached_object_ids.find(o_id); - search != this->attached_object_ids.end()) { - this->attached_object_ids.erase(o_id); - } - else { - throw nb::type_error( - "object id " + std::to_string(o_id) + - " is not attached to block " + std::to_string(this->get_id()) - ); - } - return this->attached_object_ids.size(); -} - -std::string Block::to_string() const { - std::string out; - out += "Block id: " + std::to_string(this->get_id()) - + ", home id: " + std::to_string(this->get_home_id()) - + ", size: " + std::to_string(this->get_size()) - + ", object ids: {"; - for (const auto &elem : this->get_attached_object_ids()) { - out += std::to_string(elem) + " "; - } - out += "}"; - return out; -} - -NB_MODULE(block, m) { - nb::class_(m, "Block") - .def(nb::init>()) - .def("get_id", &Block::get_id) - .def("get_home_id", &Block::get_home_id) - .def("get_size", &Block::get_size) - .def("detach_object_id", &Block::detach_object_id) - .def("attach_object_id", &Block::attach_object_id) - .def("to_string", &Block::to_string); -} - -}} /* end namesapce vt::tv */ diff --git a/block.h b/block.h deleted file mode 100644 index b8661d8036..0000000000 --- a/block.h +++ /dev/null @@ -1,84 +0,0 @@ -#if !defined INCLUDED_VT_TV_API_BLOCK_H -#define INCLUDED_VT_TV_API_BLOCK_H - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace nb = nanobind; - -namespace vt { namespace tv { - -/** - * A class representing a memory block with footprint and home. - */ -struct Block -{ -private: - uint64_t index; - uint64_t home_id; - double size = 0; - std::unordered_set attached_object_ids; - - /** - * Return block object ids. - */ - std::unordered_set get_attached_object_ids() const { return this->attached_object_ids; }; -public: - /** - * Return block ID. - */ - uint64_t get_id() const { return this->index; }; - - /** - * Return block home ID. - */ - uint64_t get_home_id() const { return this->home_id; }; - - /** - * Return block size. - */ - double get_size() const { return this->size; }; - - - /** - * Try to detach object ID from block and return length. - */ - uint64_t detach_object_id(uint64_t); - - /** - * Attach object ID to block. - */ - void attach_object_id(uint64_t o_id) { this->attached_object_ids.insert(o_id); }; - - std::string to_string() const; - - friend std::ostream & operator << (std::ostream &out, const Block &b); - - Block(uint64_t, uint64_t, double, std::unordered_set); - ~Block() = default; -}; - -std::ostream & operator << (std::ostream &out, const Block &b) -{ - out << "Block id: " << b.get_id() << ", home id: " << b.get_home_id() - << ", size: " << b.get_size() << ", object ids: "; - for (const auto &elem : b.get_attached_object_ids()) { - out << elem << " "; - } - out << std::endl; - return out; -} - -}} /* end namesapce vt::tv */ - -#endif /*INCLUDED_VT_TV_API_BLOCK_H*/ diff --git a/src/vt-tv/render/render.cc b/src/vt-tv/render/render.cc index cfbaf4c487..c7afdd8461 100644 --- a/src/vt-tv/render/render.cc +++ b/src/vt-tv/render/render.cc @@ -668,78 +668,6 @@ vtkNew Render::create_object_mesh_(PhaseWork phase) { renderer->AddActor(rank_actor); renderer->AddActor2D(qoi_actor); - // vtkNew bw_lut; - // bw_lut->SetTableRange((0.0, self.__max_object_volume)); - // bw_lut->SetSaturationRange(0, 0); - // bw_lut->SetHueRange(0, 0); - // bw_lut->SetValueRange(1, 0); - // bw_lut->SetNanColor(1.0, 1.0, 1.0, 0.0); - // bw_lut->Build(); - - vtkNew sqrtT; - sqrtT->SetInputData(object_mesh); - sqrtT->AddScalarArrayName("Load"); - char const* sqrtT_str = "sqrt(Load)"; - sqrtT->SetFunction(sqrtT_str); - sqrtT->SetResultArrayName(sqrtT_str); - sqrtT->Update(); - auto sqrtT_out = sqrtT->GetDataSetOutput(); - sqrtT_out->GetPointData()->SetActiveScalars("Migratable"); - - std::vector> items{{0.0, "Square"}, {1.0, "Circle"}}; - vtkPolyDataMapper* glyph_mapper_out = nullptr; - for (auto&& [k,v] : items) { - vtkNew thresh; - thresh->SetInputData(sqrtT_out); - thresh->ThresholdBetween(k, k); - thresh->Update(); - auto thresh_out = thresh->GetOutput(); - if (not thresh_out->GetNumberOfPoints()) - continue; - thresh_out->GetPointData()->SetActiveScalars(sqrtT_str); - - // Glyph by square root of object loads - vtkNew glyph; - if (v == "Square") { - glyph->SetGlyphTypeToSquare(); - } else { - glyph->SetGlyphTypeToCircle(); - } - glyph->SetResolution(32); - glyph->SetScale(1.0); - glyph->FilledOn(); - glyph->CrossOff(); - vtkNew glypher; - glypher->SetSourceConnection(glyph->GetOutputPort()); - glypher->SetInputData(thresh_out); - glypher->SetScaleModeToScaleByScalar(); - glypher->SetScaleFactor(0.5); - glypher->Update(); - glypher->GetOutput()->GetPointData()->SetActiveScalars("Load"); - - // Raise glyphs slightly for visibility - vtkNew z_raise; - z_raise->Translate(0.0, 0.0, 0.01); - vtkNew trans; - trans->SetTransform(z_raise); - trans->SetInputData(glypher->GetOutput()); - - // Create mapper and actor for glyphs - vtkNew glyph_mapper; - glyph_mapper_out = glyph_mapper; - glyph_mapper->SetInputConnection(trans->GetOutputPort()); - // glyph_mapper->SetLookupTable(createColorTransferFunction({0,0.01}, 0, BlueToRed)); - // glyph_mapper->SetScalarRange({0,0.01}); - vtkNew glyph_actor; - glyph_actor->SetMapper(glyph_mapper); - renderer->AddActor(glyph_actor); - } - - if (glyph_mapper_out) { - auto load_actor = createScalarBarActor(glyph_mapper_out, "Object Load", 0.55, 0.55); - renderer->AddActor2D(load_actor); - } - renderer->ResetCamera(); vtkNew render_window; render_window->AddRenderer(renderer); diff --git a/visualizer.cc b/visualizer.cc deleted file mode 100644 index 7d2e6eab65..0000000000 --- a/visualizer.cc +++ /dev/null @@ -1,42 +0,0 @@ -#include "visualizer.h" - -Visualizer::Visualizer( - std::list qoi_request, - bool continuous_object_qoi, - std::list phases, - std::list grid_size, - double object_jitter, - std::string output_dir, - std::string output_file_stem, - std::map distributions, - std::map statistics, - double resolution -) -: qoi_request(qoi_request) -, continuous_object_qoi(continuous_object_qoi) -, phases(phases) -, grid_size(grid_size) -, object_jitter(object_jitter) -, output_dir(output_dir) -, output_file_stem(output_file_stem) -, distributions(distributions) -, statistics(statistics) -, resolution(resolution) -{} - - -NB_MODULE(visualizer, m) { - nb::class_(m, "phase") - .def(nb::init<>()); - nb::class_(m, "Visualizer") - .def(nb::init, - bool, - std::list, - std::list, - double, - std::string, - std::string, - std::map, - std::map, - double>()); -} diff --git a/visualizer.h b/visualizer.h deleted file mode 100644 index 74a24768bd..0000000000 --- a/visualizer.h +++ /dev/null @@ -1,76 +0,0 @@ -#if !defined INCLUDED_VT_TV_VISUALIZER_H -#define INCLUDED_VT_TV_VISUALIZER_H - -// #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// #include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -namespace nb = nanobind; - -struct Phase { - uint64_t n_objects = 0; -}; - -struct Visualizer { -private: - std::list qoi_request; - bool continuous_object_qoi; - std::list phases; - std::list grid_size; - double object_jitter = 0; - std::string output_dir = "."; - std::string output_file_stem = "LBAF_out"; - std::map distributions; - std::map statistics; - double resolution = 1; - -public: - Visualizer( - std::list, - bool, - std::list, - std::list, - double, - std::string, - std::string, - std::map, - std::map, - double - ); - -}; - -#endif /*INCLUDED_VT_TV_VISUALIZER_H*/