Skip to content

Commit

Permalink
#105: change a formatting guideline in clang and re-format source files
Browse files Browse the repository at this point in the history
  • Loading branch information
tlamonthezie committed Sep 4, 2024
1 parent c93f263 commit c7c26f8
Show file tree
Hide file tree
Showing 19 changed files with 205 additions and 79 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
Expand Down
7 changes: 5 additions & 2 deletions src/vt-tv/api/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ struct Info {
if (this->ranks_.size() > 0) {
n_phases = this->ranks_.at(0).getNumPhases();
for (NodeType rank_id = 1;
rank_id < static_cast<NodeType>(this->ranks_.size()); rank_id++) {
rank_id < static_cast<NodeType>(this->ranks_.size());
rank_id++) {
if (ranks_.at(rank_id).getNumPhases() != n_phases) {
throw std::runtime_error(
"Number of phases must be consistent across ranks");
Expand Down Expand Up @@ -590,7 +591,9 @@ struct Info {
fmt::print(
" /!\\ Didn't find recipient object {} when searching for "
"communication sent by object {} of {} bytes.\n",
B_id, A_id, bytes);
B_id,
A_id,
bytes);
}
}
// Going through A <- ... communications
Expand Down
9 changes: 6 additions & 3 deletions src/vt-tv/api/object_communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ struct ObjectCommunicator {
* \param[in] sent_in send edges
*/
ObjectCommunicator(
ElementIDType id_in, std::multimap<ElementIDType, double> recv_in,
ElementIDType id_in,
std::multimap<ElementIDType, double> recv_in,
std::multimap<ElementIDType, double> sent_in)
: object_id_(id_in),
received_(recv_in),
Expand Down Expand Up @@ -169,14 +170,16 @@ struct ObjectCommunicator {
// Search for the maximum value in received and sent (0. if sets are empty)
double max_recv = !this->received_.empty() ?
std::max_element(
this->received_.begin(), this->received_.end(),
this->received_.begin(),
this->received_.end(),
[](const auto& a, const auto& b) { return a.second < b.second; })
->second :
0.0;

double max_sent = !this->sent_.empty() ?
std::max_element(
this->sent_.begin(), this->sent_.end(),
this->sent_.begin(),
this->sent_.end(),
[](const auto& a, const auto& b) { return a.second < b.second; })
->second :
0.0;
Expand Down
4 changes: 3 additions & 1 deletion src/vt-tv/api/object_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ struct ObjectInfo {
* \param[in] in_index the index for the object
*/
ObjectInfo(
ElementIDType in_id, NodeType in_home, bool in_migratable,
ElementIDType in_id,
NodeType in_home,
bool in_migratable,
std::vector<UniqueIndexBitType> const& in_index)
: id_(in_id),
home_(in_home),
Expand Down
3 changes: 2 additions & 1 deletion src/vt-tv/api/object_work.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ struct ObjectWork {
* \param[in] in_user_defined the user-defined fields in json
*/
ObjectWork(
ElementIDType in_id, TimeType in_whole_phase_load,
ElementIDType in_id,
TimeType in_whole_phase_load,
std::unordered_map<SubphaseType, TimeType> in_subphase_loads,
std::unordered_map<std::string, QOIVariantTypes> in_user_defined = {},
std::unordered_map<std::string, QOIVariantTypes> in_attributes = {})
Expand Down
7 changes: 5 additions & 2 deletions src/vt-tv/api/rank.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ struct Rank {
* \param[in] in_phase_info all the phase info
*/
Rank(
NodeType in_rank, std::unordered_map<PhaseType, PhaseWork> in_phase_info,
NodeType in_rank,
std::unordered_map<PhaseType, PhaseWork> in_phase_info,
std::unordered_map<std::string, QOIVariantTypes> in_attributes = {})
: rank_(in_rank),
phase_info_(std::move(in_phase_info)),
Expand Down Expand Up @@ -123,7 +124,9 @@ struct Rank {
* \return void
*/
void addObjectReceivedCommunicationAtPhase(
PhaseType phase_id, ElementIDType o_id, ElementIDType from_id,
PhaseType phase_id,
ElementIDType o_id,
ElementIDType from_id,
double bytes) {
phase_info_.at(phase_id).addObjectReceivedCommunication(
o_id, from_id, bytes);
Expand Down
70 changes: 51 additions & 19 deletions src/vt-tv/render/render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,16 @@ Render::Render(Info in_info)
};

Render::Render(
std::array<std::string, 3> in_qoi_request, bool in_continuous_object_qoi,
Info& in_info, std::array<uint64_t, 3> in_grid_size, double in_object_jitter,
std::string in_output_dir, std::string in_output_file_stem,
double in_resolution, bool in_save_meshes, bool in_save_pngs,
std::array<std::string, 3> in_qoi_request,
bool in_continuous_object_qoi,
Info& in_info,
std::array<uint64_t, 3> in_grid_size,
double in_object_jitter,
std::string in_output_dir,
std::string in_output_file_stem,
double in_resolution,
bool in_save_meshes,
bool in_save_pngs,
PhaseType in_selected_phase)
: rank_qoi_(in_qoi_request[0]),
object_qoi_(in_qoi_request[2]),
Expand Down Expand Up @@ -248,7 +254,8 @@ std::pair<double, double> Render::computeRankQoiRange_() {

// Get max qoi for this rank across all phases
auto prmax = std::max_element(
std::begin(rank_qoi_map), std::end(rank_qoi_map),
std::begin(rank_qoi_map),
std::end(rank_qoi_map),
[](
const std::pair<PhaseType, double>& p1,
const std::pair<PhaseType, double>& p2) {
Expand All @@ -258,7 +265,8 @@ std::pair<double, double> Render::computeRankQoiRange_() {

// Get min qoi for this rank across all phases
auto prmin = std::max_element(
std::begin(rank_qoi_map), std::end(rank_qoi_map),
std::begin(rank_qoi_map),
std::end(rank_qoi_map),
[](
const std::pair<PhaseType, double>& p1,
const std::pair<PhaseType, double>& p2) {
Expand Down Expand Up @@ -392,7 +400,8 @@ vtkNew<vtkPolyData> Render::createObjectMesh_(PhaseType phase) {
this->globalIDToCartesian_(rankID, this->grid_size_);

std::array<double, 3> offsets = {
ijk[0] * this->grid_resolution_, ijk[1] * this->grid_resolution_,
ijk[0] * this->grid_resolution_,
ijk[1] * this->grid_resolution_,
ijk[2] * this->grid_resolution_};

// Compute local object block parameters
Expand Down Expand Up @@ -447,7 +456,9 @@ vtkNew<vtkPolyData> Render::createObjectMesh_(PhaseType phase) {
}

points->SetPoint(
point_index, currentPointPosition[0], currentPointPosition[1],
point_index,
currentPointPosition[0],
currentPointPosition[1],
currentPointPosition[2]);

// Set object attributes
Expand All @@ -474,9 +485,9 @@ vtkNew<vtkPolyData> Render::createObjectMesh_(PhaseType phase) {
lineValuesArray->SetName("bytes");
vtkNew<vtkCellArray> lines;
uint64_t n_e = 0;
std::map<
std::tuple<ElementIDType, ElementIDType>, std::tuple<uint64_t, double>>
edge_values;
std::
map<std::tuple<ElementIDType, ElementIDType>, std::tuple<uint64_t, double>>
edge_values;

fmt::print(" Creating inter-object communication edges\n");
for (auto& [pt_index, k, v] : sent_volumes) {
Expand Down Expand Up @@ -644,8 +655,12 @@ Render::createColorTransferFunction_(
}

/*static*/ vtkSmartPointer<vtkScalarBarActor> Render::createScalarBarActor_(
vtkSmartPointer<vtkMapper> mapper, const std::string& title, double x,
double y, uint64_t font_size, std::set<std::variant<double, int>> values) {
vtkSmartPointer<vtkMapper> mapper,
const std::string& title,
double x,
double y,
uint64_t font_size,
std::set<std::variant<double, int>> values) {
vtkSmartPointer<vtkScalarBarActor> scalar_bar_actor =
vtkSmartPointer<vtkScalarBarActor>::New();
scalar_bar_actor->SetLookupTable(mapper->GetLookupTable());
Expand Down Expand Up @@ -783,9 +798,15 @@ Render::createColorTransferFunction_(
}

void Render::renderPNG(
PhaseType phase, vtkPolyData* rank_mesh, vtkPolyData* object_mesh,
uint64_t edge_width, double glyph_factor, uint64_t win_size,
uint64_t font_size, std::string output_dir, std::string output_file_stem) {
PhaseType phase,
vtkPolyData* rank_mesh,
vtkPolyData* object_mesh,
uint64_t edge_width,
double glyph_factor,
uint64_t win_size,
uint64_t font_size,
std::string output_dir,
std::string output_file_stem) {
// Setup rendering space
vtkSmartPointer<vtkRenderer> renderer = setupRenderer_();

Expand Down Expand Up @@ -939,7 +960,11 @@ void Render::renderPNG(
}
vtkSmartPointer<vtkActor2D> object_qoi_scalar_bar_actor =
createScalarBarActor_(
glyph_mappers.at(1.0), object_qoi_name.c_str(), 0.52, 0.04, font_size,
glyph_mappers.at(1.0),
object_qoi_name.c_str(),
0.52,
0.04,
font_size,
values);
renderer->AddActor2D(object_qoi_scalar_bar_actor);
}
Expand Down Expand Up @@ -1054,8 +1079,15 @@ void Render::generate(uint64_t font_size, uint64_t win_size) {
fmt::print(" Image size: {}x{}px\n", win_size, win_size);
fmt::print(" Font size: {}pt\n", font_size);
this->renderPNG(
phase, rank_mesh, object_mesh, edge_width, glyph_factor, window_size,
font_size, output_dir_, output_file_stem_);
phase,
rank_mesh,
object_mesh,
edge_width,
glyph_factor,
window_size,
font_size,
output_dir_,
output_file_stem_);
}
};

Expand Down
39 changes: 29 additions & 10 deletions src/vt-tv/render/render.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ namespace vt::tv {
*/
struct Render {
private:
enum struct ColorType: uint8_t { Default = 0, BlueToRed = 1, HotSpot = 2, WhiteToBlack = 3 };
enum struct ColorType : uint8_t {
Default = 0,
BlueToRed = 1,
HotSpot = 2,
WhiteToBlack = 3
};

// quantities of interest
std::string rank_qoi_ = "load";
Expand Down Expand Up @@ -211,8 +216,11 @@ struct Render {
ColorType ct = ColorType::Default);

static vtkSmartPointer<vtkScalarBarActor> createScalarBarActor_(
vtkSmartPointer<vtkMapper> mapper, const std::string& title, double x,
double y, uint64_t font_size = 50,
vtkSmartPointer<vtkMapper> mapper,
const std::string& title,
double x,
double y,
uint64_t font_size = 50,
std::set<std::variant<double, int>> values = {});

static vtkSmartPointer<vtkRenderer> setupRenderer_();
Expand Down Expand Up @@ -255,10 +263,15 @@ struct Render {
* \param[in] in_selected_phase the phase selected (if max then render all)
*/
Render(
std::array<std::string, 3> in_qoi_request, bool in_continuous_object_qoi,
Info& in_info, std::array<uint64_t, 3> in_grid_size,
double in_object_jitter, std::string in_output_dir,
std::string in_output_file_stem, double in_resolution, bool in_save_meshes,
std::array<std::string, 3> in_qoi_request,
bool in_continuous_object_qoi,
Info& in_info,
std::array<uint64_t, 3> in_grid_size,
double in_object_jitter,
std::string in_output_dir,
std::string in_output_file_stem,
double in_resolution,
bool in_save_meshes,
bool in_save_pngs,
PhaseType in_selected_phase = std::numeric_limits<PhaseType>::max());

Expand All @@ -277,9 +290,15 @@ struct Render {
* @return A smart pointer to the resulting render window.
*/
void renderPNG(
PhaseType phase, vtkPolyData* rank_mesh, vtkPolyData* object_mesh,
uint64_t edge_width, double glyph_factor, uint64_t win_size,
uint64_t font_size, std::string output_dir, std::string output_file_stem);
PhaseType phase,
vtkPolyData* rank_mesh,
vtkPolyData* object_mesh,
uint64_t edge_width,
double glyph_factor,
uint64_t win_size,
uint64_t font_size,
std::string output_dir,
std::string output_file_stem);

void generate(uint64_t font_size = 50, uint64_t win_size = 2000);
};
Expand Down
10 changes: 7 additions & 3 deletions src/vt-tv/utility/json_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,11 @@ std::unique_ptr<Info> JSONReader::parse() {
objects.try_emplace(
object,
ObjectWork{
object, time, std::move(subphase_loads),
std::move(readed_user_defined), std::move(readed_attributes)});
object,
time,
std::move(subphase_loads),
std::move(readed_user_defined),
std::move(readed_attributes)});
}
}
}
Expand Down Expand Up @@ -245,7 +248,8 @@ std::unique_ptr<Info> JSONReader::parse() {
fmt::print(
"Warning: Communication {} -> {}: neither sender nor "
"recipient was found in objects.\n",
from_id, to_id);
from_id,
to_id);
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions src/vt-tv/utility/parse_render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ void ParseRender::parseAndRender(
}

std::array<std::string, 3> qoi_request = {
config["viz"]["rank_qoi"].as<std::string>("load"), "",
config["viz"]["rank_qoi"].as<std::string>("load"),
"",
config["viz"]["object_qoi"].as<std::string>("load")};

bool save_meshes = config["viz"]["save_meshes"].as<bool>(true);
Expand Down Expand Up @@ -165,8 +166,16 @@ void ParseRender::parseAndRender(

// Instantiate render
Render r(
qoi_request, continuous_object_qoi, *std::move(info), grid_size,
object_jitter, output_dir, output_file_stem, 1.0, save_meshes, save_pngs,
qoi_request,
continuous_object_qoi,
*std::move(info),
grid_size,
object_jitter,
output_dir,
output_file_stem,
1.0,
save_meshes,
save_pngs,
phase_id);

if (save_meshes || save_pngs) {
Expand Down
Loading

0 comments on commit c7c26f8

Please sign in to comment.