Skip to content

Conversation

@lifflander
Copy link
Collaborator

Fixes #2420 WIP

@lifflander lifflander linked an issue Apr 16, 2025 that may be closed by this pull request
@github-actions
Copy link

clang-format output for this changeset:

diff --git a/examples/collection/matrix.cc b/examples/collection/matrix.cc
index 94788c235..0bbb2947b 100644
--- a/examples/collection/matrix.cc
+++ b/examples/collection/matrix.cc
@@ -114,16 +114,22 @@ MatrixRegionEnum getRegion(vt::Index2D const idx) {
   return region;
 }
 
-vt::NodeType myMap(vt::Index2D* idx, vt::Index2D* range, vt::NodeType num_nodes) {
-  vtAbortIf(not (sqrt(num_nodes) * sqrt(num_nodes) == num_nodes), "Must be square number of procs");
+vt::NodeType
+myMap(vt::Index2D* idx, vt::Index2D* range, vt::NodeType num_nodes) {
+  vtAbortIf(
+    not(sqrt(num_nodes) * sqrt(num_nodes) == num_nodes),
+    "Must be square number of procs"
+  );
   int const np = sqrt(num_nodes);
-  vtAbortIf(not (range->x() / np) * np == range->x(), "Must be divisible");
-  vtAbortIf(not (range->y() / np) * np == range->y(), "Must be divisible");
-  int const proc = (idx->x() / (range->x() / np)) * np + idx->y() / (range->y() / np);
+  vtAbortIf(not(range->x() / np) * np == range->x(), "Must be divisible");
+  vtAbortIf(not(range->y() / np) * np == range->y(), "Must be divisible");
+  int const proc =
+    (idx->x() / (range->x() / np)) * np + idx->y() / (range->y() / np);
   return proc;
 }
 
-int32_t getSubblock(vt::Index2D* idx, vt::Index2D* range, vt::NodeType num_nodes) {
+int32_t
+getSubblock(vt::Index2D* idx, vt::Index2D* range, vt::NodeType num_nodes) {
   int const np = sqrt(num_nodes);
   int const subblock =
     (idx->x() / (range->x() / np)) * np * subblocks_per_rank +
@@ -132,7 +138,6 @@ int32_t getSubblock(vt::Index2D* idx, vt::Index2D* range, vt::NodeType num_nodes
 }
 
 struct MatrixBlock : vt::Collection<MatrixBlock, vt::Index2D> {
-
   void setTimeForLB() {
     std::vector<vt::LoadType> vec;
     getLBData().setTime(getWork(region), vec);
@@ -146,7 +151,9 @@ struct MatrixBlock : vt::Collection<MatrixBlock, vt::Index2D> {
     int subblock = getSubblock(&idx, &global_range, num_nodes);
     int proc = myMap(&idx, &global_range, num_nodes);
 
-    ptr->valInsert("shared_id", static_cast<double>(subblock) , true, true, false);
+    ptr->valInsert(
+      "shared_id", static_cast<double>(subblock), true, true, false
+    );
     ptr->valInsert("shared_bytes", 1.0, true, true, false);
     ptr->valInsert("task_serialized_bytes", 0.0, true, true, false);
     ptr->valInsert("task_footprint_bytes", 0.0, true, true, false);
@@ -154,7 +161,7 @@ struct MatrixBlock : vt::Collection<MatrixBlock, vt::Index2D> {
     ptr->valInsert("rank_working_bytes", 0.0, true, true, false);
     ptr->valInsert("home_rank", static_cast<double>(proc), true, true, false);
   }
-  
+
   void setRegion() {
     auto const my_index = getIndex();
     region = getRegion(my_index);
@@ -174,12 +181,10 @@ int main(int argc, char** argv) {
   vt::initialize(argc, argv);
 
   if (argc != 9) {
-    vtAbort(
-      "Expecting 8 arguments: "
-      "<N> <slot-factor> <exterior-factor> "
-      "<slot-slot time> <slot-surface/surface-slot time> "
-      "<exterior time> <interior time> <subblocks-per-rank>"
-    );
+    vtAbort("Expecting 8 arguments: "
+            "<N> <slot-factor> <exterior-factor> "
+            "<slot-slot time> <slot-surface/surface-slot time> "
+            "<exterior time> <interior time> <subblocks-per-rank>");
   } else {
     N = atoi(argv[1]);
     slot_percent = atof(argv[2]);
@@ -205,14 +210,8 @@ int main(int argc, char** argv) {
       "\texterior_time={}\n"
       "\tinterior_time={}\n"
       "\tsubblocks_per_rank={}\n",
-      N,
-      slot_percent,
-      exterior_percent,
-      slot_time,
-      slot_surface_time,
-      exterior_time,
-      interior_time,
-      subblocks_per_rank
+      N, slot_percent, exterior_percent, slot_time, slot_surface_time,
+      exterior_time, interior_time, subblocks_per_rank
     );
   }
 
@@ -252,12 +251,12 @@ int main(int argc, char** argv) {
   }
 
   auto matrix = vt::makeCollection<MatrixBlock>("matrix block")
-    .collective(true)
-    .bounds(range)
-    .listInsert(list)
-    .mapperFunc<myMap>()
-    .wait();
-  
+                  .collective(true)
+                  .bounds(range)
+                  .listInsert(list)
+                  .mapperFunc<myMap>()
+                  .wait();
+
   if (this_node == 0) {
     vt_print(gen, "Starting setRegion and set time\n");
   }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add benchmark for paper

2 participants