working: rip why is it slower

This commit is contained in:
Michael Zhang 2023-11-25 07:07:20 +00:00
parent d477611892
commit 0619d79caa
2 changed files with 26 additions and 17 deletions

View file

@ -1,10 +1,10 @@
.PHONY: run clean .PHONY: run clean
CFLAGS += -g -pg # CFLAGS += -O3
# CFLAGS += -DFMT_HEADER_ONLY -O3 CFLAGS += -DFMT_HEADER_ONLY -g
# LDFLAGS += $(shell pkg-config --libs fmt) # LDFLAGS += $(shell pkg-config --libs fmt)
lpa: lpa.cpp Makefile test.gdb lpa: lpa.cpp Makefile
mpic++ $(CFLAGS) $(LDFLAGS) -o $@ lpa.cpp mpic++ $(CFLAGS) $(LDFLAGS) -o $@ lpa.cpp
lpac: lpa.cpp lpac: lpa.cpp

View file

@ -14,8 +14,10 @@
#include <unistd.h> #include <unistd.h>
#include <utility> #include <utility>
// #include <fmt/format.h> #ifdef FMT_HEADER_ONLY
// #include <fmt/ranges.h> #include <fmt/format.h>
#include <fmt/ranges.h>
#endif
#define TAG_SEND_NUM_EDGES 1001 #define TAG_SEND_NUM_EDGES 1001
#define TAG_SEND_EDGES 1002 #define TAG_SEND_EDGES 1002
@ -291,10 +293,6 @@ int main(int argc, char **argv) {
} }
} }
// std::cout << fmt::format("[{}] Helloge {}", rank,
// fmt::join(new_labels, ", "))
// << std::endl;
// Have there been any changes in the labels? // Have there been any changes in the labels?
int num_changes = new_labels.size(); int num_changes = new_labels.size();
int total_changes; int total_changes;
@ -353,11 +351,7 @@ int main(int argc, char **argv) {
std::cout << "Done! " << label_count.size() << std::endl; std::cout << "Done! " << label_count.size() << std::endl;
} else { } else {
std::vector<int> flat_assignments; MPI_Send(node_label_assignment_vec, num_my_nodes, MPI_INT, 0,
for (int i = 0; i < num_my_nodes; ++i) {
flat_assignments.push_back(node_label_assignment_vec[i]);
}
MPI_Send(flat_assignments.data(), flat_assignments.size(), MPI_INT, 0,
TAG_SEND_FINAL_RESULT, MPI_COMM_WORLD); TAG_SEND_FINAL_RESULT, MPI_COMM_WORLD);
} }
#pragma endregion #pragma endregion
@ -428,6 +422,21 @@ int lookup_assignment(int *base_node_assignment, pair my_node_range,
int index = -1, ctr = 0; int index = -1, ctr = 0;
std::vector<int> inner(recv_map[process_from].begin(), std::vector<int> inner(recv_map[process_from].begin(),
recv_map[process_from].end()); recv_map[process_from].end());
// {
// int lo = 0, hi = count;
// while (lo < hi) {
// int mid = (lo + hi) / 2;
// int midk = inner[mid];
// if (node_number < midk)
// hi = mid;
// else if (node_number > midk)
// lo = mid;
// else {
// index = mid;
// break;
// }
// }
// }
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
int remote_node = inner[i]; int remote_node = inner[i];
if (node_number == remote_node) { if (node_number == remote_node) {