diff --git a/assignments/03/.gitignore b/assignments/03/.gitignore index 00b0e11..cca9c0b 100644 --- a/assignments/03/.gitignore +++ b/assignments/03/.gitignore @@ -1,3 +1,4 @@ lpa compile_commands.json -.cache \ No newline at end of file +.cache +report.pdf \ No newline at end of file diff --git a/assignments/03/Makefile b/assignments/03/Makefile index e0a80fe..acaba41 100644 --- a/assignments/03/Makefile +++ b/assignments/03/Makefile @@ -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' \ No newline at end of file + 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 \ No newline at end of file diff --git a/assignments/03/lpa.cpp b/assignments/03/lpa.cpp index 861dcd3..2dcd295 100644 --- a/assignments/03/lpa.cpp +++ b/assignments/03/lpa.cpp @@ -14,8 +14,8 @@ #include #include -#include -#include +// #include +// #include #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 diff --git a/assignments/03/report.typ b/assignments/03/report.typ new file mode 100644 index 0000000..e69de29 diff --git a/assignments/03/zhan4854.tar.gz b/assignments/03/zhan4854.tar.gz new file mode 100644 index 0000000..297483a Binary files /dev/null and b/assignments/03/zhan4854.tar.gz differ