This commit is contained in:
Michael Zhang 2023-11-25 02:26:14 +00:00
parent ca96bf8b2d
commit fac66e8e70
5 changed files with 33 additions and 8 deletions

View file

@ -1,3 +1,4 @@
lpa
compile_commands.json
.cache
report.pdf

View file

@ -4,10 +4,19 @@ CFLAGS += -DFMT_HEADER_ONLY
LDFLAGS += $(shell pkg-config --libs fmt)
clean:
rm lpa
rm -f lpa
lpa: lpa.cpp
mpic++ $(CFLAGS) $(LDFLAGS) -o $@ -g $<
run:
watchexec -c clear 'make lpa && mpirun -n 4 ./lpa dataset/both_1000.txt'
report.pdf: report.typ
typst compile $< $@
zhan4854.tar.gz: Makefile ASSIGNMENT.md lpa.cpp report.pdf
mkdir -p zhan4854
cp $^ zhan4854
tar -czvf $@ zhan4854
rm -r zhan4854

View file

@ -14,8 +14,8 @@
#include <unistd.h>
#include <utility>
#include <fmt/format.h>
#include <fmt/ranges.h>
// #include <fmt/format.h>
// #include <fmt/ranges.h>
#define TAG_SEND_NUM_EDGES 1001
#define TAG_SEND_EDGES 1002
@ -154,6 +154,10 @@ int main(int argc, char **argv) {
}
#pragma endregion
// STEP 2 TIMER STARTS HERE
MPI::COMM_WORLD.Barrier();
double step_2_start_time = MPI::Wtime();
// Each process analyzes the non-local edges that are contained in its portion
// of the graph.
#pragma region
@ -209,6 +213,10 @@ int main(int argc, char **argv) {
#pragma region
#pragma endregion
// STEP 5 TIMER STARTS HERE
MPI::COMM_WORLD.Barrier();
double step_5_start_time = MPI::Wtime();
// The processes perform the transfers of non-local labels and updates of
// local labels until convergence.
#pragma region
@ -289,9 +297,9 @@ int main(int argc, char **argv) {
int total_changes;
MPI::COMM_WORLD.Allreduce(&num_changes, &total_changes, 1, MPI_INT,
MPI::SUM);
std::cout << fmt::format("[{}] # updates: {} ({})", rank, num_changes,
total_changes)
<< std::endl;
// std::cout << fmt::format("[{}] # updates: {} ({})", rank, num_changes,
// total_changes)
// << std::endl;
if (total_changes == 0) {
break;
@ -304,6 +312,13 @@ int main(int argc, char **argv) {
}
#pragma endregion
// END TIMERS
MPI::COMM_WORLD.Barrier();
double end_time = MPI::Wtime();
printf("2-5 Time: %0.04fs\n", end_time - step_2_start_time);
printf("5 Time: %0.04fs\n", end_time - step_5_start_time);
// The results are gathered to a single process, which writes them to the
// disk.
#pragma region

View file

Binary file not shown.